Created
October 26, 2012 12:08
-
-
Save hugodias/3958416 to your computer and use it in GitHub Desktop.
Google maps como chegar
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
var maps; | |
var directionsService = new google.maps.DirectionsService(); | |
var directionsDisplay = new google.maps.DirectionsRenderer(); | |
var infoWindow = new google.maps.InfoWindow({maxWidth: 460}); | |
var markerOffice = new google.maps.Marker({ | |
title: 'MARK_TITLE_HERE', | |
//icon: 'site/images/icon-feed.gif', // icon | |
position: new google.maps.LatLng('LAT_HERE', 'LONG_HERE') | |
}); | |
function initialize() { | |
var options = { | |
zoom: 15, | |
center: markerOffice.position, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById("mapa"), options); | |
markerOffice.setMap(map); | |
google.maps.event.addListener(markerOffice, 'click', function() { | |
infoWindow.setContent('HTML_MARK_CONTENT'); | |
infoWindow.open(map, markerOffice); | |
}); | |
} | |
$(function() { | |
$('#form-endereco-rota').submit(function() { | |
infoWindow.close(); | |
markerOffice.setMap(null); | |
directionsDisplay.setMap(null); | |
directionsDisplay = new google.maps.DirectionsRenderer(); | |
var request = { | |
origin: $("#endereco").val(), | |
destination: markerOffice.position, | |
travelMode: google.maps.DirectionsTravelMode.DRIVING | |
}; | |
directionsService.route(request, function(response, status) { | |
if (status == google.maps.DirectionsStatus.OK) { | |
directionsDisplay.setDirections(response); | |
directionsDisplay.setMap(map); | |
} | |
}); | |
return false; | |
}); | |
initialize(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment