Answer the question
In order to leave comments, you need to log in
Calculate the distance between 2 objects. Google Maps API v.3
Faced the problem of calculating the distance between objects/cities located at large distances from each other, for example, "the city of Moscow, Russia" - "Berlin, Germany". But "the city of Moscow, Russia" - "the city of Vladimir, Vladimir region, Russia" considers. I am using Google Maps API v.3.
var gMarkers, gDirections
...
$('#submitdata').click(function(){
gDirections.Service.route({
origin: gMarkers.point1.position,
destination: gMarkers.point2.position,
travelMode: google.maps.TravelMode.DRIVING
}, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
gDirections.Renderer.setDirections(result)
gMarkers.point1.setVisible(false)
gMarkers.point2.setVisible(false)
$('#gmap_result').html(result.routes[0].legs[0].distance.text)
}
console.debug(result)
})
return false;
})
Answer the question
In order to leave comments, you need to log in
Someone will be interested - I use open.mapquestapi.com/nominatim/ (base from openstreetmap.org) to get coordinates (although I didn’t find how to filter by type - I filter after receiving it), and cloudmade.com/ to calculate distances - too cant with directions.loadFromWaypoints () - after the calculation I can not call the function.
The fact is that Google is bad at building routes in the CIS. Even banal ones.
habreffect.ru/files/768/77f437924/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA-6.png
maybe it will come in handy for you - so far he thinks it’s too long, but it’s normal for me))
calc-api.ru/apipages:CitiesDistance
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question