Polygon needs to be redrawn before placed on correct location

Jan 12, 2009 at 3:07 PM
Hi all,
With the risk of repeating a question that has already been asked (I have seen something similar, but can't find the thread anymore)...

I am drawing a polygon on a geometrylayer, and add the layer to the map (see code below)
However, the polygon will not be pinned to the correct location at first. Only when I pan the map, the polygon readjusts and takes the correct position on the map.
Also, when the browser window is changes size the polygon will take the wrong position and readjust when panning the map a bit.
Is this something you guys have to work out, or is it our code?


public Page()





this.map.Loaded += new RoutedEventHandler(map_Loaded);





private void map_Loaded(object sender, RoutedEventArgs e)




this.shapelayer = CreateShapeLayer();









this.map.SetViewCenter(new Point(4.4607, 51.9065), 13.0);





private GeometryLayer CreateShapeLayer()




GeometryLayer shapelayer = new GeometryLayer(this.map) { ID = "POLYGONLAYER" };


shapelayer.HideElementsOnZoom =



shapelayer.UpdateMode =




return shapelayer;





private void AddPolygonToLayer(GeometryLayer shapelayer)




List<Point> points = new List<Point> { new Point(4.5295, 51.8942), new Point(4.5295, 51.8942), new Point(4.5361, 51.8948), new Point(4.5392, 51.8947), new Point(4.5397, 51.8959), new Point(4.5502, 51.8950), new Point(4.5567, 51.8933), new Point(4.5609, 51.8885), new Point(4.5623, 51.8806), new Point(4.5611, 51.8793), new Point(4.5619, 51.8782), new Point(4.5449, 51.8725), new Point(4.5435, 51.8714), new Point(4.5399, 51.8707), new Point(4.5319, 51.8800), new Point(4.5338, 51.8806), new Point(4.5295, 51.8857), new Point(4.5343, 51.8869) };



Polygon polygon = new DeepEarth.Geometry.Polygon { Points = points };


polygon.Name =



polygon.BorderThickness =

new Thickness(0);


polygon.LineThickness = 0.0;

polygon.FillColor =

Color.FromArgb(128, 155, 155, 155);



shapelayer.MouseEnter +=

new MouseEventHandler(polygon_MouseEnter);


shapelayer.MouseLeave +=

new MouseEventHandler(shapelayer_MouseLeave);



Jan 12, 2009 at 3:35 PM
Edited Jan 12, 2009 at 3:56 PM
First, try to recreate with the latest codebase.  I can tell by your code your a few drops (and fixes) behind.  There is a known issue with any geometry not being in the correct location until the MSI is initialized.  All of our calculations are dependend upon MSI being loaded.  One thought I've had is whether we should hide the GeometryLayer until the MSI is completely loaded.  Also, I recommend using Map.Events.MapLoaded event to signal MSI load vs. your current use of Map.Loaded. 

For your second issue, we may not be reacting correctly to the LayoutChanged event.  I'll take a took at this.

Update:  Checked it and it seems to be working fine.  Need more details.
Jan 12, 2009 at 4:34 PM
Ok, we'll get the latest codebase (the one we use now is one week old)
Appreciate the quick responses, thx!