首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fitBounds()不使用geocoder函数

fitBounds()不使用geocoder函数
EN

Stack Overflow用户
提问于 2013-09-21 08:47:02
回答 1查看 274关注 0票数 0

我刚刚将代码从v2更新到了v3。所有东西都在工作,但这里的函数map.fitBounds();是我的示例代码。

var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': 'your address'}, >function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var newPoint = new google.maps.LatLng(results[0].geometry.location.lat(), >results[0].geometry.location.lng()); markerBounds.extend(newPoint); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert('Geocode was not successful for the following reason: ' + status); } }); map.fitBounds(markerBounds); }

我发现这段代码看起来很好,但是这里的fitBounds()不能工作。下文的答复中提到了所需的改变。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-21 16:49:48

在这种情况下,我们必须编写这样的代码

markerBounds.extend(newPoint); map.fitBounds(markerBounds);//在功能上,而不是在最后

这对我很有帮助,希望对你也有帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18930703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档