Search

GeoJsonLayer

The GeoJSON layer uses the GeoJSON data format to draw geometric objects over the map. See the GeoJSON Layer docs for details.

Parameters

object

The data to load into the layer.

id

optional
string

A unique id of the layer. If not specified, it will be generated automatically.

The options to set on the layer.

Overrides the style of the specified GeoJSON features.

ref

optional
RefObject<LayerRefProps>

Ref prop for use with React's useRef or createRef. This allows access to the imperative part of the layer's API.

visible

optional
boolean

Whether the layer is visible.

Returns ReactNode

GeoJsonFeatureStyle

Specifies the styling for GeoJSON features. These styles can be overridden with overrideStyles.

const geoJsonData = {
  type: 'Feature',
  id: 'EiffelTower_linestring',
  properties: {
    color: 'rgba(0,0,255,0.7)',    // custom color
    width: 10,                     // custom line width
  },
  geometry: {
    type: 'LineString',
    coordinates: [
      [2.2955, 48.8594],
      [2.2935, 48.8594],
    ],
  },
};

border

optional
object

Defines the border styling for Polygon, MultiPolygon, Point and MultiPoint features.

color

optional
string default: '#404040'

The color of the border.

width

optional
number default: 0

The width of the border. Set the units in units.

color

optional
string default: '#808080'

The fill color for the GeoJSON feature.

radius

optional
number default: 1

The radius for Point and MultiPoint features. Set the units in units.

width

optional
number default: 2

The width for LineString and MultiLineString features. Set the units in units.

GeoJsonLayerData

GeoJsonLayerData GeoJSON | Feature[]

The data describing the geometric object in GeoJSON format. Accepts a single GeoJSON object or an array of GeoJSON feature objects.

const geoJsonData = {
  type: 'Feature',
  id: 'EiffelTower_polygon',
  properties: {
    color: 'rgba(0,255,0,0.3)',
  },
  geometry: {
    type: 'Polygon',       // the polygon is a rectangle around the Eiffel Tower
    coordinates: [
      [
        [2.2935, 48.8574], // bottom-left
        [2.2955, 48.8574], // bottom-right
        [2.2955, 48.8594], // top-right
        [2.2935, 48.8594], // top-left
      ],
    ],
  },
};

GeoJsonLayerOptions

The options to set on this layer.

 const geoJsonOptions = {
   filled: false,
   units: 'pixels'
 };

// ...

 return (
   <MapWeave>
   <GeoJsonLayer data={geoJsonData} options={geoJsonOptions} />
   </MapWeave>
 );

filled

optional
boolean default: true

Set to true to fill the Polygon, MultiPolygon, Point and MultiPoint features with the color set in color.

units

optional
"meters" | "pixels" default: 'pixels'

Sets the units used for border.width, width and radius.

GeoJsonLayerRefProps

An instance method to return the bounds of the items in the layer with the specified ids, or all items if no ids are specified. Returns null if there are no items to compute bounds for.

Parameters

ids
optional
string[]

Returns LngLatBounds

An object defining the bounds of the specified items.

GeoJsonLayerStyleOverride

Defines the style properties to override for the specified GeoJSON features.

string | string[]

The id or ids of the GeoJSON features.

The style properties to apply to the specified GeoJSON features.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.