我在 Angular 应用程序中使用 Esri 地图,并将弹出窗口呈现为 Angular 组件,其中包含从PopupTemplate
'scontent
方法发布的数据:
layer.popupTemplate = new PopupTemplate({
content: (feature: { graphic: __esri.Graphic }) => {
this.publishPopupData(layer, feature.graphic.attributes);
return popupComponent.viewContainerRef.element.nativeElement;
},
// other properties...
});
这很好用,除非在给定点有多个特征的情况。当用户循环浏览特征时,如果他/她返回到已经显示的特征,则不会执行内容方法,因此不会发布弹出数据。
我可以在弹出窗口中访问当前选择的要素MapView
,但我需要知道要素来自哪个图层才能正确发布数据(每个图层对于将 ArcGIS 数据处理到弹出窗口使用的模型中都有独特的要求) .
mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) => {
const layer = ???;
this.publishPopupData(layer, graphic.attributes);
});
名义上,graphic.layer
应该包含图层参考,但在我的情况下,它总是null
.
有没有办法强制弹出窗口始终调用 content 方法,即使它已经为给定的功能执行过?或者,有没有办法从MapView.popup
(或我没有考虑过的其他东西)获取功能所属的图层?
如果重要,弹出窗口用于MapImageLayer
子层。