Skip to content

Structure of GeoJSON

Kumar Damani edited this page Feb 26, 2019 · 3 revisions

Following the GeoJSON spec www.geojson.org, the JSON that we should be passing around must contain at minimum the following 2 fields:

  1. type : STRING, and set this to "Point".
  2. coordinates : Array of decimals, where first element is the longitude, second element is the latitude (there is a reason for this).

So the following object would be a good example:

var data = {
    "type": "Point",
    "coordinates": [-79.0878, 43.0877]
};

Of course you may also add more fields to this object, but they should at minimum contain the two described above, for example:

var data = {
    "type": "Point",
    "coordinates": [-79.0878, 43.0877],
    "age": 45,
    "foo": "bar",
    "timestamp": <timestamp>
};

would also be valid.