esri.request doubt for legend creation

699
2
Jump to solution
04-09-2014 06:44 AM
VikramS
Occasional Contributor
Hello all,

I am creating legend dynamically using below code . maplayers_config contains list of url's for the map service . In the response how do I know for which map service I am getting the response . Can anybody help me with this . Thanks

for (var mapcount = 0; mapcount <= maplayers_config.length - 1; mapcount++) {
   /*var url = maplayers_config[mapcount].url + '/legend';*/
   var url = 'http://utility.arcgis.com/sharing/tools/legend';
        url = url + '?soapUrl=' + escape(maplayers_config[mapcount].url);
      var handle = esriRequest({
        url: url,
   content: { f: "json" },
        callbackParamName: 'callback'
      });
  
 
     handle.then(
  function(response,io) {
    console.log("Success: ", response);
console.log("Success: ", io);
a_test = response;
  },
function(error) {
    console.log("Error: ", error);
  });
  }
   });
0 Kudos
1 Solution

Accepted Solutions
ScottGunn
New Contributor III
Within your handle.then you should have access to the URL used in the request object:
Try this within your handle.then callback:
 handle.then(   function(response,io) {       console.log(handle.ioArgs.url);       .....

So, handle.ioArgs.url should give you the URL for the service.  You could then write some code to compare the URL string with your config file, pulling out a layer name or whatever else you need...

Hello all,

I am creating legend dynamically using below code . maplayers_config contains list of url's for the map service . In the response how do I know for which map service I am getting the response . Can anybody help me with this . Thanks
  handle.then(
  function(response,io) {
    console.log("Success: ", response);
console.log("Success: ", io);
a_test = response;
  },
function(error) {
    console.log("Error: ", error);
  });
  }
   });

View solution in original post

0 Kudos
2 Replies
ScottGunn
New Contributor III
Within your handle.then you should have access to the URL used in the request object:
Try this within your handle.then callback:
 handle.then(   function(response,io) {       console.log(handle.ioArgs.url);       .....

So, handle.ioArgs.url should give you the URL for the service.  You could then write some code to compare the URL string with your config file, pulling out a layer name or whatever else you need...

Hello all,

I am creating legend dynamically using below code . maplayers_config contains list of url's for the map service . In the response how do I know for which map service I am getting the response . Can anybody help me with this . Thanks
  handle.then(
  function(response,io) {
    console.log("Success: ", response);
console.log("Success: ", io);
a_test = response;
  },
function(error) {
    console.log("Error: ", error);
  });
  }
   });
0 Kudos
VikramS
Occasional Contributor
Thanks Scott . That solved the problem .
0 Kudos