how trace polyline between two points?

943
1
11-30-2010 04:03 AM
StefhanCampos
New Contributor
How i can draw a line between two points...e.g.: I have initial point and endpoint
and i need trace a line between this points...how i can do that?
0 Kudos
1 Reply
AliMirzabeigi
New Contributor
You can create a PointCollection containing the two points and create a Polyline object adding the PointCollection to its Paths:
ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
pointCollection.Add(startPoint);
pointCollection.Add(endPoint);
ESRI.ArcGIS.Client.Geometry.Polyline polyline = new ESRI.ArcGIS.Client.Geometry.Polyline();
polyline.Paths.Add(pointCollection);

To trace the line listen to your Map_MouseMove event handler and add a Graphic object to your GraphicsLayer setting its Geometry to the above Polyline object (the end point in this case will be always the point you are getting from GetPosition() method of the MouseEventArgs). To avoid drawing multiple lines on your layer you should check whether the Graphic object has been already added to your layer and if the layer contains your Graphic just set its Geometry to the new Polyline object that you are creating on your MouseMove event handler.
0 Kudos