Skip to content

Instantly share code, notes, and snippets.

@desireesantos
Last active December 31, 2015 09:19
Show Gist options
  • Save desireesantos/7965742 to your computer and use it in GitHub Desktop.
Save desireesantos/7965742 to your computer and use it in GitHub Desktop.
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