Potential Error - using source 17601

Dec 12, 2008 at 8:06 PM
Hello all,

I've been testing dynamic addition of polygons to DeepEarth; having mixed results.  I took the code below (from GeoServices.xaml.cs) and pasted it in the Page.xaml.cs so that it would execute on startup.   The polygon is added, but it is spatially incorrect.  It's only after I zoom in once (I use mouse wheel to zoom) that the polygon "moves" to the correct location.  I've noticed this with other polygons I've added dynamically as program is starting. 

Is there a setting / parameter that may be a little off on program startup??

//ADDED TO TEST ADDING POLYGON ON STARTUP

 

ShapeLayer shapeLayer = null;

 

shapeLayer =

new ShapeLayer(map) { ID = "POLYGONLAYER" };

 

map.Layers.Add(shapeLayer);

 

var points = new System.Collections.Generic.List<Point> { new Point(0, 0), new Point(20, 0), new Point(20, 20), new Point(0, 20) };

 

 

var polygon = new Polygon { Points = points };

 

shapeLayer.Add(polygon);

 

//

 

Coordinator
Dec 13, 2008 at 8:53 AM
Calculations may be off since the map may not be fully loaded.   We may want to queue up Shape additions until we know map is fully loaded or just make sure to reset them all when we know map is loaded.
Dec 14, 2008 at 7:53 PM
Resolved:   To fix this problem I did the following:

Added  the following to Public Page()  

//WHEN MAP STOPS ZOOMING, THIS EVENT IS FIRED

map.Events.MapZoomEnded +=

new DeepEarth.Events.MapEvents.MapEvent(Events_MapZoomEnded);


Logic is now included with Events_MapZoomEnded.  This cleared up the spatial placement issue of the features (polygons).


Rob

 

Coordinator
Dec 15, 2008 at 1:26 AM
Rob, can you elaborate on the exact changes you made to fix this?
Dec 15, 2008 at 2:16 PM

soulsolutions,

Using source code 17627:

I compared a lot of code between previous source code versions that worked and more current source code versions in which this occurred.  While some differences, no changes made a difference.  I then figured it had to be due to the map not being completely loaded while I was trying to dynamically add polygons on startup.

I added the following to Page() in Page.xaml.cs

 

//WHEN MAP STOPS ZOOMING, THIS EVENT IS FIRED

 

map.Events.MapZoomEnded +=

new DeepEarth.Events.MapEvents.MapEvent(Events_MapZoomEnded);


The code within Events_MapZoomEnded:

 

map.Events.MapZoomEnded -= Events_MapZoomEnded;

 

drawLayersOnMap();


This simply adds a set of spatially enabled layers (shapefiles or SDE layers) on application startup.  The polygons are now spatially correct on application startup.

Simple approach I took to fix this - perhaps I missed something in the code.   If you need anything else, please let me know.

Again, great work.    Rob