Draw toolbar not showing extent while click-dragging...

542
3
Jump to solution
01-09-2014 05:08 AM
JustinWhite
New Contributor II
I have a strange one here and am sure that I am just missing something silly. I am using the latest version of the API in conjunction with ESRI's world street map service. Basically when clicking-dragging the mouse with the draw toolbar, nothing but the tool tip appears on the map. After letting go of the mouse button, the draw-end event fires correctly and I am able to draw the geometry on the map... It works - but is confusing. I have similar code working using an older version of the API.

ESRI's samples all work as expected in the same browser above as doos my older API code - so not a browser issue. There is a graphics layer on the map, but it still doesn't work even if remove that.

Anyone seen something similar or have any thoughts?

Code:

(Initialization)
   scToolBar = new esri.toolbars.Draw(self.map);                    
   scToolBar.on("draw-end", spatialConstraintDrawn);      

...

(when drawing starts - this is in another function activated by a button click)
  self.map.disableMapNavigation();
  scToolBar.activate(esri.toolbars.Draw.EXTENT);


Thank you for any thoughts or ideas!

Justin
0 Kudos
1 Solution

Accepted Solutions
JustinWhite
New Contributor II
Like I thought, it was something simple. Mainly that I am a moron. Not even really worth sharing - sorry to waste your time and thank you for your help.

Cheers!

Justin

View solution in original post

0 Kudos
3 Replies
derekswingley1
Frequent Contributor
Please post complete examples that demonstrate the problem.

Are you waiting for the map to load before creating your draw toolbar?

Here's code that does what you're requesting:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <title></title>
    <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.8/js/esri/css/esri.css">
    <style>
      html, body, #map {
        height: 100%; width: 100%; margin: 0; padding: 0; 
      }
    </style>

    <script src="//js.arcgis.com/3.8/"></script>
    <script>
      var map;
    
      require([
        "esri/map", 
        "esri/toolbars/draw",
        "esri/symbols/SimpleFillSymbol", 
        "esri/graphic",
        "dojo/domReady!"
      ], function(
        Map, Draw, SimpleFillSymbol, Graphic
      ) {
        map = new Map("map", {
          basemap: "streets",
          center: [ 19.291, 48.343 ],
          zoom: 4 
        });
        map.on("load", function() {
          var d = new Draw(map);
          d.on("draw-end", function(e) {
            console.log("e", e);
            map.graphics.add(new Graphic(e.geometry, new SimpleFillSymbol()));
          });
          d.activate(Draw.EXTENT);
        });
      });
    </script>
  </head>
  <body>
    <div id="map"></div>
  </body>
</html>


Live:  http://jsbin.com/ufOSACOR/1/edit
0 Kudos
JustinWhite
New Contributor II
Hi Derek,

Thanks for the quick response. The map has long been initialized in this case (it has already been drawn on with other objects) and that all works fine.

I essentially have the same code that you are showing, but since it is a large app and runs behind a firewall, it is really hard to post everything. The only difference that stands out is that I have two maps on the screen at once, although I disabled the second map and still a no go. It is strange too - on your sample drawing it is really smooth and I notice that when I try to draw on mine it is really "herky-jerky" - so much so that the tool tip sometimes can't keep up with the cursor. Perhaps the API is throwing and buryingexceptions?

Is there anyway to see if that is the case?

Thanks again for the suggestions.

Cheers,

Justin
0 Kudos
JustinWhite
New Contributor II
Like I thought, it was something simple. Mainly that I am a moron. Not even really worth sharing - sorry to waste your time and thank you for your help.

Cheers!

Justin
0 Kudos