SHarihar-esristaff

Unable to fetch the Layer Names

Discussion created by SHarihar-esristaff Employee on Nov 6, 2012
I am trying to obtain the names of the individual layers in the MapService that I have hosted and populate it in the dijit.form.select. Now I have the mapservice url but is there some way I can obtain the layer names from them?

What I am trying to say is, I have one dijit.form.select which has the MXD names that I have provided in the list form,

<select name="Mxds" data-dojo-type="dijit.form.Select" id="ddMxd" data-dojo-props="onChange:function(){populateLayers(this.get('value'));}">
    <option value=0>Soil</option>
    <option value=1 selected="selected">Human Intervention</option>
    <option value=2>Climate</option>
  </select>


And On select change, I populate the other dijit.form.select like this,

var opts = [];
  for (var i = 0; i<ddArray[val].length; i++) {
   opts.push({label: ddArray[val][i].substring(54,ddArray[val][i].length-12), value: ddArray[val][i]});
  }
ddLyr = new dijit.form.Select({
   name: "selectLyr",
   options: opts
  }, dojo.byId('lyrs'));
  ddLyr.startup();
  dojo.connect(ddLyr, 'onChange', addLayer);
  }


Any Idea how I can achieve this? ddArray is an array which holds all the urls,

Outcomes