ThinkGeo.com    |     Documentation    |     Premium Support

Problems with the visualization of all the points of interest with markers and popups

When I load the map , it  delays,  when I visualize it and on having done 2 or 3 zoom fails (it remains hung) and I do not visualize all the markers of the points of interest


my code:



If



 (Not Page.IsPostBack) Then

Map1.BackgroundFillBrush =


New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))

Map1.MapUnit = GeographyUnit.DecimalDegree



 


mapazaragozaa0 =


mapazaragozaa0.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.GetSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1)


mapazaragozaa0.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


Dim mapazaragozaa0 As ShapeFileLayerNew ShapeFileLayer("C:\ZaragozaAtlas\espes2________a0.shp")

Dim


SetCityMarkers(markerLayer.ZoomLevelSet.ZoomLevel04.Markers)


markerLayer.ZoomLevelSet.ZoomLevel04.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05


 markerLayer As MarkerLayer = New MarkerLayer("DefaultMarkers", GetFeatureSource())

Map1.StaticLayers.Add(


Map1.MarkerLayers.Add(markerLayer)


"MapaZaragozaA0", mapazaragozaa0)

Dim


Map1.ZoomToScale(1000000)


 


Map1.ScaleLine.Enabled =


 zoomLevelSet As ZoomLevelSet = New ZoomLevelSet()True

Map1.PanZoomBar.Enabled =


True

Map1.MousePosition.Enabled =


True

Map1.Overview.Enabled =


True

End If


 


Private


 


 


citiesLayer.Open()


featureSource = citiesLayer.FeatureSource


citiesLayer.Close()


 


 


 Function GetFeatureSource() As FeatureSourceDim featureSource As FeatureSourceDim citiesLayer As ShapeFileLayer = New ShapeFileLayer("C:\ZaragozaAtlas\espes2________pi.shp")Return featureSourceEnd Function

 


 


 


 


featureSource.Open()


 


featureSource.Close()


 


 


 


 


marker.Popup.ContentHtml =


marker.Popup.Width = 160


marker.Popup.Height = 40


markers.Add(marker)


 


 


Private Sub SetCityMarkers(ByVal markers As GeoKeyedCollection(Of Marker))Dim icon As WebImage = New WebImage("C:\ThinkGeo_VB\theme\default\samplepic\circle.png")Dim layer As ShapeFileLayer = New ShapeFileLayer("C:\ZaragozaAtlas\espes2________pi.shp")Dim featureSource As FeatureSource = layer.FeatureSourceDim features As Collection(Of Feature) = featureSource.GetAllFeatures(New String() {"NAME", "STNAME"})For Each feature As Feature In featuresDim position As PointShape = CType(feature.GetShape(), PointShape)Dim marker As Marker = New Marker(position, icon)Dim cityInfomation As String = String.Format("{0} esta en la {1} thousand people.", feature.ColumnValues("NAME"), feature.ColumnValues("STNAME"))String.Format("{0}", cityInfomation)Next featureEnd Sub

I wait your support with this problem



 



Alan,


 
I did some changes to your code and made a demo similar to your app and it runs well. Please have a look at the attached sample. I also included a snapshot of the demo, when you zoom in or zoom out a bit, you can see the markers disappear.
 
There are 2 problems in your code, first is that you added the featureSource to both MarkerLayer and MarkerLayer.ZoomLevelSet.ZoomLevel04, if you only want to show markers in certain zoomLevel, you do not need to add the featureSource to the whole marker layer. Second, the code Map1.ZoomToScale(1000000) zoom in too far, I changed the scale so you can see the markers when you open the page at the first time.
 
By the way, please make sure you are using the latest public release (Web Edition 3.0.2, MapSuiteCore 3.0.2, NetTopologySuite 1.7.1.2781).
 
Ben.

60-pointsOfInterestForAlan.JPG (40.8 KB)
61-pointsOfInterestForAlan.zip (111 KB)

Good Ben the changes that you did in the code, me did not work, I did a few changes and it shows me the points.


This one is my code, if someone needs it:


It shows points according to the condition



    Map1.MarkerLayers.Remove("Puntos")
        Dim icon As WebImage = New WebImage(MapPath("~/themes/default/img/marker.gif"))
        icon.ImageHeight = 12
        icon.ImageWidth = 12

        Dim layer As ShapeFileLayer = New ShapeFileLayer(MapPath("~/DATA/espes2________pi.shp"))

        layer.Open()
        Dim features As Collection(Of Feature) = layer.QueryTools.GetAllFeatures(New String() {"NAME", "STNAME", "HTTP", "FEATTYP"})

        Dim puntos As New MarkerLayer("Puntos")

        For Each feature As Feature In features
            If feature.ColumnValues("FEATTYP") = "7397" Then
                Dim position As PointShape = CType(feature.GetShape(), PointShape)
                Dim marker As Marker = New Marker(position, icon)
                Dim cityInfomation As String = String.Format("Nombre: {0} Direccion: {1} Web: visita su pagina", feature.ColumnValues("NAME"), feature.ColumnValues("STNAME"), feature.ColumnValues("HTTP"))
                marker.Popup.ContentHtml = String.Format("{0}", cityInfomation)
                marker.Popup.Width = 160
                marker.Popup.Height = 120
                marker.Popup.HasCloseButton = True
                puntos.Markers.Add(marker)
            End If
        Next feature
        puntos.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

        Map1.MarkerLayers.Add(puntos)


Thanks very much for sharing your code.  Alan.

I did some modification for your code just to make it look nicer. Also to post codes directly in forum, here is a trick which can make your codes much nicer. 

 


Ben