first of all i am adding basic staticoverlay layers on page load events. and some of staticoverlay i wants to add on checkbox select event and here is my checkbox selectedevent code is:
if (cbProvince.Checked)
{
ShapeFileFeatureLayer province = new ShapeFileFeatureLayer(MapPath("~/Layer/afghanistanprovince.shp"));
// province.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
province.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("Prov_Name", new GeoFont("Verdana", 9),
new GeoSolidBrush(GeoColor.StandardColors.Blue));
province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.State1;
province.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);
province.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.StaticOverlay.Layers.Add(province);
// Map1.ZoomIn();
}
else
{
Map1.StaticOverlay.Layers.Remove( Map1.StaticOverlay.Layers.FirstOrDefault(x => x.Name == "province")) ;
Map1.StaticOverlay.Layers.Clear();
//Map1.ZoomOut();
}
but issue that i am getting is map is not working correctly when i checked my checkbox and after that when i zoomin layer is showing but when i uncheck my checkbox my province layer is still add in my map i dont know is this is a bug or my code fault but i clear layers as you can see in my code. also my page load code is closed in If (!ispostback) condition so tell me what is the issue is this is a bug or what?
issue raised with zoom in and zoom out .
Add staticoverlay layers on checkboxlist
Hi Raja,
Please call Redraw function, as below is my test code which works.
if (cbProvince.Checked)
{
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.StaticOverlay.Layers.Add("worldLayer", worldLayer);
}
else
{
Map1.StaticOverlay.Layers.Clear();
}
Map1.StaticOverlay.Redraw(); // Please redraw overlay when you add or remove layer
Regards,
Don
hi Don
that is very kind and yes it is helpful
but i am wonder if i only wants to clear one particular staticOverlay clear how can i do that i mean i only wants to clear province layer not world and capitallayer how can i do that . this piece of code clear my all layers Map1.StaticOverlay.Layers.Clear(); but i wants to clear only one layer. is there is a any function that can i used thanks.
Hi Raja,
You can add layer by key and remove it by key.
Map1.StaticOverlay.Layers.Add("key", Layer);
Map1.StaticOverlay.Layers.Remove("key");
Regards,
Don
hi don
thanks for your reply its working fine but i have one more issue with AreaStyle.
i have province ,district and city layers which i add with different areastyle color like this.
province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(GeoPens.Blue);
and district
District.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(GeoPens.Brown);
and city
District.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(GeoPens.Red);
but issue is it always remember last selected checkbox color for example
if i first select province. it show fine province blue color
but again if i select district it do province and district with same color Brown
and if i select city all province district and city become RED.
please tell me about transparent color of boundaries of layers
basically at the end province district layers are at same line i wants to transparent layers with minor different distance in border line please tell is there is any way to do this.
Hi Raja,
You can set the alpha value of color for make the area transparent like this:
province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Blue)));
district.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(100, GeoColor.StandardColors.Brown)));
city.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(100, GeoColor.SimpleColors.Red)));
Please modify the value between 0 ~ 255 follow your requirement.
Regards,
Don
Hi Don
i have another question related to my shapefile border colors can i change shapefile border color at run time i mean color change of shapefile at run time when a user select color its take as input color and change color of shapefile please tell me
and thanks for your help.
Hi Raja,
I think you can modify the style run time, don’t forget fresh map after you modify it.
Regards,
Don