Skip to content

GeoJSON

Andreas Fast edited this page Feb 13, 2016 · 2 revisions

GeoJSON is a format for encoding a variety of geographic data structures. Here is an example GeoJSON.

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

We use GeoJSON mainly to place markers, polylines and polygons on the map. Other features including MultiPoint, MultiLineString, MultiPolygon, GeometryCollection are available in the GeoJSON format but unsupported at this time. Consider contributing!

For more information about GeoJSON go to geojson.org.

Example featuring one of each supported types

map: {
  geojson: '{
    "type": "FeatureCollection",
    "features": [{
      "type":"Feature",
      "geometry":{"type":"Point", "coordinates":[-32.026862,-55.425003]},
      "properties":{"image": "./marker.png"}
    }, {
      "type": "Feature",
      "geometry": {"type": "LineString", "coordinates": [ [-32.026862,-55.425003], [-31.026862,-55.425003], [-31.026862,-54.425003], [-32.026862,-54.425003] ] },
      "properties": {"color": "#000000"}
    }, {
      "type": "Feature",
      "geometry": {"type": "Polygon", "coordinates": [ [-32.126862,-55.825003], [-31.426862,-55.225003], [-31.326862,-54.825003], [-32.146862,-54.835003] ] },
      "properties": {
        "stroke": true,
        "color": "#000000",
        "weight": 2,
        "opacity": 1,
        "fill": true,
        "fillColor": "#ffffff",
        "fillOpacity": 1,
        "fillRule": "evenodd",
        "dashArray": "5,2,3",
        "lineCap": "round",
        "lineJoin": "round"
      }
    }]
  }'
}

Clone this wiki locally