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

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

问题描述

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



北美地区协调中心:

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

我试过(+ 90,-180)( - 90,180)


解决方案

@Marcelo& amp; @Doc对于理解Lat Lng的派生来说很好:



但是,如果 需要最大范围的答案 Google地图:



纬度:-85至+85 其实-85.05115代表某些原因



经度:-180至+180



在Google地图上为自己尝试


$ b

  • https://maps.google.com/?q=85,180

  • https://maps.google.com/?q=-85.05115,180

  • ul>

    (您可能需要缩小。看看这个pin是如何处于世界的边缘的 - 这就是限制)

    所以在你的代码里 Try

      var strictBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(85 ,-180),//地图左上角
    new google.maps.LatLng(-85,180)//右下角
    );

    一旦你有了答案,请编辑这个wiki(或者更新你的问题)。谢谢


    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?

    Coordinates for North America:

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

    I've tried (+90, -180)(-90,180) to no luck.

    解决方案

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

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

    Latitude: -85 to +85 (actually -85.05115 for some reason)

    Longitude: -180 to +180

    Try it for yourself on the Google Maps:

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

    So in your code Try:

    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
    );
    

    Please edit this wiki (or update your question) once you have the answer. Thanks

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

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