1

I just started exploring the CMV about a week ago as an option to replace our Flex Viewer based configurable web mapping applications. So far it seems to be meeting all our needs however I have run into a snag regarding layer order.

Our web maps consume a variety of operational layer types but when I add a KML layer, it gets placed on top of all other layers. All layers added from our GIS servers get placed in the same order as listed in the code of viewer.js but the KML layers are not honored by this order. Is there any way to manage the layer order of KML layers directly in the CMV?

To clarify, when GIS server layers are mixed with kml layers, the kml layers are grouped separately from the GIS server group of layers regardless of operational layer order in viewer.js. Although, within both of these "groups," layer order as per the code of viewer.js is honored. It's in the rendering of layers on the map that layer order is not honored within the "group" of kml layers. The rendering is completely random, see below for three separate renderings of a map with all the same settings.

kml layers not honoring their coded order in viewer.js After hitting refresh a new layer order is assigned yet a third different rendering of kml layer order, all with the same app and widget settings

1 Answer 1

1

I believe this occurs because the ESRI JavaScript API actually adds separate graphics layers for different feature types within the KML file. These layers are added after the KML file is loaded and so loaded on top of any previous maps.

Perhaps you could explicitlyreorder the KML layer(s) from within an invisible widget once all the layers have been loaded.

Also note that the layerControl widget has some properties you can set to control the reordering of vector layers versus overlay layers. I'm not sure you are running into this but it is possible that it may be intereferring with your explcit layer order. Try removing this widget to see if the layer ordering is improved.

2
  • I did play around with the settings of the layerControl widget and try removing it altogether. Neither changed anything. In my edit above, the issue is only with the order KML layers are rendered in the map. I've even looked for clues that might affect kml ordering when retrieved from my web server (i.e. file names, size, etc.), nothing. I did notice in the LayerControl.js file that there appears to be a seperate overlay layer control container and vector layer control container. I'm no javascript developer. Any idea why these "containers" are separate or if they can be combined?
    – Cornflake
    Commented May 5, 2015 at 19:15
  • I think you'll need to write code to force the KML layers to be in the order you desire. I am pretty certain this is not specific to CMV or the layerControl widget and it is caused by how the ESRI JavaScript orders the graphic layers as they are derived and created from the KML file after it is retrieved via the url. Here's a reference to the issue with a possible work around (code) geonet.esri.com/thread/43340
    – tmcgee
    Commented May 5, 2015 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.