Select to view content in your preferred language

Create Polygon From Height and Width

08-01-2021 12:30 PM
New Contributor II


We are creating a feature from a width and height. The code is creating polygon properly, but when I use to measure the height and width of the polygon using the measure tool, it shows the actual height and width smaller then the height and widths specified when creating the feature.

This is the code we use to create feature polygon.

For example, if I create the Polygon with 20 x 20, It created it, but when I measure it with measure tool, it shows height and width 18 meters width and 18 meters height.

This is the code.


var weight = this.txtWidth.get("value");
var height = this.txtHeight.get("value");

this.txtWidth.set("value", "");
this.txtHeight.set("value", "");

if (this.isNumeric(weight) == false || this.isNumeric(height) == false) {
  alert("Please enter correct Height and Width");

var symbol = new SimpleFillSymbol({
  "type": "esriSFS", "style": "esriSFSSolid", "color": [255, 0, 0, 100],
  "outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": [255, 0, 0, 255], "width": 1 }

var pt =;
var x = pt.x, y = pt.y;
var dx = parseInt(weight), dy = parseInt(height);

var polygon = new Polygon({
  "rings": [[
	  [x - dx, y - dy], [x - dx, y + dy],
	  [x + dx, y + dy], [x + dx, y - dy], [x - dx, y - dy]
  ]], "spatialReference": pt.spatialReference

var gr = new Graphic(polygon, symbol);
gr.attributes = [];

var layerId = this.config.editor.layerInfos[0];
var currentFeatureLayer =;






Please suggest, what is wrong with this code. This was working before but recently we upgraded to ESRI 10.8 version and we notice issue. Previous version was ESRI 10.5.


0 Kudos
0 Replies