admin管理员组文章数量:1325228
How can I find the closest intersection of the street I have coordinates of?
For instance, say I have street A running from south to north that is crossed by street X on the north and by street Y on the south.
Does the Google Maps API allow for finding coordinates of the nearest crossroad (either X or Y) of street A? I couldn't find it mentioned anywhere.
PS: The only solution I am aware of is to guess the lowest number and the highest number of building on the street A and to draw polyline between them. I am not sure about this though.
How can I find the closest intersection of the street I have coordinates of?
For instance, say I have street A running from south to north that is crossed by street X on the north and by street Y on the south.
Does the Google Maps API allow for finding coordinates of the nearest crossroad (either X or Y) of street A? I couldn't find it mentioned anywhere.
PS: The only solution I am aware of is to guess the lowest number and the highest number of building on the street A and to draw polyline between them. I am not sure about this though.
Share Improve this question edited Feb 27, 2009 at 23:00 GEOCHET 21.3k15 gold badges77 silver badges99 bronze badges asked Feb 16, 2009 at 21:29 dusoftdusoft 11.5k5 gold badges40 silver badges44 bronze badges 4- I wonder if you could hack GDirections to do this? – dotjoe Commented Feb 16, 2009 at 21:59
- I am not sure, I ill have to dive in GDirections API to find out, but I have searched for the answer (both google and google maps support groups) and nobody really seem to know, if this is possible. – dusoft Commented Feb 17, 2009 at 11:42
- I was thinking you could get the walking directions to two points so that it would force you to turn on the first crossroad. But, i doubt this would be reliable. Is there a google maps search operator like "nearest intersection" or something? – dotjoe Commented Feb 17, 2009 at 16:27
- no, there is not. it would help if there was a function to provide an array of coordinates of the nearest intersections. – dusoft Commented Feb 19, 2009 at 15:56
2 Answers
Reset to default 1[see ments above]
unfortunately, no. even with gdirections, there is no way to locate the beginning and end of the street (coordinates). I have solved it by using the hack proposed above: looping over building numbers from 1 to XXX.
if accuracy is 6 for a while (8 = building number, 7=intersection, 6 = approximate address only) that means no new numbers exist. so i just take first point (lat/long), middle one and the last one (all with accuracy 8) and create path between them. this however sometimes only provides only a part of the street as other parts are either without any buildings or google does not have further data :(
You might consider using the TIGER data from the USGS. You can get that information from there, but it's not as easy to play with as the Google data.
本文标签: javascriptHow can I find the nearest intersection via the Google Maps APIStack Overflow
版权声明:本文标题:javascript - How can I find the nearest intersection via the Google Maps API? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742171841a2426856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论