Converting polygons drawn with Sketch widget to GeoJSON

570
1
Jump to solution
05-12-2019 12:17 PM
Kevin_C
New Contributor III

I want to create an option in my webmap (drawn with ArcGIS API for JS) where I allow the user to draw polygons (probably using the Sketch widget). I then want to submit this polygon to a database. What's the best way to do this? Perhaps GeoJSON? Are there any options to convert created polygons to geojson with this API? 

I'm using php to connect to a postgreSQL db that stores this data.


Thanks!

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

There's no GeoJson support out of the box. Every ArcGIS geometry has toJSON method which allows to you to convert geometry objects to JSON geometry object. You can then perhaps use the following library to convert it to GeoJSON. 

https://github.com/Esri/arcgis-to-geojson-utils

View solution in original post

1 Reply
UndralBatsukh
Esri Regular Contributor

There's no GeoJson support out of the box. Every ArcGIS geometry has toJSON method which allows to you to convert geometry objects to JSON geometry object. You can then perhaps use the following library to convert it to GeoJSON. 

https://github.com/Esri/arcgis-to-geojson-utils

View solution in original post