世界的最大纬度和经度边界 - Google Maps API LatLngBounds() [英] Maximum Lat and Long bounds for the world - Google Maps API LatLngBounds()

查看:22
本文介绍了世界的最大纬度和经度边界 - Google Maps API LatLngBounds()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Google 地图地形视图可以无限制地平移地图图块.您可以使用 LatLngBounds() 来限制这一点,但是我应该使用什么最大和最小坐标将视口设置为地球而不是地图区域之外?

The Google Maps terrain view by default has unlimited panning of the map tile. You can use LatLngBounds() to limit this, but what are the maximum and minimum coordinates I should use to set the viewport as just the earth and not outside the map region?

北美坐标:

var strictBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(28.70, -127.50), 
    new google.maps.LatLng(48.85, -55.90)
);

我试过 (+90, -180)(-90,180) 不走运.

推荐答案

@Marcelo & 提供的链接@Doc good 有助于理解 Lat Lng 的推导:

The links provided by @Marcelo & @Doc are good for understanding the derivation of the Lat Lng:

但是如果您只是想要Google Maps最大边界的答案:

But if you just want an answer for the maximum bounds for Google Maps:

纬度:-85 到 +85(由于某种原因实际上是 -85.05115)

经度:-180 到 +180

在 Google 地图上亲自尝试:

(您可能需要缩小.看看图钉如何位于世界的边缘"——这些是限制)

(You may need to Zoom Out. See how the pin is at the "edge" of the world - these are the limits)

所以在你的代码中尝试:

var strictBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(85, -180),           // top left corner of map
    new google.maps.LatLng(-85, 180)            // bottom right corner
);

获得答案后,​​请编辑此维基(或更新您的问题).谢谢

这篇关于世界的最大纬度和经度边界 - Google Maps API LatLngBounds()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆