使用 Google Maps API,显示以 {minLat, min Long} 和 {maxLat, maxLong} 为界的地图

发布于 2024-12-12 05:57:41 字数 120 浏览 2 评论 0原文

Google 地图 API 需要 3 个参数来启动:纬度、经度和缩放级别。我想要的是根据最小纬度、最小长度、最大纬度和最大长度确定最接近的缩放级别,以便我的地图可以以正确的比例显示,不多也不少。有什么简单的方法可以做到这一点?

Google Maps APIs require 3 parameters to start with: lat, long and zoom level. What I want is to determine the closest zoom level based on the min lat, min long, max lat, and max long, so that my map can be displayed at the right scale, no more and no less. What's an easy way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩套路吗 2024-12-19 05:57:41

使用边界来适合您的地图。

bounds = new google.maps.LatLngBounds();
bounds.extend(minLatLng);
bounds.extend(maxLatLng);
map.fitBounds(bounds);

Use bounds to fit your map.

bounds = new google.maps.LatLngBounds();
bounds.extend(minLatLng);
bounds.extend(maxLatLng);
map.fitBounds(bounds);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文