Skip to content

Instantly share code, notes, and snippets.

@seb-thomas
Created December 14, 2012 12:38
Show Gist options
  • Save seb-thomas/4285197 to your computer and use it in GitHub Desktop.
Save seb-thomas/4285197 to your computer and use it in GitHub Desktop.
set marker from json
$.getJSON('media/js/markers.json', function(data){
$.each(data.markers, function(i, marker){
map.addMarker({
id: i,
tags: marker.tag,
lat: marker.latitude,
lng: marker.longitude,
infoWindow: {
content: '<h2>' + marker.name + '</h2><p>' + marker.address + '</p>'
}
});
});
});
@seb-thomas
Copy link
Author

json is:
{"markers":[ {
"id": "1",
"tag": "bar",
"latitude":51.527145976089415,
"longitude": -0.08147038015136054,
"name":"Meat Mission",
"address":"Hoxton Square"
}, {
"id": "2",
"tag": "foo",
"latitude":51.53144023349466,
"longitude":-0.0802026567871561,
"name":"Troy",
"address":"Hoxton St"
} ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment