Edit: Move circle issue

372
3
08-02-2020 06:00 AM
MilawK_
New Contributor

Using Draw, i'm creating a circle (drag'n drop or click) from center point (lat and long) and radius.

drawRadiusCircle: function() {
this._clearGraphicLayers();
this.map.disableMapNavigation();
this.map.disableDoubleClickZoom();
this.map.hideZoomSlider();
this.map.setMapCursor(DRAW_CURSOR);
radius.activate(Draw.CIRCLE);

if (!this.mouseDragDrawListener) {
this.mouseDragDrawListener = this.map.on("mouse-drag", lang.hitch(this, this._mouseDragDrawHandler));
}

},

_mouseDragDrawHandler: function(event) {
this.isDrawDragged = true;
},

addDrawToMap: function(event) {
radius.deactivate();

if (this.mouseDragDrawListener) {
this.mouseDragDrawListener.remove();
this.mouseDragDrawListener = null;
}

var center = event.geometry.getCentroid();
var normalizedCenter = webMercatorUtils.xyToLngLat(center.x, center.y);
var centerX = normalizedCenter[0];
var centerY = normalizedCenter[1];
this.latitudeInput.set('value', centerY);
this.longitudeInput.set('value', centerX);

var point = event.geometry.getPoint(0, 0);
var normalizedPoint = webMercatorUtils.xyToLngLat(point.x, point.y);
var pointX = normalizedPoint[0];
var pointY = normalizedPoint[1];

var line = new Polyline([[pointX,pointY],[centerX,centerY]]);
var rad = geometryEngine.geodesicLength(line, this._rangeUnitSelectionValue());

if (this.isDrawDragged) {
this.rangeRadiusInput.set('value', rad);
this.isDrawDragged = false;
}

this.map.setMapCursor(DEFAULT_CURSOR);
this.map.enableMapNavigation();
this.map.enableDoubleClickZoom();
this.map.showZoomSlider();
this.drawRadiusCircleAndQueryData();
},

Callling this.drawRadiusCircleAndQueryData   create the layer and the graphic (the circle using the below):

return new Circle({
center: this._centerPointByInputs(),
radius: this._rangeRadiusInputValue(),
radiusUnit: this._radiusUnitType(),
geodesic: true
});

Using Edit for MOVE, I'm cannot get the new center point of the graphic

var graphic = this._radiusLayer.graphics[0];
editToolbar.activate(Edit.MOVE, graphic, options);


Getting this error:
Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "Z".

There is any way to get the new coordinate of the circle?

Thanks

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Milaw,

  Once a circle is created and edited it becomes a polygon and no longer has the properties of the circle class.

0 Kudos
MilawK_
New Contributor

Hi Robert,

Thanks for your answer.
Then what should I do to get the new center of the circle after 'move'?
Redraw a new graphic (polygon) and make some manipulation on it? 

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Milaw,

   You can get the center of a circle polygon by getting the polygons extent and the extents center.

0 Kudos