AnsweredAssumed Answered

JavaScript - map.setExtent does not work

Question asked by shaningesri on Jun 30, 2015
Latest reply on Jul 1, 2015 by shaningesri

About 1.5 year ago I created a JS application, which draw either a point or a polyline on the map after query.  Now, when I work on this project again and found that the map.setExtent does not work well.  The related code is below:

 

<script src="http://js.arcgis.com/3.13/" type="text/javascript"></script>

  ...

  map.graphics.clear();

  var polylineJson = response.Geometry[0];

  var polyline = new esri.geometry.Polyline(polylineJson);

  var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 3);  // Red

  var g = new esri.Graphic(polyline, symbol, null, null);

  map.graphics.add(g);

  map.setExtent(g.geometry.getExtent().expand(2));

If I disabled the line of    map.setExtent(g.geometry.getExtent().expand(2)); the polyline is drawn on the map.  With this line of code, the map does not shown well at all.

Besides, both the Zoom-in and Zoom-out buttons (+ & -) on the top-left of the map do not function well.

How can this be debugged?  Thanks.

Outcomes