简体   繁体   English

如何通过Google Maps API找到最近的十字路口?

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

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. 例如,假设我有一条从南到北的街道A,北面是街道X,南边是街道Y.

Does the Google Maps API allow for finding coordinates of the nearest crossroad (either X or Y) of street A? Google Maps API是否允许查找街道A最近的十字路口(X或Y)的坐标? 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. PS:我所知道的唯一解决方案是猜测街道A上建筑物的最低数量和最高数量,并在它们之间绘制折线。 I am not sure about this though. 我不确定这一点。

[see comments above] [见上面的评论]

unfortunately, no. 抱歉不行。 even with gdirections, there is no way to locate the beginning and end of the street (coordinates). 即使有gdirections,也无法找到街道的起点和终点(坐标)。 I have solved it by using the hack proposed above: looping over building numbers from 1 to XXX. 我已经通过使用上面提出的黑客解决了它:循环建筑数字从1到XXX。

if accuracy is 6 for a while (8 = building number, 7=intersection, 6 = approximate address only) that means no new numbers exist. 如果精度为6暂时(8 =建筑物编号,7 =交叉点,6 =仅近似地址),则表示不存在新数字。 so i just take first point (lat/long), middle one and the last one (all with accuracy 8) and create path between them. 所以我只取第一个点(纬度/长度),中间值和最后一个点(全部精度为8)并在它们之间创建路径。 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. 您可以考虑使用USGS的TIGER数据。 You can get that information from there, but it's not as easy to play with as the Google data. 您可以从那里获取该信息,但它并不像Google数据那样容易使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM