Map Startup Issue - Mouse Graphics and Functionality not working and Layer doesn't load

2666
4
04-14-2016 11:59 AM
CraigPatterson
New Contributor III

I'm writing a stand alone ArcGIS Javascript API application that's behaving strangely when it initially loads. It contains three map services but when it starts, only two of them load. Another symptom is that the default mouse behavior isn't working either. If I click and hold down the left mouse button, the Hand icon appears and I can pan the map as expected. However, if I hold down the shift key and the left mouse and draw a rectangle, the default graphic doesn't render (showing the rectangle I've drug) nor does the map zoom in to the new extent. I have added a Draw Object, defined the renderer, but that doesn't work either when I activate the Draw Object.

However, when I click the Zoom In button, (the + in the top left corner), the map zooms in, the missing layer is drawn, and the mouse graphics start working.

Has anyone seen this behavior before? If so, any suggestions on where to start on debugging it? I'm not seeing any error messages in the web browser console, it it doesn't seem to matter if I change the map service. It acts the same.

Thanks for any help!

Craig

0 Kudos
4 Replies
CraigPatterson
New Contributor III

I haven't solved the issue, but here's a little more information.

For my map, I add the layers using the addLayers method.

map.addLayers([waterLayer, documentPolygonsFeatureLayer, basemapLayer ]);

I also am using the LayerList dijit. When I open the layer list, whatever layer I have listed first is grayed out in the LayerList. As soon as I zoom in or out, the layer becomes active.

0 Kudos
CraigPatterson
New Contributor III

Update number 2.

I've isolated the problem. If I have any code in my callback on the map's load event, the last layer doesn't finish loading.

Here's how I create my map.

        map = new Map("map",{

          //basemap: "dark-gray",

          extent: new Extent({

          "xmin": 12772352.907166796,

          "xmax": 12775795.524319759,

            "ymin": 536599.993017194,

            "ymax": 538666.659683864,

            "spatialReference": {"wkid": 2253 }

   })

        });

       

        map.addLayers([waterLayer,basemapLayer, documentPolygonsFeatureLayer ]);

        map.on("load", setup);

       

        function setup () {

          //define a selection symbol for the feature layer

      var selectionSFS = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

     new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,

     new EsriColor([255,0,0]), 2),new EsriColor([255,255,0,0.25]));

      documentPolygonsFeatureLayer.setSelectionSymbol(selectionSFS);

             

        }

How can I execute my callback method without causing this issue?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Craig,

Use:

map.on("layers-add-result", setup);

CraigPatterson
New Contributor III

Thanks for the advice. I ended up setting up the feature layers selection symbol outside of the setup method and got it working. But I'll keep your suggestion in mind for future reference.

0 Kudos