Thanks in advance
Anupam,
These are different ways of accessing data on a feature service. PortalID is used when loading the layer via the portalitem property.
<SPAN class="comment token">// loads the third layer in the given Portal Item</SPAN> <SPAN class="keyword token">const</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> portalItem<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"8d26f04f31f642b6828b7023b84c2188"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> layerId<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">2</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The url method pointing the service and not the layer directly in the Feature Service.
<SPAN class="comment token">// Can also be used if URL points to service and not layer</SPAN> <SPAN class="keyword token">const</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// Notice that the url doesn't end with /2</SPAN> url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer"</SPAN><SPAN class="punctuation token">,</SPAN> layerId<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">2</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Additional information is available at FeatureLayer | ArcGIS API for JavaScript 4.12
The ID information can be viewed in the objects Jason using the ArcGIS Online Assistant as posted by Christopher Schreiber in the post How do I get the ID of a web map layer?
To view a webmap's JSON:1.Login2. Select the "I want to..." list in the top menu3. Select "View an Item's JSON" from the list.4. Select the map or Item from the lists on the left of the page.
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.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.