Created
November 17, 2011 18:47
-
-
Save nogo/1374056 to your computer and use it in GitHub Desktop.
Google Maps Page Integration
This file contains hidden or 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
<div id="map_container" style="width: 100%; height: 300px; margin-bottom: 10px;"></div> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script> | |
<script type="text/javascript"> | |
var Markers = [{"address":"ADRESSE","info":"","title":""}]; | |
var Marker = "/path/to/image/marker.png"; | |
(function($, markers, markerIcon) { | |
var map, geocoder, infowindow; | |
function initializeMap() { | |
map = new google.maps.Map(document.getElementById("map_container"), { | |
zoom: 10, | |
center: new google.maps.LatLng(0, 0), | |
mapTypeId: google.maps.MapTypeId.SATELLITE, | |
mapTypeControl: true, | |
navigationControl: false, | |
streetViewControl: true | |
}); | |
// Create new geocoding object | |
geocoder = new google.maps.Geocoder(); | |
infowindow = new google.maps.InfoWindow(); | |
// Download the data in data.xml and load it on the map. | |
for (var i = 0; i < markers.length; i++) { | |
if (geocoder) { | |
geocoder.geocode({address: markers[i]['address']}, function(results, status){ | |
if (status == google.maps.GeocoderStatus.OK) { | |
map.fitBounds(results[0].geometry.viewport); | |
var marker = new google.maps.Marker({ | |
map: map, | |
position: results[0].geometry.location, | |
icon: markerIcon | |
}); | |
} else { | |
alert("Geocode was not successful for the following reason: " + status); | |
} | |
}); | |
} | |
} | |
} | |
$(document).ready(initializeMap); | |
})(jQuery, Markers, Marker); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment