I have a widget that adds a layer from the result of a gpservice. Users can re-run the gp tool for different dates. In doing so the layer is removed and then re-added (with same id) when the new gpresult is returned. The pop ups are acting strange when i do this. As you can see I have these "ghost" features that show the pop up for outlined in blue. The yellow feature in the middle is from the newest gpresult. I can't figure out why it is still requesting the pop up info from the first gpresult.
function gpJobComplete(jobinfo){
gp.getResultImageLayer(jobinfo.jobId, null, null, function(layer){
layer.setOpacity(0.7);
layer.title = "Hail History Swath";
layer.id = "Hail_History_Swath"
this.map.addLayers([layer]);
});
}
function gpJobStatus(jobinfo){
console.log(jobinfo);
}
function gpJobFailed(error){
console.warn(error);
}
function cleanup(){
var hailLayer = this.map.getLayer('Hail_History_Swath');
if(hailLayer){
this.map.removeLayer(hailLayer);
}
}
Brain,
are you replacing the layer when the popup is still open? If so that is an issue and you need to hide the map popup or set this.map.infoWindow.setFeatures([]);
I think you are on the right track but it is not just that I have a pop up open. Eseesntially if I have a pop up open or have had one open but now closed, I get the same issue. If I never open a pop up on that layer I do not see this issue.
did you try setting the popups feature to null or an empty array?
I tried both as well as closing out the pop up window. No luck.
function cleanup(){
//hide the legend and remove the existing hotspot layer
//domUtils.hide(dom.byId('legendDiv'));
var hailLayer = this.map.getLayer('Hail_History_Swath');
if(hailLayer){
map.infoWindow.clearFeatures();
hailLayer.infoTemplate = null;
hailLayer.infoTemplate = [];
this.map.removeLayer(hailLayer);
}
Couldn't get it to work so went a different route. Now just appending a date to the layer names each layer added will be unique.