views:

28

answers:

1

Can either Bing or Google Maps allow you to pass in a collection of points and then interrogate that collection to only plot the X nearest points?

I am asking because it may be difficult to pre-filter this data and would be much simpler to supply the entire list and filter it within the API itself.

A: 

You'd have to do most of the legwork yourself, the APIs aren't going to do every function under the sun for you.

However, I know that you can find the distance between two points using the Google Maps API. Take a look at the distanceFrom method in the API reference. It would only be a matter of calculating the distances for every point in your XML file, then taking the smallest X numbers.

Regarding your comment - yeah I guess looping through 300 items on the client-side might be a bit much. One solution would be to store the GPS coordinates for each point in your XML file (if not already), then create a function that would prune away most of the points using a simple distance calculator (you'd have to research that yourself). Then pass the remaining points (maybe 30 of them) into the API to calculate more accurate distances.

DisgruntledGoat
There are likely to be around 300+ items in the XML in some cases so I wanted to steer clear of looping through all of them if at all possible.I'd be happy to do this filtering myself but the CMS supplying this data won't be able to hence my wondering if Google or Bing can do it instead.
Simon
@Simon: You could perhaps do a little pre-processing yourself and remove any obvious outliers, etc. I'll update my answer.
DisgruntledGoat