Created
April 6, 2012 05:16
-
-
Save ebinnion/2317191 to your computer and use it in GitHub Desktop.
Embed Google Map with Geocode
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
<div id="map" style="width: 413px; height: 300px;"></div> | |
<script type="text/javascript"> | |
var mapOptions = { | |
zoom: 16, | |
center: new google.maps.LatLng(54.00, -3.00), | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var geocoder = new google.maps.Geocoder(); | |
var address = '3410 Taft Blvd Wichita Falls, TX 76308'; | |
geocoder.geocode( { 'address': address}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
map.setCenter(results[0].geometry.location); | |
var marker = new google.maps.Marker({ | |
map: map, | |
position: results[0].geometry.location | |
}); | |
} else { | |
alert("Geocode was not successful for the following reason: " + status); | |
} | |
}); | |
var map = new google.maps.Map(document.getElementById("map"), mapOptions); | |
</script> |
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
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment