Created
July 24, 2014 17:17
-
-
Save wiredmax/53f77af8c7601a39a0e1 to your computer and use it in GitHub Desktop.
Google Geocoder APIv3
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"> | |
<meta charset="utf-8"> | |
<title>Geocoding service</title> | |
<style> | |
html, body, #map-canvas { | |
height: 100%; | |
margin: 0px; | |
padding: 0px | |
} | |
</style> | |
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> | |
<script> | |
var geocoder; | |
var map; | |
function initialize() { | |
geocoder = new google.maps.Geocoder(); | |
var mapOptions = { | |
zoom: 12, | |
} | |
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); | |
var address = "2065 Parthenais, Montreal" | |
geocoder.geocode( { 'address': address}, function(results, status) { | |
console.log(results[0].geometry.location) | |
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); | |
} | |
}); | |
} | |
google.maps.event.addDomListener(window, 'load', initialize); | |
</script> | |
</head> | |
<body> | |
<div id="map-canvas"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment