Created
April 3, 2012 23:17
-
-
Save mynameispj/2296224 to your computer and use it in GitHub Desktop.
Google Maps API JS
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 type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAOj_3CRyephdFtCbWh5OZ6eXa49zcJFHM&sensor=false"></script> | |
<div id="address" style="display:none;"><!--address for the map goes here-->8134 Country Village Drive Cordova, TN 38016</div> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
var geocoder; | |
function initialize() { | |
geocoder = new google.maps.Geocoder(); | |
var myOptions = { | |
center: new google.maps.LatLng(-34.397, 150.644), | |
zoom: 12, | |
panControl: false, | |
streetViewControl: false, | |
mapTypeControl: false, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(document.getElementById("map"),myOptions); | |
var address = $("#address").text(); | |
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); | |
} | |
}); | |
} | |
initialize(); | |
}); | |
</script> | |
<div id="map"><!--map will actually render here--></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment