0

I'm new to arcgis javscript api, and trying to get layers from a group layer. I'm not sure how to get this done. any help?

3

You can use esri.request to retrieve information about a service.
For example:
http://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_1990-2000_Population_Change/MapServer?f=pjson
the response is (an extract):
.
.
"copyrightText": "Copyright:© 2013 ESRI",
"supportsDynamicLayers": false,
"layers": [
{
"id": 0,
"name": "USA 1990-2000 Population Change",
"parentLayerId": -1,
"defaultVisibility": true,
"subLayerIds": [
1,
2,
3,
4
],
"minScale": 0,
"maxScale": 0
},
{
"id": 1,
"name": "Block Groups",
"parentLayerId": 0,
"defaultVisibility": true,
"subLayerIds": null,
"minScale": 150000,
"maxScale": 0
},
{
"id": 2,
"name": "Tracts",
"parentLayerId": 0,
"defaultVisibility": true,
"subLayerIds": null,
"minScale": 750000,
"maxScale": 150001
},
{
"id": 3,
"name": "Counties",
"parentLayerId": 0,
"defaultVisibility": true,
"subLayerIds": null,
"minScale": 25000000,
"maxScale": 750001
},
{
"id": 4,
"name": "States",
"parentLayerId": 0,
"defaultVisibility": true,
"subLayerIds": null,
"minScale": 0,
"maxScale": 25000001
}
]
.
.

the first layer (id: 0) is a grouplayer with subLayerIds 1,2,3,4
The other layers (with id 1,2,3,4) have parentLayerId: 0 (the grouplayer).

  • Thanks for your reply, about the service url, should I build it? I mean.. I have a map url which contains the group layers and its children. Is the service something I got from the map url or is it something totally different. – Omar Taha Nov 5 '14 at 10:09
  • I found it, but when I try to do an esri.request, it gives me this message :NS_ERROR_DOM_BAD_URI: Access to restricted URI denied. What's the problem – Omar Taha Nov 5 '14 at 10:31
  • You can post the url? – lele3p Nov 5 '14 at 12:07
  • The url is local, and Thanks, it is working now. I don't know what was the problem, I keep making changes until it works. – Omar Taha Nov 5 '14 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.