Hi,
I have an application where I need to colorize the map based on zip code... I was able to make it to work but!!!!
The time required to draw the map is terrible................................
of course the number of zip is very high.......
help required! Thanks in advance.
jm.
this is the code:
private void SHOW_REP_TERRITORY()
{
StringBuilder sb = new StringBuilder();
layerOverlay = (LayerOverlay)Map1.CustomOverlays["layerOverlay"];
#region Load reps geography
_rep = (Dictionary<string, string>)Application["REPPERZIP"];
_reps = (List<string>)Application["REPS"];
#endregion
try
{
layerOverlay.Layers.Remove("shp_zip5");
}
catch (System.Exception ex)
{ }
try
{
Map1.CustomOverlays.Remove("inMemoryMarkerOverlay_rep_zip");
}
catch (System.Exception ex)
{ }
Collection<GeoColor> colorsInHueFamily = GeoColor.GetColorsInHueFamily(GeoColor.FromArgb(70, GeoColor.SimpleColors.Red), _reps.Count);
Collection<GeoColor> colorsInQualityFamily = GeoColor.GetColorsInQualityFamily(GeoColor.FromArgb(50, GeoColor.SimpleColors.Red), _reps.Count);
ValueStyle valueStyleRep = new ValueStyle();
valueStyleRep.ColumnName = "SALEREP";
int colorIx = 0;
foreach (string s in _reps)
{
valueStyleRep.ValueItems.Add(new ValueItem(s, new AreaStyle(new GeoSolidBrush(colorsInQualityFamily[colorIx++]))));
}
shp_zip5 = (ShapeFileFeatureLayer)Application["ZIP5"];
shp_zip5.IsVisible = true;
shp_zip5.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
shp_zip5.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyleRep);
shp_zip5.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("SALEREP");
shp_zip5.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10;
shp_zip5.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);
layerOverlay.Layers.Add("shp_zip5", shp_zip5);
sb.Clear();
sb.Append("<tr>Name:[#SALEREP#]</tr>");
sb.Append("<tr>Zip :[#SALEREPZIP#]</tr>");
inMemoryMarkerOverlay_rep_zip = new InMemoryMarkerOverlay("inMemoryMarkerOverlay_rep_zip");
inMemoryMarkerOverlay_rep_zip.Name = "inMemoryMarkerOverlay_rep_zip";
inMemoryMarkerOverlay_rep_zip.FeatureSource.Open();
inMemoryMarkerOverlay_rep_zip.Columns.Add(new FeatureSourceColumn("SALEREP"));
inMemoryMarkerOverlay_rep_zip.Columns.Add(new FeatureSourceColumn("SALEREPZIP"));
inMemoryMarkerOverlay_rep_zip.FeatureSource.Close();
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.ContentHtml = new HtmlString(sb.ToString()).ToHtmlString();
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.AutoPan = false;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.AutoSize = false;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.Height = 32;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.Width = 200;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.BackgroundColor = GeoColor.StandardColors.LightBlue;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.BorderColor = GeoColor.StandardColors.DarkBlue;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.Popup.BorderWidth = 2;
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.WebImage = new WebImage("../../Img/person_generic.png", 24, 24);
inMemoryMarkerOverlay_rep_zip.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryMarkerOverlay_rep_zip.FeatureSource.Open();
foreach (Feature f in (Collection<Feature>)Application["CENTERZIP5"])
{
if (_rep.ContainsKey(f.ColumnValues["ZCTA5CE10"]))
{
string xx = _rep[f.ColumnValues["ZCTA5CE10"]];
if (f.ColumnValues.ContainsKey("SALEREP"))
f.ColumnValues["SALEREP"] = xx;
else
f.ColumnValues.Add("SALEREP", xx);
if (f.ColumnValues.ContainsKey("SALEREPZIP"))
f.ColumnValues["SALEREPZIP"] = f.ColumnValues["ZCTA5CE10"].ToString();
else
f.ColumnValues.Add("SALEREPZIP", f.ColumnValues["ZCTA5CE10"].ToString());
}
inMemoryMarkerOverlay_rep_zip.Features.Add(f.Id, f);
}
inMemoryMarkerOverlay_rep_zip.FeatureSource.Close();
Map1.CustomOverlays.Add(inMemoryMarkerOverlay_rep_zip);
}