开发者

taking a screenshot of some element in the html

开发者 https://www.devze.com 2023-04-08 23:15 出处:网络
So I was wondering, if I have a div which contains a maps of google maps rendered with some makers and I want to take a picture of that element how can I do this?.I found this solutions it\'s a approa

So I was wondering, if I have a div which contains a maps of google maps rendered with some makers and I want to take a picture of that element how can I do this?.I found this solutions it's a approach of what I need but the problem it's that sending a url doesn't help me, I need the开发者_如何学编程 specific Div with all the markers. For the server side i'm using C# and for the cliente, asp.net with jquery. Also the google maps apiV3 to handle the maps


Take a look at the Canvas2Image library by Nihilogic Labs:

http://www.nihilogic.dk/labs/canvas2image/

Here's an example of how to take a screenshot of an element through JavaScript:

var oCanvas = document.getElementById("thecanvas");    
Canvas2Image.saveAsPNG(oCanvas);

EDIT

You might also take a look at Html2Canvas and FlashCanvas too. I believe one of them has support for earlier browsers (those which don't support HTML5).


Use the method in the link you mentioned and crop the resulting image to the dimensions of your div. You can use myDiv.getBoundingClientRect() in JavaScript to get the dimensions of your div.

Using the WebBrowser control, you can manipulate the document using html or JavaScript to get the page in the state you need to take your screenshot.


Have you considered using the Google Maps Static API - this will render a map image, with markers on it, as a PNG.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号