can you please take a look at this snippet and let me know why I am getting this Error message
Uncaught TypeError: Cannot read property 'isWebMercator' of undefined
from the Circle.js module?
var graphicsLayerPoint = new esri.layers.GraphicsLayer();
map.addLayer(graphicsLayerPoint);
var graphicsLayerCircle = new esri.layers.GraphicsLayer();
map.addLayer(graphicsLayerCircle);
$("#btnAddJunctionFlag").on("click", function () {
toolbar = new Draw(map);
toolbar.activate(Draw.POINT);
map.hideZoomSlider();
toolbar.on("draw-end", addToMap);
function addToMap(evt) {
circle = new Circle({
center: evt.mapPoint,
geodesic: true,
radius: .6,
radiusUnit: "esriMiles"
});
}
var cgraphic = new Graphic(circle, circleSymb);
graphicsLayerCircle.add(cgraphic);
var pgraphic = new Graphic(evt.geometry, config.symbolPointJFlag);
graphicsLayerPoint.add(pgraphic);
}
1 Answer 1
The evt
object returned from the 'draw-end' event should have a property called geometry
, not mapPoint
. So it looks like you are passing an undefined center
parameter to the Circle constructor. Also, depending on your ESRI JavaScript version, consider using the 'draw-complete' event instead of 'draw-end', which is deprecated.
Try this instead:
circle = new Circle({
center: evt.geometry,
geodesic: true,
radius: .6,
radiusUnit: "esriMiles"
});