Popup conent disappears when StreamLayer graphic updates location

505
1
02-28-2018 03:16 PM
DanaConway
New Contributor II

When I click on a graphic in a StreamLayer to view the popup content, if the graphic's location updates while the popup is still open, the content disappears.   I've tried setting the "updateLocationEnabled" property to true in the popup, but that didn't help.

How can you keep the content from disappearing if the location updates while viewing the popup?

0 Kudos
1 Reply
DanaConway
New Contributor II

After hours of debugging, I was able to come up with a workaround for now.   What appears to be happening is that if the graphic's location updates, it's popupTemplate is being set to null.   So, the popupTemplate and content needs to be reset.   My workaround was to put a watch on the title property of the popup and when it went blank, reset the popupTemplate.  Code snippet below.   This is the 4.6 version of the API.

popup.watch(["visible", "selectedFeature", "title"], function (newValue, oldValue, propertyName, target) {

   if (propertyName !== null && propertyName !== undefined) {                    

      if( propertyName.toLowerCase() === "title" ){

         if( oldValue !== null && oldValue.length > 0 && newValue !== null && newValue.length === 0 ) {

               this.selectedFeature.popupTemplate = mapElements.getPopupTemplate();

               this.selectedFeature.popupTemplate.content = mapElements.setContentInfo;

         }

      }

   }

});

0 Kudos