-1

Given three points (or more) on a map, I would like to find the point that is closest to all of them and is at the same driving distance from all of them. I would like to do this in Google Maps, using the provided driving directions service.

Any idea?

Thanks a lot

UPDATE

in this question is mentioned a way to find the center of a bunch of locations, which could be a first step

var locations = [
            ['Bondi Beach', -33.890542, 151.274856, 4],
            ['Coogee Beach', -33.923036, 151.259052, 5],
            ['Cronulla Beach', -34.028249, 151.157507, 3],
            ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
            ['Maroubra Beach', -33.950198, 151.259302, 1]
        ];

//[OTHER CODE]

var bound = new google.maps.LatLngBounds();

for (i = 0; i < locations.length; i++) {
  bound.extend( new google.maps.LatLng(locations[i][1], locations[i][2]) );

  // OTHER CODE
}

var geoCenter = bound.getCenter();//THIS IS THE GEOGRAPHICAL CENTER

After this, one could just retrieve the driving directions from each point to the center, and hope they're about the same distance. If, for any reason, the distances are too different, some kind of methodology should developed in order to find the desired point.

Community
  • 1
  • 1
Gombo
  • 708
  • 2
  • 10
  • 20

1 Answers1

2

I dont think there is any service that will achieve that.

You could attempt to calculate the geographic centre point and then calculate the driving distance to that point from each point using the direction services. If one or more of the driving distances is significantly longer the other you could than adjust the 'centre point' along the route and trying again.

Also consider three point along a straight road - there is nowhere that is both closest and equidistant to all of them

MymsMan
  • 191
  • 8