Dynamic Map Service Popup not working after updating url

403
8
08-16-2018 02:06 PM
Ran_Deng
New Contributor

Hi, 

I have a dynamic map layer but for some reason once the widget update the variable "year_opSelect" which changes the url to a different map service, the popup stopped working. does anyone know why and how to fix it? Thanks so much!!

takeoutLayerFromMap: function (layer) {
   this.inherited(arguments);
   var layerToRemove = this.map.getLayer(layer);
   this.map.removeLayer(layerToRemove);
},

 

if (this.map.getLayer("hDynamicLayer") !== undefined) {
   this.takeoutLayerFromMap("hDynamicLayer");
};

var hYearUrlD = "https://randomtestsite.org:6443/arcgis/rest/services/appLayers/Application_" + year_opSelect + "/MapServer"

var hDynTemplate= {};
      hDynTemplate[0] = { infoTemplate: templateX };

var hDynamicLayer = new ArcGISDynamicMapServiceLayer(hYearUrlD, {id: "hDynamicLayer", minScale: hDetailMinVal,       imageformat: "png32", name: "h Application Details"});
      hDynamicLayer.setVisibleLayers([dSelect]);
      hDynamicLayer.setInfoTemplates(hDynTemplate);

var hLayerDefinitions = [];
      hLayerDefinitions[dSelect] = hYear_ID;

var hlayerDrawingOptions = [];
var layerDrawingOption = new LayerDrawingOptions();
      layerDrawingOption.renderer = hRenderer;
      hlayerDrawingOptions[dSelect] = layerDrawingOption;
      hDynamicLayer.setLayerDrawingOptions(hlayerDrawingOptions);
      hDynamicLayer.setLayerDefinitions(hLayerDefinitions);

this.map.addLayer(hDynamicLayer);

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Ran, are you removing the previous layer that had the same ID?..

0 Kudos
Ran_Deng
New Contributor

Hi Robert, 

Yes, I have a function that takes out the layer at the beginning. but strangely the layer get added without any issue, just the pop up not won't show. but as soon as i switch back to the initial url. it works right the way. any idea? Thanks!! 

takeoutLayerFromMap: function (layer) {
   this.inherited(arguments);
   var layerToRemove = this.map.getLayer(layer);
   this.map.removeLayer(layerToRemove);
},

if (this.map.getLayer("hDynamicLayer") !== undefined) {
   this.removeLayerFromMap("hDynamicLayer");
};

Thanks,

Ryan

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Ryan,

   Is it just a misspelling or why do you have 

this.removeLayerFromMap("hDynamicLayer"); and your function is called takeoutLayerFromMap?

0 Kudos
Ran_Deng
New Contributor

Hi Robert, 

good catch, it's the same function. I copied and pasted but didn't copy the remove part and type in the wrong name. 

Thanks,

Ryan

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Ryan,

   So do each of your layers you are using have the same schema (meaning the same field names)? On each of the map services is it always going to be layer 1 that gets that infotemplate?

0 Kudos
Ran_Deng
New Contributor

Robert,

yes, they do, same fields and it's always layer 0. 

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Ryan,

  Hmm. I don't see the issue. The field names have no variation at all right (cAsE of the names or anything)?

0 Kudos
Ran_Deng
New Contributor

Robert, 

yes, that's what strange to me. the layer services have identical field names. (all lower case) 

0 Kudos