Below is about the simplest possible code for drawing a line between two points. the event is tied to a button that coexists on a page with a xamWebMap. The map is pretty much drawn from the samples.
The odd thing is that DrawPath_Click does nothing the first time around. I can see an element added to xamWebMap1.Layers[0].Elements and the visible attribute is set to visible but it doesn't show up on the map. The second and subsequent calls to DrawPath_Click are fine.
I checked to see if maybe I was one rendering behind all the time and I don't think that's the case but I am often wrong.
private void DrawPath_Click(object sender, RoutedEventArgs e)
{
drawLine(36 + numCalls, -80, 39 + numCalls, -95);
numCalls += 1;
}
void drawLine(double srcLat, double srcLong, double destLat, double destLong)
MapPolylineCollection lines = new MapPolylineCollection();
List<Point> points = new List<Point>();
points.Add(new Point(srcLong, srcLat));
points.Add(new Point(destLong, destLat));
lines.Add(xamWebMap1.Projection.ProjectToMap(points));
PathElement lineElement = new PathElement() { Polylines = lines };
lineElement.Fill = new SolidColorBrush(Colors.White);
lineElement.StrokeThickness = 2;
xamWebMap1.Layers[0].Elements.Add(lineElement);
Rect worldRect = lineElement.WorldRect;
worldRect = lines.GetWorldRect();
lineElement.WorldRect = worldRect;
I wasn't entirely sure how to check the version so I went to Infragistics.Silverlight.DataVisualization.Map.v9.1.dll and clicked on properties. The version showed 9.1.20091.1000.
I am still seeing nothing after the first time through my code. I am using Silverlight 3 and FireFox 3.5.2.
I notice in the online docs that the tree control has no vertical scroll bar in FireFox but does in IE.
I will run the app in IE and see if I get different behavior.
this worked fine for me using your code on a page like this:
<Grid x:Name="LayoutRoot"> <igMap:XamWebMap x:Name="xamWebMap1"> <igMap:XamWebMap.Layers> <igMap:MapLayer> <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="world" /> </igMap:MapLayer.Reader> </igMap:MapLayer> </igMap:XamWebMap.Layers> </igMap:XamWebMap> <Button Height="50" Width="50" x:Name="DrawPath" Click="DrawPath_Click" /> </Grid>
the first time i clicked the button, a white line was drawn from South Carolina to the Mississippi river. i tested this using version 9.1.20091.1000. what version are you using?
is the map fully loaded and rendered when you click this button?
as a workaround, you could try calling MapLayer.RenderWindow() to force a re-render. beware, though, this causes a full refresh of the map which is an unnecessarily large operation and could impact your application's performance.