Skip to content

Instantly share code, notes, and snippets.

@jasonbell
Forked from mapsam/geojson.js
Last active September 26, 2017 15:08
Show Gist options
  • Save jasonbell/fc937d5f3da61678becb929bf837f42c to your computer and use it in GitHub Desktop.
Save jasonbell/fc937d5f3da61678becb929bf837f42c to your computer and use it in GitHub Desktop.
Create a GeoJSON structure in for loop
var geojson = {};
geojson['type'] = 'FeatureCollection';
geojson['features'] = [];
for (var k in data) {
var newFeature = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": parseFloat(data[k].lng), parseFloat(data[k].lon)]
},
"properties": {
"title": data[k].title,
"description": data[k].desc
}
}
geojson['features'].push(newFeature);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment