AnsweredAssumed Answered

How to make the getDojoShape() work in V3.5

Question asked by arcgisforwang on Jul 2, 2013
Hi all,
I found a very useful code snippet @

the code intends to make a dragable graphic on the map, it works on arcgis API 2.2 but not the latest 3.5.
Mainly because getDojoShape() returns null if only the version changed.
the reason could be perhaps explained as Jayant B Sai write HERE:

In v1.4, we changed the graphics layer behavior for better performance. As of v1.4, a graphic is only drawn if the extent of the graphic's geometry intersects the current map extent. In your case, I am guessing the graphic's geometry does not intersect, which causes this error.

I don't understand how to make the graphic intersects with the map extent and get the getDojoShape() work.

I know there are various ways to imitate the dojox mover object by using javascript, but they are not as good as this one, for me only, perhaps.

SO I was wondering if the following code works under arcgis API V 3.5?

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <meta http-equiv="X-UA-Compatible" content="IE=7" /> 
    <title>Moving a marker</title> 
    <link rel="stylesheet" type="text/css" href=""> 
    <script type="text/javascript" src=""></script> 
    <script type="text/javascript"> 
      var map;
      function init() {
        map = new esri.Map("map");
        dojo.connect(map, "onLoad", onMapLoad);
        var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("");
      function onMapLoad() {
        var geometry = map.extent.getCenter().offset(0, 15);
        var symbol = new esri.symbol.SimpleMarkerSymbol().setColor("red");
        var graphic = new esri.Graphic(geometry, symbol);
        // Add a graphic;
        // Make the shape moveable
        var dojoShape = graphic.getDojoShape();
        var moveable = new dojox.gfx.Moveable(dojoShape);
        // Update the geometry at the end of move
        var moveStopToken = dojo.connect(moveable, "onMoveStop", function(mover) {
          // Get the transformation that was applied to 
          // the shape since the last move
          var tx = dojoShape.getTransform();
          var startPoint = graphic.geometry;
          var endPoint = map.toMap(map.toScreen(startPoint).offset(tx.dx, tx.dy));
          // clear out the transformation
          // update the graphic geometry
          // You can find quite a bit of information about
          // applying transformations to Dojo gfx shapes in this
          // document:
  <body class="tundra"> 
    <div id="map" style="width:700px; height:500px; border:1px solid #000;"></div>