【问题标题】:Finding the lat-long of the corners in a Google Maps window在 Google 地图窗口中查找角的经纬度
【发布时间】:2010-11-08 04:21:55
【问题描述】:

使用Google Maps API,如何获取地图显示区域各个角落的经纬度?

也就是说,如果我的地图是 300px 宽和 400px 高,我怎样才能找到 (0,0) 和 (300,400) 处的点的经纬度?

【问题讨论】:

    标签: google-maps mapping maps


    【解决方案1】:

    使用getBounds()。来自文档:

    以地理坐标返回地图视图的可见矩形区域。

    该函数准确返回您想要的:地图的西南角和东北角。第一对坐标是左下角(西南)坐标,第二对是右上角(东北)坐标。

    【讨论】:

    • (0,0) 可能是西北角,在这种情况下,Matt 需要第二个坐标的纬度,但需要第一个坐标的经度。
    • 好点,但我想既然我们谈论的是地图而不是通用屏幕,原点应该是左下角,而不是左上角。无论哪种方式,getBounds() 都会返回 Matt 想要的信息。这只是一个解析它的问题......
    • map.getBounds().getSouthWest().lng() = 西界。 map.getBounds().getNorthEast().lat() = 北界等
    【解决方案2】:

    在 Android(Kotlin) 中你可以试试这个,

    val curentScreen: LatLngBounds =  mapview.getProjection().getVisibleRegion().latLngBounds
    
    var northeast=curentScreen.northeast
    var southwest=curentScreen.southwest
    var center=curentScreen.center
    Log.v("northeast LatLng","-:"+northeast)
    Log.v("southwest LatLng","-:"+southwest)
    Log.v("center LatLng","-:"+center)
    

    【讨论】:

      猜你喜欢
      • 2017-01-18
      • 1970-01-01
      • 2021-07-18
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多