将当前的谷歌地图保存为图像 [英] Save current Google Map as image
问题描述
如何将当前的谷歌地图保存为图片?下面是我用来初始化地图的 Javascript.
How can I save the current google map as an image? Below is the Javascript I use to initialize the map.
var myMarker = new google.maps.LatLng(result[0].centerLat, result[0].centerLong);
var myOptions = {
disableDoubleClickZoom: true,
zoom: result[0].zoom,
center: myMarker,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
我查看了 https://developers.google.com/maps/documentation/javascript/reference#Map 但似乎没有方法可以返回当前地图对象的 URL 或图像.是否可以通过某种方式将地图另存为图像?
I had a look at https://developers.google.com/maps/documentation/javascript/reference#Map but there seems to be no method that returns a URL or image for the current map object. Is it possible to save the map as an image in some way?
推荐答案
您可以使用谷歌地图静态 API :https://developers.google.com/maps/documentation/staticmaps/
You can use the google maps static API : https://developers.google.com/maps/documentation/staticmaps/
您可以从谷歌地图 javascript api 获取需要传递给静态地图 api(例如 center 、可见区域等)的参数.
You can get the parameters that you need to pass to the static maps api (e.g. center , visible region etc) from the google maps javascript api.
这篇关于将当前的谷歌地图保存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!