如何使用 JavaScript 或 jQuery 截取 Google 地图的屏幕截图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17877494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 09:56:51  来源:igfitidea点击:

How to take screenshot of a Google map using JavaScript or jQuery?

javascriptjqueryhtmlcanvashtml2canvas

提问by Jayeshkumar Sojitra

I want to take a 'screenshot' of a google map in my html file using JavaScript.

我想使用 JavaScript 在我的 html 文件中对谷歌地图进行“屏幕截图”。

The map is currently loading in divtags, so I am not able to get image using this <div>tag.

该地图当前正在加载div标签,因此我无法使用此<div>标签获取图像。

But if I can load it in canvas <canvas>then I can take a screenshot of it very easily, can anybody tell me solution for this problem - that is, how can I load a google map in canvas.

但是如果我可以在画布中加载它,<canvas>那么我可以很容易地截取它的屏幕截图,谁能告诉我这个问题的解决方案 - 也就是说,我如何在画布中加载谷歌地图。

Or is there any alternative solution for this?

或者是否有任何替代解决方案?

回答by Dziad Borowy

Why not just use google maps image api?

为什么不直接使用 google maps image api呢?