Is there a simple way to draw a PolyLine ? I am trying to do this within these event handlers but it doesn't work:
private void xamMap_MapMouseMove(object sender, MapMouseEventArgs e)
private void xamMap_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
Programatically it works. I mean that the PolyLine object is filling with the new coordinates and then I close it to become a Polygon, but I can't see it visually
Hi VipSoftware,
Please take a look at this forum thread and also at this article.
Hope that helps,Milana Zhileva
I decided to test your example from this link but nothing happened.
I see no line. I use the "drawLayer".
I am trying this on WPF not Silverlight, but I think the data visualization is the same.
Declaration:
MapPolyline drawingPolyLine; PathElement el;
Initialization:
xaml:
<ig:MapLayer LayerName="drawLayer" FillMode="None" Fill="Blue" Stroke="Red" StrokeThickness="2"> <ig:MapLayer.Reader> <ig:SqlShapeReader DataMapping="Data=polyline" /> </ig:MapLayer.Reader> </ig:MapLayer>
code:
drawingPolyLine = new MapPolyline(); el = new PathElement(); el.StrokeThickness = 10.0; el.Fill = new SolidColorBrush(Colors.Red); el.Polylines = new MapPolylineCollection();
Drawing:
private void xamMap_MapMouseLeftButtonUp(object sender, MapMouseButtonEventArgs e) { if (this.DrawModeSelected) { Point newPoint = e.Position; Point geoPoint = getMapCoordinateByClickPoint(newPoint); if (drawingPolyLine.Count == 0) { drawingPolyLine.Add(geoPoint); } drawingPolyLine.Add(geoPoint); el.Polylines.Clear(); el.Polylines.Add(drawingPolyLine); xamMap.Layers["drawLayer"].Elements.Clear(); xamMap.Layers["drawLayer"].Elements.Add(el); xamMap.UpdateLayout();
}
private void xamMap_MapMouseMove(object sender, MapMouseEventArgs e) { if (this.DrawModeSelected) { if (drawingPolyLine != null) { if (drawingPolyLine.Count > 0) { Point newPoint = e.Position; Point geoPoint = getMapCoordinateByClickPoint(newPoint); drawingPolyLine[drawingPolyLine.Count - 1] = geoPoint; el.Polylines.Clear(); el.Polylines.Add(drawingPolyLine); xamMap.Layers["drawLayer"].Elements.Clear(); xamMap.Layers["drawLayer"].Elements.Add(el); xamMap.Layers["drawLayer"].UpdateLayout(); } } } }
My point is that when I move mouse over the map I want to see how the line is changing, but it is not happening.
Thanx a lot!