Last active
December 31, 2015 09:19
-
-
Save desireesantos/7965742 to your computer and use it in GitHub Desktop.
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
function initialize() { | |
geocoder = new google.maps.Geocoder(); | |
alert(geocoder.latitude); | |
alert(geocoder.longitude); | |
var latlng = new google.maps.LatLng(-22.618827234831404, -42.57636812499999); | |
var mapOptions = { | |
zoom: 8, | |
center: latlng | |
} | |
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); | |
} | |
function goToAddress() { | |
var address = document.getElementById('address').preventDefault(); | |
geocoder.geocode( { 'address': address}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
var marker = map.setCenter(results[0].geometry.location); | |
new google.maps.Marker({ | |
map: map, | |
position: results[0].geometry.location, | |
icon:"/img/icon.png" | |
}); | |
} else { | |
alert('Geocode was not successful for the following reason: ' + status); | |
} | |
}); | |
} | |
google.maps.event.addDomListener(window, 'load', initialize); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment