8 Replies Latest reply on Mar 28, 2015 11:33 PM by Yusufamro

    Unable to draw graphic (null): Deferred Cancelled

    anaish
      Hi

      I am getting a JavaScript exception when selecting features from a FeatureLayer on the map. The selection *seems* to work (i.e the features are highlighted), however firebug reports this error:

      dojo.io.script error Error: Deferred Cancelled
      
      cancelResult: undefined
      dojoType: "cancel"
      fileName: http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0
      lineNumber: 16
      message: "Unable to draw graphic (null): Deferred Cancelled"
      name: "Error"
      stack: "Error("Deferred Cancelled")@:0 ()@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 ([object Object],0,[object Array])@http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/esri/layers/FeatureLayer.xd.js:19 ([object Array],(function (dfd, id) {dfd = dfd || _4.io.script["jsonp_" + "dojoIoScript" + id];if (dfd) {try {dfd.cancel();_4.io.script._validCheck(dfd);} catch (e) {}}}))@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 (true)@http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/esri/layers/FeatureLayer.xd.js:19 ([object Object],4,[object Object],6)@http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/esri/layers/FeatureLayer.xd.js:19 ([object Object],4,[object Object],6)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 ([object Object],4,[object Object],6)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 ([object Object],4,[object Object],[object Object],true)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:52 ([object HTMLDivElement])@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:52 ([object HTMLDivElement])@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 ("onEnd",[object Array])@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 (148)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 (148)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 (148)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 (148)@http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0:16 "
      


      Firebug also reports the following error:

      
      dojo.io.script.jsonp_dojoIoScript_postcodes00_0_02197265625_1_3 is undefined
      
      


      Here is the code I am using:

      
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
      <html> 
      <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
        <meta http-equiv="X-UA-Compatible" content="IE=7" /> 
        <title>Layer in a map service - [ON-DEMAND]</title> 
          <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css"> 
       <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dojox/layout/resources/ResizeHandle.css"/> 
          <script type="text/javascript">djConfig = { parseOnLoad:true };</script> 
          <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script> 
       
          <script type="text/javascript"> 
            dojo.require("esri.map");
            dojo.require("esri.layers.FeatureLayer");
         dojo.require("dijit.form.ComboBox")
      
            var selectionToolbar, featureLayer;
       
            function init() {
         
         
           var initialExtent = new esri.geometry.Extent(112.607,-43.825,154.882,-10.558, new esri.SpatialReference({wkid:4326}) );
              var map = new esri.Map("map", { extent: initialExtent, slider: true, nav: true });
              dojo.connect(map, "onLoad", initSelectToolbar);
              var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
              map.addLayer(baseMapLayer);
       
              var fieldsSelectionSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5]));
              fieldsSelectionSymbol.setOutline(new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color([255,0,0]), 2));
        
              featureLayer = new esri.layers.FeatureLayer("http://arcgis:8399/arcgis/rest/services/maptest/MapServer/0",{
                mode: esri.layers.FeatureLayer.MODE_ONDEMAND
              });
       
              featureLayer.setSelectionSymbol(fieldsSelectionSymbol);
       
       
              map.addLayer(featureLayer);
            }
       
            function initSelectToolbar(map) {
              selectionToolbar = new esri.toolbars.Draw(map);
              var selectQuery = new esri.tasks.Query();
              dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
                selectionToolbar.deactivate();
                selectQuery.geometry = geometry;
                featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
              });
            }
         
         
        
       
          dojo.addOnLoad(init);
        </script> 
       
      </head> 
       
      <body class="tundra"> 
       <select dojoType="dijit.form.ComboBox" id="asgc" name="asgc">
      
        <option>
         ASGC Heirarchy 1
        </option>
        <option selected>
           ASGC Heirarchy 2
        </option>
        <option>
         ASGC Heirarchy 3
        </option>
       </select>
      
         
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.EXTENT);">Extent</button> 
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.LINE);map.hideZoomSlider();">Line</button> 
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.POLYLINE);map.hideZoomSlider();">Polyline</button> 
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.POLYGON);map.hideZoomSlider();">Polygon</button> 
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYLINE);map.hideZoomSlider();">Freehand Polyline</button> 
        <button dojoType="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);map.hideZoomSlider();">Freehand Polygon</button> 
        <button dojoType="dijit.form.Button" onClick="featureLayer.clearSelection();">Clear Selection</button><br> 
        <div id="map" style="position: relative; width:1280px; height:768px; border:1px solid #000;">
        </div> 
        
        <span id="messages"></span> 
      
      </body> 
      </html>
      
      



      I cannot afford to have JavaScript errors on the site I am working on, any help is greatly appreciated.