Skip to content

Instantly share code, notes, and snippets.

@mynameispj
Created April 3, 2012 23:17
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 mynameispj/2296224 to your computer and use it in GitHub Desktop.
Save mynameispj/2296224 to your computer and use it in GitHub Desktop.
Google Maps API JS
<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