Skip to main content

GeoJSON Layer

The GeoJSON layer uses the GeoJSON data format to draw geometric objects over the map.

These geometric objects, such as a polygon, can be used to:

  • Highlight areas of the map.
  • Geofence the nodes defined in the network layer to an area of the map.
  • Filter the trajectories defined in the observations layer to an area of the map.

Data Format

An example of a GeoJSON object is as follows:

const vancouverDowntown = {
type: "FeatureCollection",
features: [
{
type: "Feature",
id: "vancouver-downtown",
geometry: {
coordinates: [
[
[-123.112266, 49.290164],
[-123.104240, 49.288166],
[-123.099288, 49.289272],
[-123.099998, 49.272750],
[-123.101699, 49.272972],
[-123.111076, 49.272926],
[-123.114448, 49.271774],
[-123.121162, 49.269538],
[-123.129280, 49.269531],
[-123.137680, 49.275318],
[-123.132331, 49.276931],
[-123.121093, 49.284366],
[-123.136680, 49.294456],
[-123.134689, 49.295810],
[-123.122711, 49.291500],
[-123.112266, 49.290164],
],
],
type: "Polygon",
},
},
],
};

You can assign an ID to a GeoJSON feature, allowing event handlers to return the ID for an interaction.

A full definition of the GeoJSON data format can be found at https://geojson.org/.

Explore the GeoJSON Layer examples to learn more.