我正在尝试拍摄由谷歌地图上绘制的矩形包围的区域的快照.是否可以拍摄矩形下方区域的快照?我搜索了答案,但找不到任何有用的信息.
我试图通过指定地图中心,缩放级别,图像宽度和图像高度,使用静态地图API获取矩形区域的快照.如 https://maps.googleapis.com/maps/api/staticmap?center=CENTER OF THE RECTANGLE&zoom = ZOOM LEVEL of MAP&size = WIDTH AND HEIGHT OF THE RECTANGLE&maptype = satellite&key = API KEY
这是我试过的代码,
var zoom = map.zoom;
var centre = rectangle.getBounds().getCenter(); //rectangle is the shape drawn on the map
var spherical = google.maps.geometry.spherical;
bounds = rectangle.getBounds(); //rectangle is the shape drawn on the map
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); …Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-api-3 google-maps-static-api