1

I have list of points. I am pushing these points to an array. Now when i draw polyline through esri map graphics.add then its not shwoing anything.

My code for drawing polyline on esri map is as follows:

  var Points = new Array();
            var PointsGoogle = new Array();
            for (VIndex = 0; VIndex < ItemList.Coordinates.length; VIndex++)
            {
             latlng = new  esri.geometry.Point(ItemList.Coordinates[VIndex].X,ItemList.Coordinates[VIndex].Y);

                Points.push(latlng);

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

      var polylineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([204, 102, 51]), 4);
          var polyline = new esri.geometry.Polyline(esrimap.spatialReference);
      polyline.addPath(Points);
      esrimap.graphics.add(new esri.Graphic(polyline, polylineSymbol));
1
  • What coordinate system is the esrimap in?
    – raykendo
    Mar 4, 2015 at 15:06

1 Answer 1

1

edit: amended answer because ray kendo was on the right track and i gave incorrect information initially.

paths can either be composed of an array of Point objects or raw coordinate pairs.

we assume wgs84 when no spatial reference is provided for individual points, but you need to declare the spatialReference of the empty polyline as WGS84 as well if you'd like the entire geometry to be reprojected and drawn appropriately in a web mercator map.

var wgs84 = new SpatialReference({wkid:4326});
var geometry = new Polyline(wgs84);
geometry.addPath([new esri.geometry.Point(0,0), new esri.geometry.Point(10,10), new esri.geometry.Point(30,10)]);
// or
geometry.addPath([[0,0],[10,10],[30,10]]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.