Answer the question
In order to leave comments, you need to log in
How to get the coordinates of the marker when dragging it around the map?
When entering the departure and destination addresses, the map is initialized:
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer({
draggable: true});
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: $('[name=from_address]').val()
});
directionsDisplay.setMap(map);
directionsService.route({
origin: $('[name=from_address]').val(),
destination: $('[name=where_address]').val(),
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response,{preserveViewport: true});
} else {
$('#map').html('<div class="ajax-error">Невозможно проложить автомобильный маршрут! Укажите другой адрес.</div>');
}
});
Answer the question
In order to leave comments, you need to log in
Everyone found this in the documentation, https://developers.google.com/maps/documentation/j...
issue closed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question