map.operationalLayers repeating Layer

946
10
05-15-2019 01:41 PM
MKa
by
Occasional Contributor III

Has anyone ever had an issue with the operational layers repeating a layer when looping through them?  It seems to happen on mobile devices and on appstudio mobile but not on desktop app.  

I am simply wanting to loop though the layers, but I seem to have a repeating layer.  

 map.operationalLayers.forEach(function(value) {
    popupMessageBox.messageText += "\nvalue.name = " + value.name
 });‍‍‍

In this above example with 4 layers, the first time I run it, it gives me this result

layer.name = 1
layer.name = 2
layer.name = 3
layer.name = 4

Then I run it again and I get this result.  It seems to happen intermittently and only on my mobile device

 

layer.name = 1
layer.name = 2
layer.name = 2
layer.name = 4

Wondering if anyone has seen this type of behavior?

0 Kudos
10 Replies
JamesBallard1
Esri Regular Contributor

Hi M Ka‌,

I'm not aware of any problems like that. Can you provide some more information, or maybe even a small reproducer app that shows the problem?

You mentioned mobile. Is that Android or iOS? Also, what version of Runtime are you using?

0 Kudos
MKa
by
Occasional Contributor III

I can not figure out why this is happening.  It is happening in both IOS and Android and i am running the latest version of Runtime.  I have added 4 layers to my webmap and on mobile (cell) only, it sometimes is repeating the layers when I loop through the operational layers of a given map.

0 Kudos
MKa
by
Occasional Contributor III

Is there a way to requery the operationallayers of a map?  It is almost like on mobile, it takes longer to load and somehow a duplicate is getting returned in my above loop.  Again, this only happens on the mobile and it happens using the AppStudio mobile app.

0 Kudos
MKa
by
Occasional Contributor III

I am loading a MapView page with a loader, but on mobile when looping through the operational layers I am getting duplicates.  When I return to the page or come into the mapview for the first time.


MapView {
    map: MapFieldSelectedLoader.item
.
.
.

Component.onCompleted: {
        MapFieldSelectedLoader.sourceComponent = MapFieldSelected;        
    }
.
.
.
.
Loader {
        id: MapFieldSelectedLoader
    }

    Component {
        id: MapFieldSelected

        Map {
            id: mapFieldSelected
            autoFetchLegendInfos: true
            initUrl: app.webMapUrl

            //This returns the duplicate layer when looping through on mobile
            onLoadStatusChanged: 
            {
                    if (loadStatus === Enums.LoadStatusLoaded)
                    {                        
                     operationalLayers.forEach(function(lyr) {
                     popupMessageBox.messageText += "\n Loaded lyr.name = " + lyr.name                            
                        });
                    }
            }
        }
    }

0 Kudos
JamesBallard1
Esri Regular Contributor

M Ka‌,

Thanks for the additional info. Is the web map you're accessing public? If so, please share the url and we can try to reproduce the problem on our end.

0 Kudos
MKa
by
Occasional Contributor III

Could I get an email in which to send the URL of the WebMap to.  I will need to grant you access and give you a username and password to our portal that holds the web map.  I cannot make the whole thing public.

0 Kudos
JamesBallard1
Esri Regular Contributor

M Ka‌ thanks for the offer. I'll see if I can find a web map with four (or more) layers that we have access to and see if I can reproduce the problem that way.

0 Kudos
MKa
by
Occasional Contributor III

That would be so helpful.  You will need to load a mapview/loader/map page again and again, looking at the operational layers on load.  Mine seems to repeat them quite frequently as I mentioned above

0 Kudos
JamesBallard1
Esri Regular Contributor

M Ka‌, one of my colleagues tried this out in a test and wasn't able to reproduce the problem on a mobile device. That was using the same code you provided with a different web map. If you're able, please log the issue with Esri support so we can follow up.

Esri Support Home  

0 Kudos