简体   繁体   English

Google Maps v3 API地理编码和视口不一致

[英]Google Maps v3 APIs Geocoding and Places Inconsistent Viewport

I'm working on a Google Maps project where we want the customer to type in an Autocomplete address and then be taken to that place on the map. 我正在做一个Google Maps项目,我们希望客户输入自动完成地址,然后带到地图上的那个地方。

My manager wants a consistent "viewport" result when compared to the viewport achieved when searching for the same place on maps.google.com. 与在maps.google.com上搜索相同地点时获得的视口相比,我的经理希望获得一致的“视口”结果。

I found an inconsistent result for a certain location, in particular for the Australian city of Sydney. 我发现某个位置的结果不一致,尤其是在澳大利亚的悉尼市。

The result I get back from Places Autocomplete for Sydney looks quite zoomed in (I used the response's viewport data and call map.fitBounds(...). I'm a first time Stackoverflow user, so I can't post images yet - instead, the effect can be seen by entering 'Sydney, New South Wales, Australia' at the following page: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete 我从Places Autocomplete for Sydney回来的结果看起来非常放大(我使用了响应的视口数据,并调用map.fitBounds(...)。我是Stackoverflow的首次用户,所以我还不能发布图片-相反,可以在以下页面上输入“澳大利亚新南威尔士州悉尼”来查看效果: https//developers.google.com/maps/documentation/javascript/examples/places-autocomplete

Alternatively, if I use the Geocoding API instead and take the viewport data response and use that to call map.fitBounds(...), I get a zoomed out view, similar to what I would see when I look for Sydney on maps.googles.com. 另外,如果我改用Geocoding API,并获取视口数据响应并将其用于调用map.fitBounds(...),则会得到缩小视图,类似于在地图上寻找悉尼时所看到的视图。 googles.com。

I would be very grateful for any suggestions that would provide a solution that gives my customers a viewing result that is 100% consistent with maps.google.com. 对于提供解决方案,使客户的观看结果与maps.google.com保持100%一致的建议,我将不胜感激。 For example, should I be using a different version of the Autocomplete API, or pass a special parameter? 例如,我应该使用其他版本的Autocomplete API,还是传递一个特殊参数? Ideally I would prefer to not be calling the Geocoding to retrieve and override the Autocomplete viewport response, since that would double up my API traffic and double the hit on Google's servers. 理想情况下,我希望不要调用地理编码来检索和覆盖“自动完成”视口响应,因为那样会使我的API流量增加一倍,并使Google服务器上的点击率增加一倍。

I look forward to any advice anybody can offer, thank you!!! 我期待任何人都可以提供任何建议,谢谢!!!

Are you wanting the map zoom level to be consistent after the search ? 搜索后是否要使地图缩放级别保持一致? I do android with google map. 我用谷歌地图做安卓。 And just by looking at the code from the provided link above. 只需查看上面提供的链接中的代码即可。 change that map.setZoom() method to the level you want might help. 将map.setZoom()方法更改为所需的级别可能会有所帮助。

I haven't done javascript google map api yet. 我尚未完成javascript google map api。 Just taking a wide guess. 只是一个广泛的猜测。

If I am answering the wrong question, please correct me. 如果我回答错误的问题,请纠正我。

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

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