Count layer in hosted feature service

788
2
Jump to solution
08-10-2016 11:27 AM
KarstenRank
Occasional Contributor III

Hi there,

is it possible to get the number of feature layer of a hosted featue service with javascript api?

Thanks for your help!

Cheers,

Karsten

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Karsten,

  you could use esriRequest to get the layers array from the result.

require([

  "esri/request"

], function(esriRequest) {

  var layerUrl = "http://yourserver/arcgis/rest/services/yourservice/FeatureServer";

  var layersRequest = esriRequest({

    url: layerUrl,

    content: { f: "json" },

    handleAs: "json",

    callbackParamName: "callback"

  });

  layersRequest.then(

    function(response) {

      console.log("Success: ", response.layers);

  }, function(error) {

      console.log("Error: ", error.message);

  });

});

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Karsten,

  you could use esriRequest to get the layers array from the result.

require([

  "esri/request"

], function(esriRequest) {

  var layerUrl = "http://yourserver/arcgis/rest/services/yourservice/FeatureServer";

  var layersRequest = esriRequest({

    url: layerUrl,

    content: { f: "json" },

    handleAs: "json",

    callbackParamName: "callback"

  });

  layersRequest.then(

    function(response) {

      console.log("Success: ", response.layers);

  }, function(error) {

      console.log("Error: ", error.message);

  });

});

View solution in original post

0 Kudos
KarstenRank
Occasional Contributor III

Hi Robert,

this is what I searched.

Thank you very much.

0 Kudos