What Is the REST URL to Get the Layers of a Web Map?

5993
4
Jump to solution
07-15-2014 02:47 PM
JacobAychman
New Contributor

I've been combing the ArcGIS REST API Resource Index for a few days now, and I still can't seem to figure out how or where I would query the available layers for a webmap, given the map id, name, or any other resource to identify it. I did find a page (Dynamically create layer list | ArcGIS API for JavaScript) detailing how to make a document able to select layers for a "stock map," and while I would eventually like to be able to select visible layers when exporting a webmap, at present I just need the REST URL for listing the layers.

 

Thanks in advance for any assistance.

0 Kudos
1 Solution

Accepted Solutions
AlexanderNohe1
Occasional Contributor III

Hi Jacob Aychman‌,

I spoke too soon.

You can use the following REST URL:

http://<ORG_SHORTURL>.maps.arcgis.com/sharing/rest/content/items/<WEBMAP_ID>/data?f=pjson&token=<TOKEN>‌

This will have a json output which you can then parse for the operational layers and their definitions.

An example of this output can be found attached.

View solution in original post

4 Replies
AlexanderNohe1
Occasional Contributor III

Hi Jacob Aychman‌,

I am not sure if this functionality you are looking for exists.  By taking a look at the ArcGIS REST API, I see no indication that webmaps have their own REST endpoint.  One method that would work at gathering the layers for a webmap would be to use the buildlayerlist function found in the link that you provided.  On the other hand, if you are looking at a servers REST Endpoint for a MapServer item, you can parse the JSON for the MapServer item.

<SERVER_URL>/MapServer/layers?f=pjson‌

Does this help?

AlexanderNohe1
Occasional Contributor III

Hi Jacob Aychman‌,

I spoke too soon.

You can use the following REST URL:

http://<ORG_SHORTURL>.maps.arcgis.com/sharing/rest/content/items/<WEBMAP_ID>/data?f=pjson&token=<TOKEN>‌

This will have a json output which you can then parse for the operational layers and their definitions.

An example of this output can be found attached.

JacobAychman
New Contributor

Thanks, Alexander Nohe‌!

I'll give this a shot. Do you know if there's any way to obtain the Webmap ID via REST? Thus far, I've just been copying it out of the map viewer's URL.

0 Kudos
AlexanderNohe1
Occasional Contributor III

Jacob Aychman‌,

You would want to do something like this on a per user basis:

http://<ORG_SHORT_URL>.maps.arcgis.com/sharing/rest/content/users/<USERNAME>?f=pjson&token=‌<TOKEN>

I hope this helps!