AnsweredAssumed Answered

Developing webappbuilder widgets

Question asked by DamienRobinson on Jul 24, 2014
Latest reply on Jul 29, 2014 by DamienRobinson

I'm developing a simple map service widget that will add and remove a dynamic map service layer. A much cut down version of the mapservices widget in Flex. However the service doesn't seem to be adding (hence I can't test the remove layer functionality either!).

 

 

I'm still using the initial beta as i'm suffering from the organisation login bug in the latest version.

 

 

I'm utilising the following button click event within a div in the widget.html:

 

 

data-dojo-attach-event="click:addMapService"

 

 

This is calling the addMapService function in the widget.js file:

 

 

  addMapService: function(){


     this.map.addLayer(dynamicMapServiceLayer);
  alert("Map Service Added");


    },

 

The dynamicMapServiceLayer variable is populated (prior to "return declare([BaseWidget]") as follows in the widget.js file:

 

 

  var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://webservices.spatialni.gov.uk/arcgis/rest/services/NIHE/NIHEAreas/MapServer",{
   "opacity" : 1
   });

 

When i debug the addMapService function, it seems to be adding the dynamicMapServiceLayer and the alert/pop up appears ok. When I check the layerslist widget the layer isn't present though.

 

 

I'm assuming the layerlist widget is only compiled and populated when clicked, therefore I shouldn't need to refresh this if i click it after adding the map service. Am I naive in expecting the map service widget to add a layer on the click of a button without any further event?

 

 

Has anyone else had any issues developing widgets thus far?

Outcomes