Below is sample code. the SAmapInitialize method is called from the pageload event.
After we have some information about the user, based on login, the state we are looking at, the SAmapReset method is called via Callback.
after some other client information is generated, a zip code list, SAmapUpdate is called via Callback.
The problem is that PSA and TSA overlays do not zoom with the rest of the map.
I have a deployed web application so you can see what I am talking about, but I don’t want to post the username and password here.
public static void SAmapInitialize(ref Map map)
{
map.MapUnit = GeographyUnit.DecimalDegree;
map.CurrentExtent = new RectangleShape(-121.5, 40.5, -120.5, 39.5);
LayerOverlay ZipBordersOverlay = new LayerOverlay(“ZipBorderOverlay”);
ZipBordersOverlay.IsBaseOverlay = false;
ZipBordersOverlay.Layers.Clear();
ZipBordersOverlay.Layers.Add(GetStateLayer(statepath, “zip”));
map.StaticOverlay.Layers.Clear();
map.CustomOverlays.Add(ZipBordersOverlay);
map.CustomOverlays.Add(GetHighwaysOverlay(""));
map.CustomOverlays.Add(zipSAoverlay("", “PSA”, “”));
map.CustomOverlays.Add(zipSAoverlay("", “TSA”, “”));
}
public static void SAmapReset(ref Map map, string statepath)
{
map.StaticOverlay.Layers.Clear();
map.CustomOverlays.Clear();
map.StaticOverlay.Layers.Add(GetStateLayer(statepath, “base”));
LayerOverlay ZipBordersOverlay = new LayerOverlay(“ZipBorderOverlay”);
ZipBordersOverlay.IsBaseOverlay = false;
ZipBordersOverlay.Layers.Clear();
ZipBordersOverlay.Layers.Add(GetStateLayer(statepath, “zip”));
ZipBordersOverlay.IsVisible = true;
ZipBordersOverlay.Layers[0].IsVisible = true;
map.CustomOverlays.Add(ZipBordersOverlay);
map.CustomOverlays.Add(GetHighwaysOverlay(statepath));
//map.CustomOverlays.Add();
//map.CustomOverlays.Add();
}
public static void SAmapUpdate(ref Map map, string statepath, string tsalist, string psalist)
{
map.CustomOverlays.Remove(“PSA”);
map.CustomOverlays.Remove(“TSA”);
map.CustomOverlays.Add(zipSAoverlay(psalist, “PSA”, statepath));
map.CustomOverlays.Add(zipSAoverlay(tsalist, “TSA”, statepath));
}
public static Layer GetStateLayer(string statepath, string type)
{
ShapeFileFeatureLayer stateLayer = new ShapeFileFeatureLayer(statepath + @"\zips\zips.shp");
if (type == “base”) {
stateLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGray, GeoColor.StandardColors.LightGray);
}
if (type == “zip”) {
stateLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.StandardColors.White);
}
//stateLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightGray, GeoColor.StandardColors.LightGray);
stateLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
return stateLayer;
}
public static LayerOverlay GetZipBorderOverlay(string statepath)
{
ShapeFileFeatureLayer ZipBorderLayer = new ShapeFileFeatureLayer();
if (statepath != “”) { ZipBorderLayer = new ShapeFileFeatureLayer(statepath + @“zips\zips.shp”); }
ZipBorderLayer.Name = “ZipBorderLayer”;
AreaStyle BaseStyle = new AreaStyle();
BaseStyle.OutlinePen.Color = GeoColor.StandardColors.White;
ZipBorderLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = BaseStyle;
ZipBorderLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay ZipBorderOverlay = new LayerOverlay(“ZipBorderOverlay”);
ZipBorderOverlay.Layers.Add(ZipBorderLayer);
return ZipBorderOverlay;
}
public static LayerOverlay GetHighwaysOverlay(string statepath)
{
ShapeFileFeatureLayer highwayslayer = new ShapeFileFeatureLayer();
if (statepath != “”) { highwayslayer = new ShapeFileFeatureLayer(@“C:\Map_Data\US\highways\in101503.shp”); }
LayerOverlay HighwayOverlay = new LayerOverlay(“HighwaysOverlay”);
HighwayOverlay.IsBaseOverlay = false;
highwayslayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 2, false);
highwayslayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Highway5(“ROUTE”);
highwayslayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//ShapeFileFeatureLayer labellayer = new ShapeFileFeatureLayer(@“C:\Map_Data\CA\labels\labels.shp”);
//ShapeFileFeatureLayer labellayer = new ShapeFileFeatureLayer(statepath + @“labels\labels.shp”);
//labellayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City3(“NAME”);
//labellayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
HighwayOverlay.Layers.Add(highwayslayer);
//HighwayOverlay.Layers.Add(labellayer);
return HighwayOverlay;
}
public static LayerOverlay zipSAoverlay (string ziplist, string sa, string statepath)
{
string[] zipArray = ziplist.Split(’,’);
ShapeFileFeatureLayer shapefilelayer = new ShapeFileFeatureLayer();
InMemoryFeatureLayer zipLayer = new InMemoryFeatureLayer();
if (statepath != “”)
{
shapefilelayer = new ShapeFileFeatureLayer(statepath + @“zips\zips.shp”);
shapefilelayer.Open();
foreach (string zip in zipArray)
{
zipLayer.InternalFeatures.Add(shapefilelayer.QueryTools.GetFeaturesByColumnValue(“ZCTA5CE10”, zip)[0]);
}
shapefilelayer.Close();
}
if (sa == “TSA”) { zipLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.LightBlue); }
else { zipLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.LightRed); }
zipLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay SAoverlay = new LayerOverlay(sa);
SAoverlay.Layers.Add(zipLayer);
return SAoverlay;
}