page_type | description | languages | products | ||||
---|---|---|---|---|---|---|---|
sample |
A module for the Azure Maps Web SDK that generates screenshots of the map. |
|
|
A module for the Azure Maps Web SDK that generates screenshots of the map.
Important
In order for this module to work, the maps preserveDrawingBuffer
must be set to true
when the map is initally loaded and can't be set afterwards.
Note that the screenshot is only of the rendered map canvas, other HTML elements, such as HTML markers and controls are not rendered on the image. Native rendering layers such as BubbleLayer, SymbolLayer, LineLayer, PolygonLayer, ImageLayer, and TileLayer are supported.
Samples
Download the project and copy the azure-maps-image-exporter
JavaScript file from the dist
folder into your project.
Usage
//Get map screenshot as an image element.
atlas.MapImageExporter.getImage(map).then(function(mapImg) {
//Do something with the image element, in this case append if to the document body.
document.body.appendChild(mapImg);
}, function (e) {
alert(e.message);
});
//Get map screenshot as a data URI.
atlas.MapImageExporter.getDataUri(map).then(function (dataUri) {
//Do something with the data URI. In this case its openning a new tab in the browser and loading it in an img tag.
var win = window.open();
win.document.write('<img src="' + dataUri + '"/>');
}, function (error) {
alert(error);
});
//Get a map screenshot as an image blob.
atlas.MapImageExporter.getBlob(map).then(function (mapImgBlob) {
//Do somethimg with the image blob.
}, function (e) {
alert(e.message);
});
Namespace: atlas
A static class for generating screenshots of the map.
Static Methods
Name | Return type | Description |
---|---|---|
getImage(map: atlas.Map) |
Promise<HTMLImageElement> |
Generates a Image object for an image of the map. |
getDataUri(map: atlas.Map, mimeType?: 'image/png' | 'image/jpeg') |
Promise<string> |
Generates a data URI for an image of the map. Mime type defaults to 'image/png' . |
getBlob(map: atlas.Map) |
Promise<Blob> |
Generates a Blob for an image of the map. |
- Azure Maps Web SDK Open modules - A collection of open source modules that extend the Azure Maps Web SDK.
- Azure Maps Web SDK Samples
- Azure Maps Gov Cloud Web SDK Samples
- Azure Maps & Azure Active Directory Samples
- List of open-source Azure Maps projects
We welcome contributions. Feel free to submit code samples, file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our Contribution Rules & Guidelines.
You can reach out to us anytime with questions and suggestions using our communities below:
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
MIT
See License for full license text.