How to get a screenshot of the Esri map at its current state on the UI and make it as downloaded as Pdf from Angular? The following code is my current .ts code and please let me know if there are additional parts to be added.
esri-map.component.html
<!-- Map Div -->
<div #mapViewNode></div>
esri-map.component.ts
// Initialize MapView and return an instance of MapView
initializeMap(esriToken) {
const container = this.mapViewEl.nativeElement;
config.apiKey = esriToken;
const horizonData: any[] = this.esiriData || [];
//load the webMap
const webmap = new WebMap({
portalItem: {
id: this.webMapId
}
});
// load the ParcelAtlas feature layer
const layer = new FeatureLayer({
url: this.featureLayerUrl,
});
webmap.add(layer);
const view = new MapView({
container,
map: webmap,
zoom: 4,
center: [-97.63, 38.34],
});
//legend Icon
const legend = new Legend ({
view: view
});
const legendExpand = new Expand(
{
view,
content: legend,
expanded: false,
})
view.ui.add(legendExpand, "top-left");
const renderer = new SimpleRenderer({
symbol: new TextSymbol({
color: "red",
text: "\ue61d",
font: {
size: 30,
family: "CalciteWebCoreIcons"
}
})
});
const dataFeedLayer = new FeatureLayer({
source: horizonData.map((d,i)=>(
{
geometry: new Point({
longitude: d.longitude,
latitude: d.latitude
}),
attributes: {
ObjectID: i,
...d
}
}
)),
objectIdField: 'ObjectID',
geometryType: "point",
renderer: renderer,
});
webmap.add(dataFeedLayer);
let options = {
width: 2048,
height: 2048
};
view.takeScreenshot(options).then(function(screenshot) {
let imageElement = document.getElementById("screenshotImage");
imageElement.src = screenshot.dataUrl;
});
this.view = view;
return this.view.when();
}
error: Property 'src' does not exist on type 'HTMLElement'.ts(2339)