Hi Troy , thank you very much for the reply. You are correct it seems the event is triggered by both Map1.StaticOverlay.Layers.Add() and Map1.Customoverlays.Add() so that is not the problem. However i am still unable to filter the features that are displayed on the map.
Dim ddlvalue As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ddlvalue = “2-Good”
Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))
Map1.CurrentExtent = New RectangleShape(-140, 60, 140, -60)
Map1.MapUnit = GeographyUnit.DecimalDegree
Dim worldMapKitOverlay As New WorldMapKitWmsWebOverlay()
Map1.CustomOverlays.Add(worldMapKitOverlay)
’ The following two lines of code enable the client and server caching.
’ If you enable these features it will greatly increase the scalability of your
’ mapping application however there some side effects that may be counter intuitive.
’ Please read the white paper on web caching or the documentation regarding these methods.
’ Map1.StaticOverlay.ClientCache.CacheId = “WorldOverlay”
’ Map1.StaticOverlay.ServerCache.CacheDirectory = MapPath("~/ImageCache/" + Request.Path)
Dim worldLayer As New ShapeFileFeatureLayer(MapPath("~\SampleData\World\20140527_Amajuba_PT_Routes_rev7.shp"))
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen.Color = GeoColor.StandardColors.Black
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add(“Surface_Co”)
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
AddHandler worldLayer.DrawingFeatures, AddressOf worldLayer_DrawingFeatures
Dim staticOverlay As New LayerOverlay(“StaticOverlay”)
staticOverlay.IsBaseOverlay = False
staticOverlay.Layers.Add(“WorldLayer”, worldLayer)
Map1.CustomOverlays.Add(staticOverlay)
End If
End Sub
Private Sub worldLayer_DrawingFeatures(ByVal sender As Object, ByVal e As DrawingFeaturesEventArgs)
Dim featuresToDrawn As New Collection(Of Feature)()
For Each feature As Feature In e.FeaturesToDraw
Dim population As String = Convert.ToString(feature.ColumnValues(“Surface_Co”))
If population = ddlvalue Then
featuresToDrawn.Add(feature)
End If
Next
e.FeaturesToDraw.Clear()
For Each feature As Feature In featuresToDrawn
e.FeaturesToDraw.Add(feature)
Next
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Map1.CustomOverlays.RemoveAt(1)
ddlvalue = “3-Fair”
Dim worldLayer As New ShapeFileFeatureLayer(MapPath("~\SampleData\World\20140527_Amajuba_PT_Routes_rev7.shp"))
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1)
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add(“Surface_Co”)
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
AddHandler worldLayer.DrawingFeatures, AddressOf worldLayer_DrawingFeatures
'Map1.StaticOverlay.Layers.Add(worldLayer)
Dim staticOverlay As New LayerOverlay(“StaticOverlay”)
staticOverlay.IsBaseOverlay = False
staticOverlay.Layers.Add(“WorldLayer”, worldLayer)
Map1.CustomOverlays.Add(staticOverlay)
End Sub
At this point I am just simulating the dropdownlist value with a button click but the effect should be the same. As it stands the map load the layer geometry on the first page load but fails to filter the features that are selected when the button is clicked.
Any help would be greatly appreciated . Thanks