Editor Widget, Union Tool, and Polyline features

3687
4
01-06-2012 06:13 AM
JasonMielke
New Contributor II
Anyone out there have any success getting line (polyline) features to union/merge when using the Editor Widget's edit toolbar union tool?

When I select two or more line features in my application and click the union tool, nothing happens..., firebug reveals that the application doesn't even attempt an HTTP GET to my geometry service's union endpoint.  I have point, line and polygn features in my template picker.  When I attempt the same thing with polygon features, it works as expected.

The JavaScript API documentation for the GeometryService union states that input geometries "...must be of the same type." This implies that it should work with esriPolyline types. And I was able to sucessfully test the geometry service's rest endpoint directly, by passing in a Geometry Array containing two paths and having it succesfully return a merged geometry message.  So I'm confident the issue probably lies within my code or that it is a bug in the Editor Widget itself.  Currently I'm using JS version 2.4.

Interestingly, I have not found an ESRI sample that contains both the union tool and a line type feature layer.  Anyone know of one..., ESRI or other public online example?  I'd appreciate hearing others experiences unioning features in their web map applications using the Editor Widget's union tool (i.e. toolbarOptions {mergeVisible: true}) with a polyline feature layer.

Thanks in advance for your thoughts and feedback, Jason
0 Kudos
4 Replies
JonasEngedal
New Contributor
Any news on this one? Still an issue in JSAPI 3.3.
0 Kudos
SakkachinWongcharoen
New Contributor
I want the feature to union/merge Polyline for editor widget too. It's really useful for my work.

Thanks in advance, Sakkachin.
ALESSANDROCECILI
New Contributor

Is somebody who resolved this problem?

Thanks in advance.

0 Kudos
BrandonFlessner
Occasional Contributor

I haven't explored using the editor widget but here is a code sample that will merge polyline graphics into one geometry:

function mergeLines(graphicsArray){
    // merge geometries of graphics into one geometry
    var polyline = new Polyline(map.spatialReference);
    for (var i = 0; i < graphics.length; i++){
        var paths = graphics.geometry.paths;
        for (var j = 0; j < paths.length; j++){ //needed for multi part lines
            polyline.addPath(paths);
        }
      }
      return polyline;
}

var mergedGraphicGeometry = mergeLines();

the graphicsArray could be map.graphics.graphics, featureLayer.graphics, featureLayer.getSelectedFeatures(), a manually populate array, etc.

Hope that helps!

0 Kudos