Select to view content in your preferred language

How to draw a "multi-polygon" using ArcGIS javascript?

4024
4
09-30-2014 12:55 AM
StephenLam
New Contributor III

Refering to this sample, I can simply draw polygons using the provided api, however they will be stored in a separated feature. I would like to draw multiple polygons and store them in a single feature, like MULTIPOLYGON (((xxxxxx

And then how to save them by applyEdit()? thanks!

0 Kudos
4 Replies
Vara_PrasadM_S
Occasional Contributor II

Hi Stephen Lam,

It might be possible, if we just keep adding the rings of other geometries to the Rings property of any one geometry. Also need to make sure that the units/spatialreference for the coordinates matches that of the map.

Note: I have not tested this. It is just an idea.

Please let me know if you get it working.

Thanks & Regards,

Vara Prasad.

0 Kudos
StephenLam
New Contributor III

Thanks for your reply, Vara. I think it should be worked, and I will give it a try if the templatePicker doesn't work for me.

0 Kudos
BjornSvensson
Esri Regular Contributor

Assuming that you want to store them in an ArcGIS feature service, you might be better of using the Editor widget (than the DrawTool plus your own code).  The Editor widget toolbar can be configured to have a "union" (merge) option.  The workflow would be to draw multiple features, then select them and click "union".

You can try with this sample: http://developers.arcgis.com/javascript/sandbox/sandbox.html?sample=ed_simpletoolbar

and add the "mergeVisible" toolbar options like this:

toolbarOptions: {
    reshapeVisible: true
    , mergeVisible: true  // add this line to the sample
}
0 Kudos
StephenLam
New Contributor III

Thanks for your reply Bjorn. It works for me!

0 Kudos