Created
May 2, 2013 12:25
-
-
Save machiel/5501863 to your computer and use it in GitHub Desktop.
Info boxes
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
if(typeof google !== undefined) { | |
var map; | |
var infoWindows = []; | |
function initialize() { | |
var mapOptions = { | |
zoom : 7, | |
center : new google.maps.LatLng(52.212992, 5.27937), | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById('google-map'), mapOptions); | |
var geocoder = new google.maps.Geocoder(); | |
for(var i = 0; i < meetingPoints.length; i++) { | |
var meetingPoint = meetingPoints[i]; | |
var address = meetingPoint['address'] + ', ' + meetingPoint['postalCode'] + ', ' + meetingPoint['city']; | |
geocoder.geocode({ 'address' : address }, function(results, status) { | |
if(status === google.maps.GeocoderStatus.OK) { | |
var contentInfo = results[0].formatted_address.replace(/, /g, '<br>'); | |
var infowindow = new google.maps.InfoWindow({ | |
content : contentInfo | |
}); | |
infoWindows[infoWindows.length] = infowindow; | |
var marker = new google.maps.Marker({ | |
map : map, | |
position: results[0].geometry.location | |
}); | |
google.maps.event.addListener(marker, 'click', function() { | |
for(var x = 0; x < infoWindows.length; x++) { | |
infoWindows[x].close(); | |
} | |
infowindow.open(map,marker); | |
}) | |
} | |
}); | |
} | |
} | |
initialize(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment