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?
Are you using 4.x? This works in the graphics sample
var polyline = new Polyline({
paths: [
[1099167.9988136857, 7769842.112602921], [1103372.0353693648, 7770319.844029703], [1101461.1096622378, 7767109.48884173]
],
spatialReference: 3857
});
As does this (with auto-casting)
var polyline = {
type: "polyline",
paths: [
[1099167.9988136857, 7769842.112602921], [1103372.0353693648, 7770319.844029703], [1101461.1096622378, 7767109.48884173]
],
spatialReference: 3857
};