Map Refresh

Sep 16, 2008 at 10:45 PM
Wondering if anyone has run into this.

I've added some polygons as shapelayers.  I have a tree user control that allows the user to select which layers to turn off and on.  I reaccess the Page.xaml.cs page with the new information and update the shapelayer information in the map.  However, the map itself does not redraw - seems like I need some kind of map refresh or something.  Any ideas.....
Developer
Sep 19, 2008 at 3:54 AM
do you mean the new shapes do not redraw on the map

or

the actuall map tiles are not being redrawn?
Sep 19, 2008 at 4:20 PM
When the application starts, shapes (such as points and polygons) are added to shapelayers, the shapelayers are added to the map.

During use of the application, the user can open a tree control which allows the user to select which shapelayers to turn on and off; selected shapelayers are stored in a "session" variable.  The tree control is in a class called FileBrowser.cs 

When the user closes the tree, FileBrowser.cs creates a new instance of DeepEarthPrototype.Page by the following:

DeepEarthPrototype.Page pPage = new DeepEarthPrototype.Page("FILEBROWSER");

Program control is thus passed back Page.xaml.cs and the logic in Page.xaml.cs is again executed.  This time the layers to be drawn are only those selected by the user.  I've used a variety of methods to try to remove shapelayers that had been previously drawn but no longer should be, such as:

ShapeLayer

pLayer = getShapelayer(s.mapID.ToUpper());    //where getShapelayer returns the current shapelayer to be removed

map.Layers.Remove(pLayer);

 

//pLayer.List.Clear();

 

 

//pLayer.IsVisible = false;

None of these work, there are no errors, it's just that the shapelayers to be turned off are still visible.  So I think I have a logic problem here.  Suggestions on how to remove some of the shapelayers from map which previously had them displayed.  Perhaps the real issue is how I'm calling Page.xaml.cs functions from FileBrowser.cs.

Thanks......

 

Developer
Sep 19, 2008 at 11:36 PM
this works for me...

I made the project, addeds a layer onload as discribed in previous post,
then I added 2 buttons which both add a new shapelayer and pushpin in different positions

if I make the button events like below, it clears all the previous shape layers and the ands the new one

   80         private void AddShapes_1_Click(object sender, RoutedEventArgs e)

   81         {

   82             foreach (ShapeLayer sl in map.Layers)

   83             {

   84                 sl.List.Clear();

   85             }

   86 

   87             //Sample Polygon added to the map

   88             if (shapeLayer == null)

   89             {

   90                 shapeLayer = new ShapeLayer { ID = "SHAPES_1" };

   91                 map.Layers.Add(shapeLayer);

   92             }

   93 

   94             Pushpin pin = new Pushpin();

   95             pin.Point = new Point(25, 25);

   96             shapeLayer.List.Add(pin);

   97         }

<!--EndFragment-->
Developer
Sep 19, 2008 at 11:47 PM
Edited Sep 19, 2008 at 11:49 PM
or this also works...  but note after the "map.Layers.Remove(...);"
method call I also set the "shapeLayer" back to "null" so when I go to add the that layer again after I have removed it I do not get a error, becuase the layer is now removed from the list and I would be trying to add a shape to a layer that is no longer in the list...

   80         private void AddShapes_1_Click(object sender, RoutedEventArgs e)

   81         {

   82             map.Layers.Remove("SHAPES_2");

   83             shapeLayer = null;

   84 

   85             //Sample Polygon added to the map

   86             if (shapeLayer== null)

   87             {

   88                 shapeLayer = new ShapeLayer { ID = "SHAPES_1" };

   89                 map.Layers.Add(shapeLayer);

   90             }

   91 

   92             Pushpin pin = new Pushpin();

   93             pin.Point = new Point(25, 25);

   94             shapeLayer.List.Add(pin);

   95         }

   96 

   97         private void AddShapes_2_Click(object sender, RoutedEventArgs e)

   98         {

   99            map.Layers.Remove("SHAPES_1");

  100            shapeLayer = null;

  101 

  102             //Sample Polygon added to the map

  103             if (shapeLayer == null)

  104             {

  105                 shapeLayer = new ShapeLayer { ID = "SHAPES_2" };

  106                 map.Layers.Add(shapeLayer);

  107             }

  108 

  109             Pushpin pin = new Pushpin();

  110             pin.Point = new Point(50, 50);

  111             shapeLayer.List.Add(pin);

  112         }

<!--EndFragment-->
Sep 24, 2008 at 7:35 PM
Ok, got this resolved.  Had to create an event handler within FileBrowser.xaml (my control) that Page.xaml.cs recognized.  Thanks for the suggestions dotnetnoobie
Jun 14, 2011 at 3:26 PM

Hello everyone,

I have some checkbox, that add or delete shapes over a map. The problem is that at this moment I obtain that result only if the user makes zoom into the map.


My second problem is the next one: I delete a shape and make zoom into the map, but when I back to the zoom before, the shapes appears again.


Have you found any solution for your question? I would like to refresh the map when the user clicks on a checkbox.