10squared

Polyline creation from lat & long

Discussion created by 10squared on Sep 2, 2011
Latest reply on Sep 6, 2011 by 10squared
I've read several examples but it looks like I'm still missing something here. Beginning with 2 pair of coordinates, e.g. -85.1, 33.4 and -85.2, 33.3, I draw circles around the points and then try to draw a polyline between them. I can buffer the points fine but having a problem with the line draw. The SpatialReference on the map and buffered points is wkid:4326.


   function drawLine(x1,y1,x2,y2) {
      var params = new esri.tasks.BufferParameters();
      var p1 = new esri.geometry.Point(x1, y1, new esri.SpatialReference({wkid:102100}) );
      var p2 = new esri.geometry.Point(x2, y2, new esri.SpatialReference({wkid:102100}) );
      var geometry = new esri.geometry.Polyline(new esri.SpatialReference( {wkid:102100} ));
      geometry = geometry.addPath([p1,p2]);
      params.geometries = [ geometry ];
      params.bufferSpatialReference = new esri.SpatialReference({wkid:102100});
      params.outSpatialReference = new esri.SpatialReference({wkid:102100});
      gsvc.buffer(params, showLineBuffer);
    }
    function showLineBuffer(geometries) {
        var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 3);
      dojo.forEach(geometries, function(geometry) {
          var graphic = new esri.Graphic(geometry,symbol);
          map.graphics.add(graphic);
      });
    }

Outcomes