How can I find the nearest intersection via the Google Maps API?

岁酱吖の 提交于 2020-01-29 13:06:10

问题


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.


回答1:


[see comments 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 :(




回答2:


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.



来源:https://stackoverflow.com/questions/554638/how-can-i-find-the-nearest-intersection-via-the-google-maps-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!