Created
September 7, 2011 05:50
-
-
Save lu1s/1199868 to your computer and use it in GitHub Desktop.
google maps quick address map
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
/* | |
* 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