Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created December 4, 2011 00:32
Show Gist options
  • Save matiskay/1428630 to your computer and use it in GitHub Desktop.
Save matiskay/1428630 to your computer and use it in GitHub Desktop.
Maps
$.getJSON('myfile.json', function(data){
$.each(data.locations, function(i, loc) {
var myLatLng = new google.maps.LatLng(loc.lat, loc.lng);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: loc.title
//icon: loc.image,
//shadow: shadow
});
Map.markers.push(marker);
(function(i, marker) {
google.maps.event.addListener(marker, 'click', function() {
if (!infowindow) {
infowindow = new google.maps.InfoWindow();
}
infowindow.setContent(loc.description);
infowindow.open(map, marker);
});
})(i, marker);
});
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment