Select to view content in your preferred language

Cant access the properties of a FeatureLayer

568
3
10-07-2010 10:28 PM
KristerVikström
Occasional Contributor
Hi!
I´m working with ArcGIS Server 10 and the JavaScript API v2.1 and I'm trying to access the properties (name, fields etc) of a featureLayer but it seems like I get no reference to the featureLayer. When I try to alert the name (... or other properties) i get "undefined". This is kind of what I´m doing in code (JavaScript)...

var featureLayer=new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/1", {mode: esri.layers.FeatureLayer.MODE_SELECTION});

alert(featureLayer.name);

Am I missing something... ??
0 Kudos
3 Replies
KristerVikström
Occasional Contributor
I have dived deeper into this issu and found out that I can get access to the information by using JSON (http request and eval function to get the object). Is this the proper way to access the properties or is it just a workaround??
0 Kudos
KellyHutchins
Esri Frequent Contributor
The feature layer properties aren't available until after the layer has loaded. Once the layer has loaded the properties should return values instead of undefined.
0 Kudos
KristerVikström
Occasional Contributor
Ok, then I missed something 😉
0 Kudos