我正在Angular应用程序中使用Esri地图,将我的弹出窗口呈现为使用PopupTemplate
的content
方法发布数据的Angular组件:
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
。
是否有一种方法可以强制弹出窗口总是调用内容方法,即使它已经针对给定要素执行过?或者,是否有一种方法可以从MapView.popup
(或其他我未考虑的内容)中获取要素所属的图层?
如果有关系,这些弹出窗口是为MapImageLayer
子图层准备的。