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?
Hanlun,
Have you considered a group layer?
GroupLayer | ArcGIS API for JavaScript 4.13
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.
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)
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
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.
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.
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.
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)
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 · GitHub
In this discussion, dynamicmaplayer was mentioned which requires Enterprise subscription. Do you think this would work?
I dont think so because u are still going to have the overlaping on the layers.
How i told u, the best way to do that is choosing with layer, index what u want to put first and what do u want to put behind.
There is no simple solution for what you are tying to do, not really. You basically need to do a client side join of two different datasets. Without building a server side solution, you may able to do something like this on the client, but first a warning. It's hacky, with no guarantees.
Here are the steps.
And same rules for FeatureLayers apply, must all be same geometry type, if layers have different schemas for fields, you'll have empty fields in popups.
If doing this dynamically in an app, just remove the old merged featurelayer and create a new one.
Did I mention this is completely untested?
Haha, thank you very much. It is very informative nonetheless.
You mentioned server side solution - could you talk more about that too?
Also, what if I switch the entire client side to something like esri-leaflet? Can I only query data from those layers (do I need ArcGIS Enterprise to query data only from layers?) and render them with leaflet?
It's no easier with esri-leaflet, probably even more work.
A server side solution would be to use a server object extension with Enterprise. I did this years ago to do something similar when I needed to add related data to the results of my feature requests. This does require having an Enterprise license and enough .NET or Java know how to build the extension.
Thank you. I think I should explore the server side option too. I do know .Net and some Java but not sure if it will be enough. I notice you are author of two ArcGIS books. May I ask if you could recommend some good resources other the ESRI documentation to get started on this?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.