Select to view content in your preferred language

Performance issue with Layer.Refresh

562
0
02-18-2014 10:28 AM
DaveSouthern
Deactivated User
We have a simple prototype application that shows a map and allows the user to draw polygons on the map.  The polygon that is drawn is saved to an arcGis server.  I'll show what I think are the relevant snippets of code below with a brief description of what I believe is going on:

The section that allows for the drawing of the polygon looks like this:
        function digitizeShape(evt) {


            //initialiaze the toolbar, if not found
            if (!drawToolbar) { InitToolbar() }

            //set the map to the digitize state
            map.disableMapNavigation;
            drawToolbar.activate(esri.toolbars.Draw.POLYGON);

        }


Once the user is finished digitizing the polygon, this code is called to save it to the server:
        function addToMap(evt) {



            //get the name
            var buildingName = document.getElementById('BuildingNameBox').value;

            //get the polygon coordinates
            var polyString = dojo.toJson(evt.geographicGeometry.toJson());
            // polyString = '';

            //also commit to the server
            var requestText = "facno=" + buildingName + "&shape=" + polyString;
            httpAddRequest = new XMLHttpRequest();
            httpAddRequest.open("POST", "../ajax/postfacility.aspx?type=IHB", true);
            httpAddRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            httpAddRequest.onreadystatechange = evalAddResult;
            httpAddRequest.send(requestText);

            //restore the map navigation state
            map.enableMapNavigation;
            drawToolbar.deactivate();

        }


Finally, once the postback is complete, we refresh the map:
        function evalAddResult(args) {

            if (httpAddRequest.readyState == 4 /* complete */) {
                if (httpAddRequest.status == 200) {

                    //see if the add was successful
                    if (httpAddRequest.getResponseHeader("ERROR") == null) {

                        //success: refresh the map
                        var ihbLayer = map._layers['buildings'];
                        ihbLayer.refresh();

                    }
                    else {

                        //TODO: show the error when we get jquery messaging sorted out
                        //ShowMessage(httpAddRequest.getResponseHeader("ERROR"), "Add Failed");
                        window.alert(httpAddRequest.getResponseHeader("ERROR"));
                    }

                }
            }

        }


All this works good except for one exception:  The refreshing of the map takes about 5 seconds.  So I'm wondering... Are we doing this correctly?  Is Layer.Refresh the most efficient way to refresh the map, or is there another way that would work better?

Or... Is the problem really just a performance issue with our server?  Right now we're just trying out azurewebsites.net.  Maybe there's too much running on our server?

Any insight would be helpful.
0 Kudos
0 Replies