Skip to content

Instantly share code, notes, and snippets.

@ebinnion
Created April 6, 2012 05:16
Show Gist options
  • Save ebinnion/2317191 to your computer and use it in GitHub Desktop.
Save ebinnion/2317191 to your computer and use it in GitHub Desktop.
Embed Google Map with Geocode
<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>
<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