I have set up a page with a shape file overlaying the Google Map, just like the "ShapeFileOverGoogleMap" sample. I would now like to be able to "turn off" the Google Map, leaving only the shape file showing. I want to do this via a check box and a postback, as opposed to the layer switcher like the "BaseLayerChangedEvent" sample does. I thought that the IsVisible property of the GoogleOverlay or CustomOverlays classes might do the trick, but it doesn't seem to work. Any suggestions?
Thanks in advance!
Tom
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));
Map1.CurrentExtent = new RectangleShape(-19200000, 14000000, 19700000, -10500000);
Map1.MapUnit = GeographyUnit.Meter;
Map1.MapTools.MouseCoordinate.Enabled = true;
GoogleOverlay googleOverlay = new GoogleOverlay("Google Map");
googleOverlay.JavaScriptLibraryUri = new Uri("maps.google.com/maps?file=api&v=2&key=ABQIAAAAoxK_HcqphMsnUQHEwLwHlRSavkNJi0NVTgm4UDidoiIU5dUJpRQW88FufPCp0aTPraxZgZFAIUHn3Q");
googleOverlay.GoogleMapType = GoogleMapType.Normal;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/App_Data/cntry02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.SimpleColors.Black, 1);
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
worldLayer.FeatureSource.Projection = proj4;
Map1.DynamicOverlay.Layers.Add(worldLayer);
Map1.CustomOverlays.Add(googleOverlay);
}
}
protected void cbShowGoogleMap_CheckedChanged(object sender, EventArgs e)
{
if (!cbShowGoogleMap.Checked)
{
// this doesn't seem to work...
GoogleOverlay googleOverlay = (GoogleOverlay)Map1.CustomOverlays.First();
googleOverlay.IsVisible = false;
// this doesn't seem to work either...
Map1.CustomOverlays["Google Map"].IsVisible = false;
}
else
{
// turn it back on...
}
}
}