ThinkGeo.com    |     Documentation    |     Premium Support

Problems with markers

I want to add markers in my points of interest on having touched the button, and it shows me the blue visor.


When I load the examples also it shows me the blue visor.


this is my code:


 



      Dim PointLayer As New ShapeFileFeatureLayer(MapPath("~\Capas\espes2________pi.shp"))
      Dim markers As New InMemoryMarkerOverlay()
      markers.IsBaseOverlay = False
      markers.Name = "Puntos"
      markers.ZoomLevelSet.ZoomLevel10.DefaultMarkerStyle.WebImage = New WebImage("../imagenes/marker_green.gif", 21, 25)

      Dim feats As New Collection(Of Feature)

      PointLayer.Open()
      feats = PointLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns)
      PointLayer.Close()

      For Each feat As Feature In feats
            If feat.ColumnValues("FEATTYP") = "7324" Then
                  markers.Features.Add(feat.Id, feat)
            End If
      Next
      Map1.CustomOverlays.Add(markers)
      PointLayer.RequireIndex = False


Alan, 


I modified your message to make your codes looks better. Please ref the link here to see how to make your codes nice in the post.
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/4941/afv/topic/Default.aspx
 
As your marker overlay is only available within one zoomLevel, there is great chance that the current zoomlevel is not within ZoomLevel10 and so you cannot see the markers, also if you didn’t set any base overlay, you can only see the default blue background.  I think that’s your case. Just wonder did you forget to set the ApplyUntilZoomLevel for ZoomLevel10, as most of time we don’t want to show markers only at one ZoomLevel. 
 
      markers.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
Also here is a sample which we just copy your code and change to our data, and it works fine. Have a look if you are interested.
 
Let us know for any queries.
 
Ben

279-Post5079.zip (105 KB)

Good Ben, even continues the fault, loads the map of google but it does not show me the markers when I pulsate in the button, it show me blue screen.

I have windows vista with ie7 and also fiefox 3.0.5 but shows me the same thing
 


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

            Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))
            Map1.CurrentExtent = New RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962)
            'Map1.CurrentExtent = New RectangleShape(-114.34, 75.27, 108.79, -70.23)
            Map1.MapUnit = GeographyUnit.Meter

            Map1.MapTools.OverlaySwitcher.Enabled = True
            Map1.MapTools.MouseCoordinate.Enabled = True
            Map1.MapTools.LoadingImage.Enabled = True
            Map1.MapTools.ScaleLine.Enabled = True

            Dim google As New GoogleOverlay(“Google Map”)
            google.JavaScriptLibraryUri = New Uri(“maps.google.com/maps?file=api&v=2&key=ABQIAAAAoxK_HcqphMsnUQHEwLwHlRSavkNJi0NVTgm4UDidoiIU5dUJpRQW88FufPCp0aTPraxZgZFAIUHn3Q”)
            google.GoogleMapType = GoogleMapType.Normal

            ’ We create a new Layer and pass the path to a Shapefile into its constructor.
            Dim PointLayer As New ShapeFileFeatureLayer(MapPath("~/Capas/espes2________pi.shp"))
            PointLayer.RequireIndex = False
            PointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = EstPi(4, 1)
            PointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10
            PointLayer.ZoomLevelSet.ZoomLevel11.DefaultPointStyle = EstPi(7, 1)
            PointLayer.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
            'PointLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
            'PointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            PointLayer.ZoomLevelSet.ZoomLevel11.DefaultTextStyle = TextStyles.Capital3(“NAME”)
            PointLayer.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            Dim proj4 As New Proj4Projection()
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326)
            proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
            PointLayer.FeatureSource.Projection = proj4

            Dim shapeOverlay As New LayerOverlay(“Shape Overlay”, False, TileType.SingleTile)
            shapeOverlay.Layers.Add(PointLayer)
            shapeOverlay.TransitionEffect = TransitionEffect.None


            Map1.CustomOverlays.Add(google)
            Map1.CustomOverlays.Add(shapeOverlay)


            ’ We need to add the world layer to map’s Static Overlay.
            'Map1.StaticOverlay.Layers.Add(“PointLayer”, PointLayer)
            PointLayer.Open()
            Map1.HighlightOverlay.Style = New HighlightOverlayStyle()
            Map1.HighlightOverlay.HoverStyle = New HighlightOverlayStyle(GeoColor.FromArgb(120,  GeoColor.StandardColors.OrangeRed), GeoColor.StandardColors.DarkGreen, 1)

            For Each feature As Feature In PointLayer.FeatureSource.GetAllFeatures(New String() {})

                Map1.HighlightOverlay.Features.Add(feature.Id, feature)

            Next

            ’ AddHandler Map1.HighlightOverlay.Click, AddressOf EventLayer_Click
            ’ Add ContextMenu to EventLayer  


            PointLayer.Open()
            Map1.CurrentExtent = PointLayer.GetBoundingBox()
            PointLayer.Close()

        End If

    End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Dim PointLayer As New ShapeFileFeatureLayer(MapPath("~\Capas\espes2________pi.shp"))
        PointLayer.RequireIndex = False

        Dim markers As New InMemoryMarkerOverlay()
        markers.IsBaseOverlay = False
        markers.Name = “Hoteles”
        markers.ZoomLevelSet.ZoomLevel11.DefaultMarkerStyle.WebImage = New WebImage("~/imagenes/marker.gif", 21, 25)



        Dim feats As New Collection(Of Feature)

        PointLayer.Open()
        feats = PointLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns)
        PointLayer.Close()

        For Each feat As Feature In feats
            If feat.ColumnValues(“FEATTYP”) = “7324” Then

                markers.Features.Add(feat.Id, feat)


            End If
        Next
        markers.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
        Map1.CustomOverlays.Add(markers)



    End Sub



Alan,


I saw from your code that GoogleOverlay and PointOverlay are both set to BaseOverlay, that's the main reason of the problem. In our map control, only one BaseOverlay can be shown on the map at a time. Please add the following line to your page_load method to make the PointOverlay a Non-Base Overlay.


  shapeOverlay.IsBaseOverlay = False


Also, GoogleOverlay's unit is meter however the features added in the MarkerOverlay are in decimal degree, you need to convert it to the same unit with the following code.


 



Dim PointLayer As New ShapeFileFeatureLayer(MapPath("~\app_data\cities_a.shp"))
Dim proj4 As New Proj4Projection()
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326)
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
PointLayer.FeatureSource.Projection = proj4

PointLayer.Open()
feats = PointLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns)
PointLayer.Close()

For Each feat As Feature In feats
If feat.ColumnValues("CLASS") = "city" Then
    markers.Features.Add(feat.Id, feat)
End If
Next

Here attached is the sample which we copy your code and do a little changes, and it works fine.
 
Let me know for any queries.
 
Ben

281-Post5079_2.zip (105 KB)

I change the code: Loading the map but when I press the button to load the blue screen. 

I use IE 7 and Mozilla 3.0.5 and the two browsers shows the same error.

Alan, 
  
 I am wondering does the attached sample (Post5079_2.zip) in the previous message work fine on your machine. If yes, can you let me know what changes you make that leads to the blue screen? One place need to check is that if the map’s height/width are set to 100%, please set all the map’s parents’ height to 100% also, otherwise the map might not be proper displayed. 
  
 It will be great if you can send us some sample so we can debug here. 
  
 Thanks, 
  
 Ben 


The attached example (Post5079_2.zip) shows me also blue screen.


I  attach my project and the screens.


Mapa.jpg ( loads of map) and bluescreen.jpg (when I press the button)


Project : WebVBGoogle.zip


ShapeFiles: Capas.zip



286-WebVBGoogle.zip (130 KB)
287-Capas.zip (192 KB)

Alan,


Your samples works great on my machine ( Windows XP with 3.0.131 assemblies).  Can you make sure you are using the latest assembly (3.0.131). Also if you still have problem, can you let us know what system you are using within?


Here is the snapshot.


Thanks,


Ben




Ben to my also loads the map with the points, but on having pressed the button does not show me the markers, shows me blue screen.


I' m using windows Vista and with 3.0.131 assemblies


On having pressed the button does it show you the markers?



Alan,


Yes, we can show markers fine.  We will test it under Vista and let you know the result. Also is there anything you think might bring this problem, please let me know.



Thanks,


Ben.


 



Alan, 



We tested under Vista and it works fine too. I have no idea why it goes wrong on your machine. To make sure, can you double check your assembly version with the following codes to see if it is "MapSuiteCore:3.0.131;WebEdition:3.0.131"? Also are you using VS 2008 with SP1? 

 


Response.Write(ThinkGeo.MapSuite.WebEdition.Map.Version);


Please let me know anything that might bring this problem you think. 



Thanks, 



Ben



Ben


I reinstalled Map Suite Web beta 2 in Windows Vista , but i show me the same problem


In Win XP also it(he,she) shows me the same problem..


the blue screen continues appearing when I press the button and want that shows me the markers.


I use VS 2008 SP1 in XP  and Vista


 


 



Alan, 
  
 Seems your environment is right. Can you try the following steps to find the reason out? 
   
 In the Button1_Click event, you create a point based shape file, project it, get all the features out and put some of them to a marker overlay. So we can  
 1, Comment the projection part out and see if there is still a blue screen. If not any more, that means something wrong with the projection and please make the proj4 object a module variable so create it only once, and see if that solves the problem.  
  
 2, if the blue screen is still there, try to comment out the PointLayer. Instead of getting all the features from a shape file, just create some of them yourself and add them to the feature collection “feats”. It has a little chance that the memory consumes too much when calling GetAllFeatures method, which might lead to some problem. If that’s your case, please try the method PointLayer.ExecuteSqlQuery(…) 
 to get only the features you need.  
  
 3, if the blue screen is still not gone, keep commenting out the rest of codes and see what the last straw is. We do not have too much chance to get here as we don’t do much stuff with the above codes commented. 
  
 Let me know what you find, Alan. 
  
 Thanks 
  
 Ben 


Ben, with the new verison it works perfectly (3.1.0)



That’s great! That’s the simplest solution:) 
  
 Ben