假设我有一个div
内的地图,宽度为x
且高度为y
且缩放级别为t。如何找到当前可见地图的面积,宽度和高度?
最佳答案
这是答案,
var spherical = google.maps.geometry.spherical,
bounds = map.getBounds(),
cor1 = bounds.getNorthEast(),
cor2 = bounds.getSouthWest(),
cor3 = new google.maps.LatLng(cor2.lat(), cor1.lng()),
cor4 = new google.maps.LatLng(cor1.lat(), cor2.lng()),
width = spherical.computeDistanceBetween(cor1,cor3),
height = spherical.computeDistanceBetween( cor1, cor4);