Created
December 14, 2012 12:38
-
-
Save seb-thomas/4285197 to your computer and use it in GitHub Desktop.
set marker from json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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>' | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"
} ]
}