I have been search for a way to override the popup template on a KMLLayer in the ESRI v4 api for a while with no luck. I am trying to avoid a rewrite of some functionality as we did not know all the constraints on KMLLayers. We would like to preserve style but not showing the extended data or having a way to add actions to the popup is kinda a deal Breaker
Any sample code or knowledge on whether this is possible would be be appreciated.
Hi there,
The first approach won't work. KMLLayer has sublayers and we don't know about the sublayers. So we can't define popupTemplate on the layer directly.
The second approach should work. You can disable the popupEnabled on the MapView.
However, you can set the popupTemplate by accessing the graphics which can be accessed via allVisiblePoints, allVisiblePolylines or allVisiblePolygons. The document is wrong these properties return collection of graphics not geometries. We will get the document correct. You can watch the changes on these collections and change the popupTemplate on the graphics.
Here is a simple codepen that shows the worflow: https://codepen.io/U_B_U/pen/rNQqgxR?editors=0010
Thanks allVisiblePoints, allVisiblePolylines or allVisiblePolygons works thanks for the quick response