K
K
Karen Kratyan2011-05-07 12:54:39
Google Maps
Karen Kratyan, 2011-05-07 12:54:39

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;
    })

Doesn't Google count long distances?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
K
Karen Kratyan, 2011-05-24
@kratkar

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.

C
CSharpRU, 2011-05-07
@CSharpRU

Considers. I recommend reading the manuals.

D
dreamfall, 2011-05-08
@dreamfall

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

D
Demon2009g, 2015-04-12
@Demon2009g

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

A
adreanolerm79, 2016-01-27
@adreanolerm79

Count here mapszoom.com/ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question