Create Polyline From Variable, result adds quotes?

436
1
Jump to solution
08-21-2014 08:41 AM
PaulVepraskas
Occasional Contributor

I am trying to create a polyline from points collected via GPS... The last remaining piece is that when I try and post the points to polyline the code adds quotes around the coordinates and is causing the post to fail.

            lineARRAY = lineARRAY.substring(0, lineARRAY.length - 1);

            var linejs = "[[" + lineARRAY + "]]";       

           

            var singlePathPolyline = new esri.geometry.Polyline({"paths":linejs,"spatialReference":{"wkid":32054}});

            var newAttributesG = dojo.mixin({}, GPSlayerLine.attributes);

            var newGraphicL = new esri.Graphic(singlePathPolyline, null, newAttributesG);

            GPSlayerLine.applyEdits([newGraphicL], null, null); 

The resulting post is:

[{"geometry":{"paths":[["[2498591.1952441176,335712.1545436013],[2498591.1952441176,335712.1545436013],[2498591.1952441176,335712.1545436013],[2498591.1952441176,335712.1545436013],[2498591.1952441176,335712.1545436013],[2498591.1952441176,335712.1545436013],"]],"spatialReference":{"wkid":32054}},"attributes":{}}]

As you can see it adds a double quote after paths (ex. "paths":[["[ ) Offending quotes in red?

Any idea on how to alter the attached code so I can eliminate the addition of those quotes?

Thanks

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Paul,

   Your issue is that lineArray is actually a string (thus the double qoutes) and not an actual array. You need to build and array not a string.

View solution in original post

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Paul,

   Your issue is that lineArray is actually a string (thus the double qoutes) and not an actual array. You need to build and array not a string.

0 Kudos