+ Reply to Thread
Results 1 to 7 of 7

Thread: Unable to draw graphic (null): Deferred Cancelled

  1. #1
    Andrew Naish
    Join Date
    Aug 2010
    Posts
    9
    Points
    1
    Answers Provided
    0


    1

    Default Unable to draw graphic (null): Deferred Cancelled

    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:

    Code:
    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:

    Code:
    dojo.io.script.jsonp_dojoIoScript_postcodes00_0_02197265625_1_3 is undefined
    Here is the code I am using:

    Code:
    <!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.

  2. #2

    Join Date
    Sep 2010
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    Hello - Did you ever find a solution to this problem? I am getting the same problem when using FeatureLayer with "dojo.io.script error Error: Deferred Cancelled" and later "dojo.io.script.<name> is undefined". I have found no other information on this problem. Would appreciate it if you could share anything you have discovered.

  3. #3
    Ihab El Attar
    Join Date
    Sep 2010
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    Hello,
    I am getting a similar error in FireFox trying to zoom in\out on a feature layer.
    http://forums.arcgis.com/threads/241...IoScript-Error

    Regards,

  4. #4
    Michelle Van Broekhoven
    Join Date
    May 2010
    Posts
    3
    Points
    1
    Answers Provided
    0


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    I had this same problem with a feature layer that drove me nuts. I believe in my case the jsonp callback string error (in dojo.io.script) was occurring because I tried to change both the featurelayer's visibility and layerdefinition, then change the map extent. My dev arcgis server is slow, so it takes a little time for the graphics in the featurelayer to redraw. If the layer isn't finished drawing before the map extent is changed, those errors were thrown.


    I solved my problem by setting the layer definition before setting its visibility and creating a small time out function to give the layer time to draw. for example-

    acuteLayer.setDefinitionExpression(defExp);
    acuteLayer.setVisibility(true);
    t=setTimeout(function(){updateZoomExtent(countyId, regionId)},500);

    I also had luck by setting the visibility of the layer to false with the event onZoomStart and then making it visible again upon onZoomEnd.

    //in the init function
    dojo.connect(map, "onZoomStart", function(extent, zoomFactor, anchor, level){
    acuteLayer.setVisibility(false);
    });

    dojo.connect(map, "onZoomStart", function(extent, zoomFactor, anchor, level){
    acuteLayer.setVisibility(true);
    });

    I'll probably end up using the second method which so far works the best for my map.
    Last edited by mapstar; 03-22-2011 at 10:12 AM.

  5. #5
    Scott Davis
    Join Date
    Mar 2010
    Posts
    54
    Points
    2
    Answers Provided
    0


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    onZoomStart and onZoomEnd fixed the problem for me. Thanks, mapstar!

  6. #6
    Georgie Cassar
    Join Date
    Feb 2011
    Posts
    12
    Points
    0
    Answers Provided
    0


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    THANKYOU.
    I have spent half a day wondering why I could not access the graphics of my featurelayer.
    I added the event "onUpdateEnd" to my feature layer and voila I can access the graphics array !

    ie:
    dojo.connect(featureLayer, "onUpdateEnd", function() {
    var zoomExtent = esri.graphicsExtent(featureLayer.graphics); //this works now !
    map.setExtent(zoomExtent);
    });

  7. #7
    Ryan Koehnen
    Join Date
    Apr 2010
    Posts
    30
    Points
    10
    Answers Provided
    1


    0

    Default Re: Unable to draw graphic (null): Deferred Cancelled

    I kept getting this error when a user rapidly zoomed in or out before the map finished drawing the feature layer. It was throwing an alert dialog. From what I can tell the error is meaningless because it's just indicating something went wrong when the xhr request for the current draw was canceled due to a new redraw.

    I was able to suppress the annoying error dialog like by proxying the alert and throwing it away. In the below function, the alert is only returned back to the caller if the error is NOT the one in question. Otherwise, it's handled, no more error alert.

    Code:
    var proxied = window.alert;
    window.alert = function(error) {
        if(error.message !== "Unable to draw graphic (null): Request canceled") {
    	return proxied.apply(this, arguments);
        }
    }
    Ryan Koehnen GIS Analyst / Software Engineer
    ddms, inc.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts