【问题标题】:Google maps api locate corner coordinates谷歌地图 api 定位角坐标
【发布时间】:2016-07-22 20:17:07
【问题描述】:

问题:有没有一种方法可以让我在每次zooms inzooms outshift 地图时定位谷歌地图角点的坐标?

详细说明我的意思:

在我的谷歌地图 api 代码中,我为地图指定了特定的宽度和高度:

<style>
    #map {
        width:400px;
        height:300px;
    }
</style>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
<script>
    var mapOptions = {
        center: new google.maps.LatLng(37.7831, -122.4039),
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById('map'), mapOptions);
</script>

现在,当用户使用滚动查看地图中更远或更远的地方时,此宽度和高度显然保持不变,但地图上的坐标位于

top-left corner
top-right corner
bottom-left corner
bottom-right corner

随着用户移动地图而改变。我一直在试图找到一种方法来获取这些坐标,但我的尝试都失败了。

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 coordinates


    【解决方案1】:

    map.getBounds() 将返回一个 bounds 对象,其中包含地图的北、南、东和西边界(如 SouthWest、NorthEast)。

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 2011-07-16
      • 2013-04-06
      • 2014-10-28
      • 1970-01-01
      • 2015-02-05
      • 2012-10-18
      • 1970-01-01
      相关资源
      最近更新 更多