Wednesday, March 31, 2010

Nearest intersection to an address on Google Maps

How to find the nearest address on a Google Map using it's API.
There are at least 2 steps in order to achieve this goal.
Let's say that you ask to geocode an address.
The map returns the exact location and centers the map on the address.
Then you ask for a direction from point A, which is the SW bound of the viewport, to point B, which is your address, to point C which is the NE bound of the viewport.
So, now you could know the last intersection before the address and also the first intersection after the address.
If you want all the intersection you can repeat the direction search with different routes, let's say NW to SE, N to S, E to W. and so on...
It might not be accurate, but is a workaround.

No comments:

Post a Comment