How to merge ArcGIS feature layers and display as one layer on client side

1478
16
10-16-2019 10:51 AM
HanlunSong
New Contributor II

I am working on a project that utilizes ArcGIS JS API to display maps using the approach of Portal Item layers. (https://developers.arcgis.com/javascript/latest/sample-code/layers-portal/index.html) Now we have a request to merge these layers (either on the client side or some other approaches) and display as one layer. And so far I haven't found a way to do it with ArcGIS JS API. I have considered switching the entire client-side JS library to something like esri-leaflet, and raised a question at their repository. Then the closest answer/approach I get so far is to subscribe to ArcGIS Enterprise and use dynamicmaplayer to achieve this. My question: Is there any way to achieve this (pulling multiple Portal item layers and merge & display as one layer) just with ArcGIS JS API? Or in general - What are the possible/recommended approaches to achieve this, no matter client side or not? If we can rebuild the entire app to achieve this, what is the recommended approach?

Tags (2)
0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Hanlun,

  Have you considered a group layer?

GroupLayer | ArcGIS API for JavaScript 4.13 

HanlunSong
New Contributor II

Hi Robert, thanks for replying.

Based on my understanding, I think group layer is just a way to manage multiple layers simultaneously - not actually merging them into one layer for display.

I've just added the link to the actual map in question. So if you take a look, toggle two layers on, one layer will cover the one below. We want the two layers merged into one new layer that accumulates the numbers (even if the units of numbers are different)  

0 Kudos
EvelynHernandez
Regular Contributor

I dont understand too much the reason, why do u need to merge all the layers in one?
I think in ur case i would make a rest service with all the info that u wanna put there (u actually can put separated layers if u want) and then, programatically, calle them as dynamic service. So in that way you only call "one" layer instead of calling all of them separated.

0 Kudos
HanlunSong
New Contributor II

Thanks for replying. 

I've just added the link to the actual map in question. So if you take a look at it, it might help you understand the issue. You can toggle two layers on, and see one layer will cover the one below. We want the two layers merged into one new layer that accumulates the numbers (even if the units of numbers are different) and just display that one layer. And it could be any number of layers the user selects, so it needs to be dynamic/on-the-fly.

0 Kudos
HeatherGonzago
Esri Contributor

If you wish to display the layers at once, have you considered adding them to a webmap and saving out the WebMap? You can then bring in the entire WebMap with all of the layers by passing in the ID as seen in this example, Load a basic WebMap | ArcGIS API for JavaScript 4.13 .

If this goes beyond just visualization and trying to keep it simple, and you wish to actually merge the data in the layers into one single output file. You would need to do that using analysis tools such as Merge. You can find more info on this at Merge Layers—ArcGIS Online Help | Documentation 

HTH,

Heather

0 Kudos
HanlunSong
New Contributor II

Thanks for the reply. I've just added the link to the actual map. You can toggle two layers on, and see one layer will cover the one below. We want the two layers merged into one new layer that accumulates the numbers (even if the units of numbers are different) and just display that one layer. And it could be any number of layers the user selects, so it needs to be dynamic/on-the-fly. Based on this, I don't think I can pre-build a specific web map that just contains certain layers.

0 Kudos
EvelynHernandez
Regular Contributor

OH now i know, but thats impossible to do i think , unless u make combinations and save them as combinations.

Every layer is going to cover the previous one, thats how it works so far.

The only thing u can do in this case it is changing the layer opacity, so in that way you can actually see both... but you will have to deal with opacity for each map that the user selects.

0 Kudos
EvelynHernandez
Regular Contributor

Also u can change the visualizacion on the layers , indicating an index on what layer should be first or above.

you do this with map.addLayer(layer,index)

0 Kudos
HanlunSong
New Contributor II

I just realized that I added the wrong link for the esri-leaflet discussion.

Here is the link: Merge ArcGIS feature layer and display as one layer on client side · Issue #1169 · Esri/esri-leaflet... 

In this discussion, dynamicmaplayer was mentioned which requires Enterprise subscription. Do you think this would work?

0 Kudos