开发者

Google Maps Direction Radius

Using google maps v3 I can get directions from one marker to another but is there anyway to figure out other markers that are a max distance from the route I will travel

Example:

Say I am goin开发者_如何学Gog form my house(start marker) to a friends house(end marker) and want to go to a gas station on the way (which will also have markers on map). Is there any way to figure out what gas stations are at most 2 miles off the path from my house to my friends?


It would appear that there is no convenient way to do exactly what you're asking for, but you can approximate it with a little work. The easiest thing to do would be to find gas stations that are the closest to your start point and/or your end point and go with that.

If you want to work a bit harder but get a better result (possibly at the expense of significant latency, though), you can probably check for gas stations closest to the start_location/end_location of each step in the directions as returned by the Directions API. For long/complicated routes, though, that could be a lot of points. And you will miss gas stations close to the middle of a long leg in the route, so it's still just an approximation.

It may be possible to parse the polylines and do a whole bunch of queries on many, many points along the route. But even if that's possible, your performance would be awful and you might even trip some rate limiting or other query limitations that Google likely has in place to prevent abuse.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜