Skip to content

Instantly share code, notes, and snippets.

@lu1s
Created September 7, 2011 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lu1s/1199868 to your computer and use it in GitHub Desktop.
Save lu1s/1199868 to your computer and use it in GitHub Desktop.
google maps quick address map
/*
* Google Maps Quick Address Map
* This snippet gets an address (parameter a)
* and plots a Google Map with a centered
* marker in the id-given element (parameter e)
*
* You need to add the Google Maps V3 API to your site:
* <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
*
* Enjoy!
*/
var geocoder = new google.maps.Geocoder();
var plotMap = function(a,e) {
geocoder.geocode({address:a},function(results,status){
if(status == google.maps.GeocoderStatus.OK){
var map = new google.maps.Map(document.getElementById(e),{
zoom: 15, //here you can change the zoom
center:results[0].geometry.location,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
})
}
else
alert("Geolocation could not be possible: "+status)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment