Select to view content in your preferred language

ESRI LEaflet - Adding ESRI GeoJSON / MultiPart Polygons to a REST service

744
0
02-17-2021 06:35 AM
annahernandez99
New Contributor

I'm currently allowing users to draw into an ESRI-Leaflet map using a drawing layer, adding some additional properties to that layer, and then submitting the results to a feature service.

This is great for single polygons. The methodology, however, doesn't work for multipart (multipolygon) polygons, or mixed feature types in a FeatureCollection. I specifically wish to submit multipart polygons rather than iterating through available features. There are some follow on GIS functions that rely on them being multipart.

Below is a sampleset of how I'm currently dealing with things. Then, a concept of what I'm thinking regarding multipart.

My question is -
When using geojsonToArcGIS can I use the result with addFeature to have a multipart polygon added to the feature service?

Not only do I not know if this is a valid approach, I'm not sure if there might be a better way of approaching this. There's not much documentation or examples to work with online around adding multipart feature collections using ESRI Leaflet. protigwelders

Currently using:


var feature = {
type: 'Feature',
geometry: Geometry,
properties: {
LGA: String(lga),
Locality: String(locality),
Region: String(region),
};

service.addFeature(feature, function (error, response) {
if (error) {
console.log('error creating feature' + error.message);
} else {
console.log('Successfully created feature with id ' + response.objectId);
}
});

Rather than using the above, I'm wondering if it is possible to do something more along the lines of:

//We start with a drawing layer, ingested as drawngeo. Lets assume it has 3 polygons (or lines) at this point.
if (eventtype == "create") {
var drawngeo = drawnItems.toGeoJSON(); //This makes the JSON accessible
drawngeo.features[0].properties.TestKey = "Test"; //Add a custom property, for example.
var drawnesrijson = L.esri.Util.geojsonToArcGIS(drawngeo,"OBJECTID"); //Make it ESRI-JSON
}

service.addFeature(drawnesrijson, function (error, response) { //We have used the ESRI GeoJSON instead
if (error) {
console.log('error creating feature' + error.message);
} else {
console.log('Successfully created feature with id ' + response.objectId);
}
});
In case this helps with people finding this in future, here are a few extra keywords: ArcGIS Online, AGOL, ESRI, ArcGIS Portal.

0 Kudos
0 Replies