AnsweredAssumed Answered

new Polyline() creates an object of type feature

Question asked by rugnirtheviking on Jul 19, 2018
Latest reply on Jul 19, 2018 by kenbuja

I'm trying to add a simple polyline to my map. I have the following code

 

var tempGraphicsLayer = new GraphicsLayer();
var updateGraphic;
geo_map = new Map({
  basemap: "dark-gray-vector",
  layers: [tempGraphicsLayer]
});

var polylineSymbol = {
  type: "simple-line",
  color: "#8A2BE2",
  width: "4",
  style: "dash"
};

geometry = new Polyline([[1099167.9988136857, 7769842.112602921], [1103372.0353693648, 7770319.844029703], [1101461.1096622378, 7767109.48884173]]);

var graphic = new Graphic({
  geometry: geometry,
  symbol: polylineSymbol
});
tempGraphicsLayer.add(graphic);

When I run this code, I get the following error:

Invalid property value, value needs to be one of 'esri.geometry.Extent', 'esri.geometry.Multipoint', 'esri.geometry.Point', 'esri.geometry.Polyline', 'esri.geometry.Polygon', 'esri.geometry.Mesh', or a plain object that can auto-cast (having .type = 'extent', 'multipoint', 'point', 'polyline', 'polygon', 'mesh')

Upon inspection, this is because the object produced by 'new Polyline()' is in fact of type "feature" - how can I add a simple polyline like this?

Outcomes