在 Angular 2 应用程序中使用 esri javascript api 4.3。我最初使用以下代码生成地图:
ngOnInit() {
this.map = new Map({
basemap: 'streets',
});
this.map.layers.add(new FeatureLayer({
url: 'http://test/arcgis/rest/services/Project_map/MapServer/0',
id: '0',
visible: true,
outFields: ["*"],
popupTemplate: this.jobsTemplate
}));
this.view = new MapView({
container: "viewDiv",
map: this.map,
center: new Point({
x: -111.876,
y: 40.758,
}),
zoom: 12,
rotation: 0
});
}
单击地图上的某个要素时,我会弹出一个包含该要素值的弹出窗口。这很好用。
还有一个表格,地图上的每个要素都有一行。
当单击表格行时,我执行以下代码,并将该功能的 lat 和 long 传递给它:
zoomToPoint(zoomLong: number, zoomLat: number) {
this.view.center = new Point({ x: zoomLong, y: zoomLat });
this.view.zoom = 15;
this.view.popup.open({ location: this.view.center });
}
我在正确的位置得到一个弹出窗口。但是,弹出窗口是空的。
我希望它使用分配给要素图层并包含该位置的要素值的 popupTemplate。就像我单击该功能时会发生什么一样。