Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I used the ArcGIS Javascript layer reordering sample as template.

Initially I have 4 layers added to the map by ArcGISDynamicMapServiceLayer where reordering was working. Then, instead of using add lake from a table, I add 5 other layers using ArcGISDynamicMapServiceLayer again and pushed the layers into the first ArcGISDynamicMapServiceLayer with DynamicLayerInfos.push(newDynamicLayerInfo).

The drag and drop list would update to include all the old + new layers. But the new layer wouldn't reorder.

I drag the new layers all the way to the top and move it around. What ended up happen was that no matter name in the list was the first four item, it would change the order of the older layers. Example:

old1 => old layer1
old2 => old layer2
new4 => old layer3
new3 => old layer4

so if I move it around this would happen

old1 => old layer1
new3 => old layer4
new4 => old layer3
old2 => old layer2

It doesn't seem to be registering the new layer in the older ArcGISDynamicMapServiceLayer which I push the new layers into. Can anyone tell me what I did wrong?

Allen

function addProperty(){
    var propertyLayer, propertyDynLayerInfos, dynamicLayerInfo;

    // disable the "Add Property" button
    dijit.byId("property").set("disabled", true);
    dijit.byId("property").destroy();

    // show a loading icon
    //dojo.style(dojo.byId("loading"), "display", "inline-block");
    dojo.style(dojo.byId("loading"), "visibility", "visible");

    urlDyn = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer";
    propertyLayer = new esri.layers.ArcGISDynamicMapServiceLayer(urlDyn, { "id": "Property2" }); //only work for mapserver not featureserver
    app.map.addLayer(propertyLayer);

    var addLayerhandler = dojo.connect(
        propertyLayer, 
        "onUpdateEnd", 
        function() {
            dojo.disconnect(addLayerhandler);
            dojo.style(dojo.byId("loading"), "visibility", "hidden");

            // create a new dynamic layer info object for the property layer
            if ( ! app.hasOwnProperty("dynLyrInfos") ) {
                app.dynLyrInfos = app.map.getLayer("Kings County").createDynamicLayerInfosFromLayerInfos();
            } 

            // add new layers
            //propertyDynLayerInfos = propertyLayer.hasOwnProperty("dynamicLayerInfos") ? propertyLayer.dynamicLayerInfos : propertyLayer.layerInfos;
            propertyDynLayerInfos = propertyLayer.createDynamicLayerInfosFromLayerInfos();
            alert(propertyLayer + " " + propertyLayer.hasOwnProperty("dynamicLayerInfos"));
            dojo.forEach(
                propertyDynLayerInfos, 
                function(dynamicLayerInfo, i)
                {
                    app.dynLyrInfos.push(dynamicLayerInfo);
                }
            );

            app.map.getLayer("County").setDynamicLayerInfos(app.dynLyrInfos);
        }
    );
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.