AnsweredAssumed Answered

PopupTemplate's content method called only once per feature

Question asked by dgallant on May 17, 2018

I am using Esri maps inside an Angular app, and I am rendering my popups as Angular components with data published from the PopupTemplate's content method:

 

layer.popupTemplate = new PopupTemplate({
  content: (feature: { graphic: __esri.Graphic }) => {
    this.publishPopupData(layer, feature.graphic.attributes);
    return popupComponent.viewContainerRef.element.nativeElement;
  },
  // other properties...
});

 

This works well, except in the case where there are multiple features at a given point. When the user cycles through the features, if he/she returns to a feature that was already displayed, the content method does not execute, so the popup data is not published.

 

I can access the currently selected feature on the MapView's popup, but I need to know what layer the feature came from in order to publish the data properly (each layer has unique requirements for processing the ArcGIS data into the models used by the popups).

 

mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) => {
  const layer = ???;
  this.publishPopupData(layer, graphic.attributes);
});

 

Nominally, graphic.layer should contain the layer reference, but in my case it is always null.

 

Is there a way to force the popups to always call the content method, even if it was already executed for a given feature? Alternatively, is there a way to get the layer a feature belongs to from MapView.popup (or something else I have not considered)?

 

If it matters, the popups are for MapImageLayer sublayers.

Outcomes