Select to view content in your preferred language

How to load a Layer to inspect its REST properties with Javascript?

592
2
Jump to solution
03-29-2019 08:54 PM
RyanSutcliffe
Frequent Contributor

I would like to fetch an ArcGIS featurelayer and get information on its properties and capabilities but I have no interest in rendering it in a map or a table. Is there a trick to load the featurelayer without inserting it in a map and view? Unless I do that I cannot figure out how to get its loaded property to be true.

var featureLayer = new FeatureLayer({
	url: url
});

featureLayer.when(function () {
// fires when layer is loaded:
	console.log(featureLayer.capabilities);
	//... do something with capabilities here...
});


// Do I really need to load the map and view modules?
var map = new Map({
	basemap: "oceans",
	layers: featureLayer
});
var view = new MapView({
	map: map,
	container: "viewDiv"
});

// after above is complete, layer will be loaded but is there
// a better way to avoid loading all this extra stuff?

I'm currently doing a straight fetch to get the layer's JSON information and parsing it manually but obviously would like to use the ArcGIS Javascript API to reduce the work and lines of code.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   If all you want is the capabilities and you are not going to do anything with the layer then just use an esriRequest to get the Rest Service details. Here is a sample that shows that (no map used).

https://developers.arcgis.com/javascript/latest/sample-code/request/index.html

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   If all you want is the capabilities and you are not going to do anything with the layer then just use an esriRequest to get the Rest Service details. Here is a sample that shows that (no map used).

https://developers.arcgis.com/javascript/latest/sample-code/request/index.html

0 Kudos
RyanSutcliffe
Frequent Contributor

Makes sense. Looks the same as the native Fetch() method with the benefit that it works on IE. Thanks for your help.

0 Kudos