我们正面临着从谷歌 Map API获取拉特和长期的问题 . 实际上,我们正在使用google map api从地址获取lat和long .
但在某些情况下,谷歌 Map api没有给出准确的纬度和长度,但如果我们直接将地址搜索到谷歌 Map ,如下面提到的谷歌 Map URL,则获得准确的纬度和长度 .
谷歌 Map 网址:https://www.google.com/maps/place/mc carter hwy&verona ave newark nj
Google Map API网址:https://maps.googleapis.com/maps/api/geocode/xml?address=mc carter hwy&verona ave newark nj
请为此建议替代解决方案 . 如果我们可以用谷歌 Map api解决那么它是好的 .
2 回答
URL中不允许
&
. 请改用"and":link
收益:
看看encodeURI() .
空间和符号(特别是
&
)可能会干扰您为API提供的URL .编辑:更具体一点,请注意整个链接不是超链接,并且它在空格后停止:
https://maps.googleapis.com/maps/api/geocode/xml?address=mc carter hwy&verona ave newark nj
现在这里是您的查询编码相同的字符串:
https://maps.googleapis.com/maps/api/geocode/xml?address=mc%20carter%20hwy%20%26%20verona%20ave%20newark%20nj