Select to view content in your preferred language

How to maintain area of polygon sketchviewmodel fixed?

550
2
05-06-2022 04:14 AM
YogeshSwami
New Contributor II

Hello Community,

I am trying to implement this functionality:

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=sketch-update-validation

Here, I am successfully getting the polygon which is editable but I want its area to be constant when shape is changed. Can anyone help me with this?

Regards

Yogesh Swami

0 Kudos
2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

You can use geometryEngine.geodesicArea method to calculate the polygon area while user is reshaping the polygon. 

I updated the sample you linked to showcase how to check if the polygon area is less than 1000 acres. Then let user make a change otherwise, force user to reshape the polygon. Having it equal to one number will probably be a challenge for users unless you help to set the area. My changes are in onGraphicUpdate function. https://codepen.io/U_B_U/pen/qBxbWOy?editors=1000

-Undral

0 Kudos
YogeshSwami
New Contributor II

Hello @UndralBatsukh ,

Thanks for you reply.

Your approach is great but I want the area to be constant. For eg, if we are giving user only the functionality to resize(not reshape) the polygon(specifically rectangle). Now the area needs to be constant while resizing.  If user decreases the height, the width should automatically get increased and vice versa so that area remains constant. Can you please help me with this as I have already spent many hours looking for the solution to this. Thanks in advanced.

0 Kudos