How do I get the ID of a web map layer?

11546
8
Jump to solution
08-13-2015 06:54 AM
Highlighted
Occasional Contributor III

For various reasons it's useful to know the ID of a web map layer. So what's the easiest way to find it?

I've learned by debugging that the ID of one of my web map layers is "Development_2055". How would I find this without debugging?

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor III

Hi Jonathan, you can find the id's of the operationalLayers in the json of your webmap :

<portalurl>/sharing/rest/content/items/<webmapid>/data?f=json&token=

I'm not sure if I would call it an easy way to find them - but it is a way without writing code or debugging  🙂

View solution in original post

8 Replies
Highlighted
Occasional Contributor III

Hi Jonathan,

Edit:  Sorry Jonathan, I guess I failed the reading comprehension portion of geonet.  I thought you meant the map id, not a layer id.  My apologies. 

Two easy ways that I know about: When you save the map and then when you look at the details of the map.

After you save the map the link will change to show the id

webmapid2.JPG

And then when you look at the details of a map it is also in the browser link

webmapid.JPG

The id is the same just called a little different in the browser link.  Hope this helps.

Best,


Brandon

Highlighted
Occasional Contributor III

Hi Brandon,

I have the web map ID -- I'm looking for the ID of specific layer within the web map, so that I can do something like:

var layer = this.map.getLayer(<insert layer ID here>);

or, in order to configure the GeoForm template fields, something like:

fields:{
  <insert layer ID here>: [{
  "name": "email", // field ID
  "alias": "Email", // label
  "fieldDescription": "Let us contact you.", // help text
  "visible": true, // show this field?
  "typeField": false, // subtype field?
  "tooltip": "test@test.com", // placeholder text
  "displayType": "email" // text, checkbox, radio, textarea, url, email
  }]
}

Thanks,

Jon.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jonathan,

You could so something like below:

var map = this.map;

       

array.forEach(map.itemInfo.itemData.operationalLayers, function(layer){

    if(layer.title == 'Parcels'){

      layerID = layer.id;

    }

})

Reply
0 Kudos
Highlighted
Occasional Contributor III

Hi Jake,

Yes, that does work. I'm wondering if there's a way to do it a priori, as in the second case that I identified above?

Thanks,

Jon.

Reply
0 Kudos
Highlighted
New Contributor III

Hi Jonathan, you can find the id's of the operationalLayers in the json of your webmap :

<portalurl>/sharing/rest/content/items/<webmapid>/data?f=json&token=

I'm not sure if I would call it an easy way to find them - but it is a way without writing code or debugging  🙂

View solution in original post

Highlighted
Occasional Contributor III

Perfect. That's exactly what I was looking for. Thanks, Herdis.

Highlighted
Occasional Contributor II

Jonathan Bailey‌,

Esri has released the ArcGIS Online Assistant app that allows you to view the JSON of an object. 

Link: ArcGIS Online Assistant 

To view a webmap's JSON:

1.Login

2. Select the "I want to..." list in the top menu

3. Select "View an Item's JSON" from the list.

4. Select the map or item from the lists on the left of the page.

I had been using the method that  Herdis Gudbrandsdottir had posted for a while now and this method seems helpful as well. 

Thanks,

Chris 

Highlighted
New Contributor II

hi,

Take the following steps to get the id of all layers/services in a web map:

  •    First share the map as public and then use the following URL

                https://<your portal url>/sharing/rest/content/items/web map id/data/?f=pjson

  •    Set the share back to its original definition
Reply
0 Kudos