AnsweredAssumed Answered

Convert Polyline Graphic to FeatureLayer

Question asked by S.h.a.n.e on Jun 12, 2018
Latest reply on Jun 12, 2018 by S.h.a.n.e

Using version 4.7 of the JavaScript API:

 

I have a Polyline graphic which displays fine on a SceneView

 

var polylinePaths = [[-118.1, 34.1], [-118.1, 34.2], [-118.2, 34.2], [-118.2, 34.3], [-118.3, 34.3], [-118.3, 34.4], [-118.4, 34.4], [-118.4, 34.1], [-118.2, 34.1]];

var polyline = new Polyline({ hasZ: false, hasM: false, paths: polylinePaths });

var polylineSymbol = { type: "simple-line", color: "yellow", width: 2, style: "solid" };

var polylineGraphic = new Graphic(polyline, polylineSymbol);

view.graphics.add(polylineGraphic);

 

I need to add it to the map as a Polyline FeatureLayer sourced from a JSON file. Could someone help me create the JSON file (in the correct format) containing the above paths and the simplest possible code to add the Polyline code to the map?

 

I have tried various ways and also looked at Robert Scheitlin's answer to 'How to create a FeatureLayer containing polylines?' but still have not managed to get it working.

 

Any help would be much appreciated.

 

Thanks,

Shane

Outcomes