【发布时间】:2022-01-14 12:50:19
【问题描述】:
我已在我的 Angular 应用程序中集成了 Esri 地图。在应用程序中有一个下载按钮,用户单击该下载按钮,Esri 地图的屏幕截图应隐式获取,该屏幕截图应将其下载为 pdf。
您能帮我解决这个问题吗?
arcgis-js-api 版本 4.2.1 角度版本 11。
.ts 文件
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 feature layer
const layer = new FeatureLayer({
url: this.featureLayerUrl,
});
webmap.add(layer);
const view = new MapView({
container,
map: webmap,
});
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();
}
.html 文件
<kendo-pdf-export #pdf paperSize="A4" margin="1cm" [scale]="scale">
<!-- Map Div -->
<div #mapViewNode></div>
<div class="float-right">
<div class="downloa-ico pr-1 float-left" (click)="pdf.saveAs('sample.pdf')"></div>
</div>
</kendo-pdf-export>
【问题讨论】:
-
嗨@KalanaTebel,看看这个问题/答案,这是一个类似的问题how-to-get-a-screenshot-of-the-esri-map-angular,如果它解决了你的问题或者是其他问题,请告诉我
-
嗨@cabesuon。是的,直到我已经完成的那个级别。我关心的是如何在没有用户手动截取屏幕截图然后将其保存为 pdf 的情况下隐式截取该屏幕截图。不是png或jpg。谢谢
标签: angular pdf screenshot arcgis-js-api