Editable hosted "Multipoint" feature service

2202
7
09-07-2017 03:49 AM
ANarasimhaMurthy1
New Contributor

I have built an application using Web Appbuilder from my organisation AGOL to facilitate the users to add/edit point locations for one of our projects. The requirement of the project is to use "multipoint" geometry feature service. I have published a hosted editable feature service layer created from a multipoint feature class residing in my local file gdb with full editing capabilities including create, delete, query, sync and update. When I test it through my application to add new features to it, it's showing the feature templates but I am unable to add new features to it but it's allowing me to edit/update the existing feature attributes.

I have tested it with a "Point" geometry feature service published with full editing capabilities, it is working fine including ability to add new features.

My first doubt is, if "Multipoint" geometry can be used for creating feature services for full editing. If so, what might be wrong with my multipoint feature service. If not, kindly suggest me an alternative for my requirement of facilitating users to add multipoint features.

Your valuable suggestions are most appreciated.

Thanks in advance,

Navin

0 Kudos
7 Replies
JeffWilcox1
New Contributor III

I am also interested in this

0 Kudos
AlvinNguyen
New Contributor

Have either of you figured out how to work around this?  It is giving a halt on my project.  Any help is appreciated!

0 Kudos
XanderBakker
Esri Esteemed Contributor

What is the actual requirement that defines the need to use a multipoint geometry? In other words, why is the data managed as multipoint geometries? Is it really necessary? As you noticed by now there are some limitations when working with multipoint geometries, but if you are creating your own application, you can implement multipoints (Geometry objects—Common Data Types | ArcGIS for Developers ) and use Apply Edits (Feature Service)—ArcGIS REST API: Services Directory | ArcGIS for Developers to apply any edits to the service. See also Add, edit, and remove features | ArcGIS for Developers . Although my advice is, if there isn't a real requirement to use multipoint, you will be better off not using them.

0 Kudos
AlvinNguyen
New Contributor

The multipoint is used to represent a city construction project that can take place at multiple points throughout the city. I need to draw the multipoints and have it be editable as one project.  I would appreciate and example of combining the draw tool, attribute selector, and apply edits to work around this. Thank you!

0 Kudos
EbenOsgood
New Contributor

I work for a DOT division that issues construction permits along/within state ROWs. I'm trying to create a multipoint feature, as well, so that permits that have multiple locations attributed to them can be mapped as "one" permit and represented in several locations. We would like to be able to change the individual statuses at each point so as one location is finished, or updated, the attributes can reflect the changes. 

0 Kudos
XanderBakker
Esri Esteemed Contributor

In case you have a multi point feature and for one of the contained points you would want to change the status, this point would need to be a single feature and not contained within a multipoint. In case if a multipoint you would manage attributes that apply to all the points contained by the multipoint.

0 Kudos
AlvinNguyen
New Contributor

Hello Eben,

The built in Editor widget doesn't work so I combined the edit toolbar, attribute inspector, and template picker to get all the features to work.  Here is the function I created. Add your own feature layer. Add the appropriate requires and use map.on("layers-add-result", initEditTool).  

Sorry, I cannot upload the whole app, as the layers have sensitive material.

I used this as a guide and made minimal changes to get multipoint to work.

Hope this helps!  

function initEditTool(results) {


                var layers = array.map(results.layers, function(result) {
                    return result.layer;
                });
                //display read-only info window when user clicks on feature
                var query = new Query();
                array.forEach(layers, function(layer) {
                    layer.on("click", function(evt) {
                        if (map.infoWindow.isShowing) {
                            map.infoWindow.hide();
                        }
                        var layerInfos = [{
                            'featureLayer': layer,
                            'isEditable': false,
                            'showDeleteButton': false,
                            'showAttachments': false,
                        }]
                        var attInspector = new AttributeInspector({
                            layerInfos: layerInfos
                        }, domConstruct.create("div"));
                        query.objectIds = [evt.graphic.attributes.OBJECTID];
                        layer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(features) {
                            map.infoWindow.setTitle("");
                            map.infoWindow.setContent(attInspector.domNode);
                            map.infoWindow.resize(310, 165);
                            map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
                        });

                        
                    });
                });
                var templatePicker = new TemplatePicker({
                    featureLayers: layers,
                    rows: 'auto',
                    columns: 'auto',
                    grouping: true
                }, "templatePickerDiv");
                templatePicker.startup();
                var drawToolbar = new Draw(map);
                var selectedTemplate;
                templatePicker.on("selection-change", function() {
                    selectedTemplate = templatePicker.getSelected();
                    if (selectedTemplate) {
                        switch (selectedTemplate.featureLayer.geometryType) {
                            case "esriGeometryPoint":
                                drawToolbar.activate(Draw.POINT);
                                break;
                            case "esriGeometryPolyline":
                                selectedTemplate.template.drawingTool === 'esriFeatureEditToolFreehand' ? drawToolbar.activate(Draw.FREEHAND_POLYLINE) : drawToolbar.activate(Draw.POLYLINE);
                                break;
                            case "esriGeometryPolygon":
                                selectedTemplate.template.drawingTool === 'esriFeatureEditToolFreehand' ? drawToolbar.activate(Draw.FREEHAND_POLYGON) : drawToolbar.activate(Draw.POLYGON);
                                break;
                                case "esriGeometryMultipoint":
                                selectedTemplate.template.drawingTool === 'esriFeatureEditToolFreehand' ? drawToolbar.activate(Draw.MULTI_POINT) :   drawToolbar.activate(Draw.MULTI_POINT) ;
                                break;
                        }
                    }
                });
                drawToolbar.on("draw-end", function(result) {
                    //display the editable info window for newly created features
                    if (map.infoWindow.isShowing) {
                        map.infoWindow.hide();
                    }
                    drawToolbar.deactivate();
                    var fieldAttributes = layerFieldToAttributes(selectedTemplate.featureLayer.fields);
                    var newAttributes = lang.mixin(fieldAttributes, selectedTemplate.template.prototype.attributes);
                    var newGraphic = new Graphic(result.geometry, null, newAttributes);
                    var layerInfos = [{
                        'featureLayer': selectedTemplate.featureLayer,
                        'isEditable': true
                    }];
                    var attInspector = new AttributeInspector({
                        layerInfos: layerInfos
                    }, domConstruct.create("div"));
                    selectedTemplate.featureLayer.applyEdits([newGraphic], null, null, function() {
                        var screenPoint = map.toScreen(getInfoWindowPositionPoint(newGraphic));
                        map.infoWindow.setTitle("");
                        map.infoWindow.setContent(attInspector.domNode);
                        map.infoWindow.resize(325, 185);
                        map.infoWindow.show(screenPoint, map.getInfoWindowAnchor(screenPoint));
                        templatePicker.clearSelection();
                    });
                    attInspector.on("attribute-change", function(result) {
                        result.feature.attributes[result.fieldName] = result.fieldValue; // result will contains  a feature layer to access its attributes
                        result.feature.getLayer().applyEdits(null, [result.feature], null);
                    });
                    attInspector.on("delete", function(result) {
                        result.feature.getLayer().applyEdits(null, null, [result.feature]);
                        map.infoWindow.hide();
                    });
                });
            }

            function getInfoWindowPositionPoint(feature) {
                var point;
                switch (feature.getLayer().geometryType) {
                    case "esriGeometryPoint":
                        point = feature.geometry;
                        break;
                    case "esriGeometryPolyline":
                        var pathLength = feature.geometry.paths[0].length;
                        point = feature.geometry.getPoint(0, Math.ceil(pathLength / 2));
                        break;
                    case "esriGeometryPolygon":
                        point = feature.geometry.getExtent().getCenter();
                        break;
                    case "esriGeometryMultipoint":
                        point = feature.geometry.getExtent().getCenter();
                      break;

                }
                return point;
            }



            function layerFieldToAttributes(fields) {
                var attributes = {};
                array.forEach(fields.Object, function(field) {
                    attributes[field.name] = null;
                });
                return attributes;

}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos