Hide Table of Contents
esri
Map
toolbars
Class: Polyline
[ AMD Module Require | Legacy Module Require ]

Description

An array of paths where each path is an array of points.

Samples

Search for samples that use this class.

Class hierarchy

esri.geometry.Geometry
|_esri.geometry.Polyline

Constructors

ConstructorDescription
new esri.geometry.Polyline(spatialReference)Creates a new Polyline object.
new esri.geometry.Polyline(json)Creates a new Polyline object using a JSON object.

Properties

PropertyTypeDescription
pathsNumber[][][]An array of paths. Each path is made up of an array of two or more points.
spatialReferenceSpatialReferenceThe spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.
typeStringThe type of geometry.

Methods

MethodReturn ValueDescription
addPath()PolylineAdds a path to the Polyline. The path can be one of the following: an array of numbers, an array of points, or a JSON object. When added the index of the path is incremented by one.

The return value of Polyline was added at v1.4.
getExtent()ExtentReturns the extent of the Polyline.
getPoint(pathIndex,pointIndex)PointReturns a point specified by a path and point in the path.
insertPoint(pathIndex,pointIndex,point)PolylineInserts a new point into a polyline.
removePath(pathIndex)Point[]Removes a path from the Polyline. The index specifies which path to remove.
removePoint(pathIndex,pointIndex)PointRemove a point from the polyline at the given pointIndex within the path identified by the given pathIndex.
setPoint(pathIndex,pointIndex,point)PolylineUpdates a point in a polyline.
setSpatialReference(sr)GeometrySets the spatial reference.

The return value of Geometry was added at v1.4.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Constructor Details

new esri.geometry.Polyline(spatialReference)

Creates a new Polyline object.
Parameters:
<SpatialReference> spatialReferenceRequiredSpatial reference of the geometry.
Code Snippet:
new esri.geometry.Polyline(new esri.SpatialReference({wkid:4326}));

new esri.geometry.Polyline(json)

Creates a new Polyline object using a JSON object.
Parameters:
<Object> jsonRequiredJSON object representing the geometry.
Code Snippet:
var polylineJson = {
  "paths":[[[-122.68,45.53], [-122.58,45.55],
  [-122.57,45.58],[-122.53,45.6]]],
  "spatialReference":{"wkid":4326}
};

var polyline = new esri.geometry.Polyline(polylineJson);
Property Details

<Number[][][]> paths

An array of paths. Each path is made up of an array of two or more points.
See Also: addPath

<SpatialReference> spatialReference

The spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

<String> type

The type of geometry.
Known Values: point | multipoint | polyline | polygon | extent
Method Details

addPath()

Adds a path to the Polyline. The path can be one of the following: an array of numbers, an array of points, or a JSON object. When added the index of the path is incremented by one.

The return value of Polyline was added at v1.4.
Return Value: Polyline
Code Snippet:

Adding a path using Points:

polyline.addPath([new esri.geometry.Point(10,10), new esri.geometry.Point(20,20), new esri.geometry.Point(30,30)]);

Adding a path using an array of x,y coordinate pairs:

polyline.addPath([[-122.68,45.53], [-122.58,45.55],  [-122.57,45.58],[-122.53,45.60]]);
See Also: paths

getExtent()

Returns the extent of the Polyline.
Return Value: Extent

getPoint(pathIndex,pointIndex)

Returns a point specified by a path and point in the path.
Return Value: Point
Input Parameters:
<Number> pathIndexRequiredThe index of a path in a polyline.
<Number> pointIndexRequiredThe index of a point in a path.

insertPoint(pathIndex,pointIndex,point)

Inserts a new point into a polyline.
Return Value: Polyline
Input Parameters:
<Number> pathIndexRequiredPath index to insert point.
<Number> pointIndexRequiredThe index of the inserted point in the path.
<Point> pointRequiredPoint to insert into the path.

removePath(pathIndex)

Removes a path from the Polyline. The index specifies which path to remove.
Return Value: Point[]
Input Parameters:
<Number> pathIndexRequiredThe index of a path to remove.

removePoint(pathIndex,pointIndex)

Remove a point from the polyline at the given pointIndex within the path identified by the given pathIndex.
Return Value: Point
Input Parameters:
<Number> pathIndexRequiredThe index of the path containing the point.
<Number> pointIndexRequiredThe index of the point within the path.

setPoint(pathIndex,pointIndex,point)

Updates a point in a polyline.
Return Value: Polyline
Input Parameters:
<Number> pathIndexRequiredPath index for updated point.
<Number> pointIndexRequiredThe index of the updated point in the path.
<Point> pointRequiredPoint to update in the path.

setSpatialReference(sr)

Sets the spatial reference.

The return value of Geometry was added at v1.4.
Return Value: Geometry
Input Parameters:
<SpatialReference> srRequiredSpatial reference of the geometry.

toJson()

Converts object to its ArcGIS Server JSON representation.
Return Value: Object