How to Add and Remove a overlay or overlays?

Mar 16, 2009 at 1:45 AM
Edited Mar 16, 2009 at 2:28 AM
First,I define a baselayer,"this.map.BaseLayer.Source =new OamTileSource(OamMapModes.OAM);" It works fine as you know.

Then click a button ,I want to add a overlay(Tile Source),"baseLayer.Overlays.Add(osmTileSource)".But it dosenot display unless I zoom in the map.Why? When I zoom out it, the new overlay will disappear. I'm confused.

Third, I want to remove a overlay if it exits,"baseLayer.Overlays.Remove(osmTileSource)". It must be zoomed in, you will see the overlay is removed. However, if zoom out after removing, the map display nothing,that is the baselayer.resource disappear as well.

I tried  it again and again, but unfortunately I losed every time. How can I make it? Help me. Thanks in advance.

Another way:Instead of adding Overlays, I add/remove a TileLayer ,but it also not works correctly.PS,the newest version.
Developer
Mar 16, 2009 at 2:45 AM
use "map.RefreshSource();"


        void AddButton_Click(object sender, RoutedEventArgs e)
        {
            map.BaseLayer.Overlays.Add(overlay);
            map.RefreshSource();
        }
 
        void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            map.BaseLayer.Overlays.Remove(overlay);
            map.RefreshSource();
        }
Mar 16, 2009 at 3:05 AM
How easy it is. But I didn't know it unexpectedly. Thank you.
Jun 13, 2011 at 12:35 PM

 

Hello everyone,
I'm developing a client-server platform. I use DeepEarth to build my client. 


At first I define a baselayer: "MyMap.BaseLayer.Source = new GoogleTileSource(GoogleMapModes.Satellite);" "MyMap" is an instance of "DeepEarth.Client.MapControl", it was declared at "MainPage.xaml".


When I press a button, an event is generated and invokes to:

public void mostrarShape(string layer)

{           

_capa = new WmsTileSource(WmsMapModes.WMS_superpuesto, "server", layer, "image/png", "EPSG:4326");                       

MyMap.BaseLayer.Overlays.Add(_capa);           

MyMap.RefreshSource();       

}

But it doesn't work. I get the same error than LionGG:

1) It doesn't display unless I zoom in the map;

2) When I zoom out it, the new overlay will disappear;

3) It must be zoomed in, you will see the overlay is removed. However, if zoom out after removing, the map displays again the removed layer.


You can see that I use " MyMap.RefreshSource();" but it also not works correctly.
Could you tell me some advice?

Thanks in advance,

Mario