ThinkGeo.com    |     Documentation    |     Premium Support

Different popup information

Hi again!!


Maybe I'll not explain very well, but I'm gonna try.


with the previous version, each marker on a marker layer could have its own pop up, with different information for each one.


 but with the new one, popups are definned for one zoomlevel, like styles, so, how can I give them different information?


and also I would know how to define my own markerStyle.


Thank you very much for listenng to me.



Miren,


Create a simple separate marker now is not available in the latest version (3.0.131). You need to add a group of markers to an overlay, set the ZoomLevel (styles) for the Overlay to display.
 
We have 2 kinds of Marker related Overlay now. One is InMemoryMarkerOverlay, which is useful when you want to create markers yourself. The other is FeatureMarkerOverlay, which is for the case you want to get the data of all your markers from a FeatureSource.  Also we have 3 Styles which apply to a MarkerOverlay, they are PointMarkerStyle, ValueMarkerStyle and ClassBreakMarkerStyle.
 
We get rid of the way that creating a simple Marker and specifying its properties (like popups) separately. The reason of that is although it’s simple for some cases, it breaks the pattern we are using all through the product. You know for a featureLayer, we have a featureSource for all the data, and have zoomLevels for the renderers. We want to do the same way for Markers to make it consistent.
 
Here is a sample for you showing how to use MarkerOverlay and MarkerStyle to render your marker differently. Let me know for any queries.
 
Thanks,
 
Ben.

251-Post5040.zip (102 KB)

Thank you very much for your help Ben.

But now... I have another problem, I'm using a featureMarkerOverlay and trying to add it features from a shapefileFeatureLayer but I don´t know how.

I've tried this way:


 




  Dim markers As New FeatureMarkerOverlay()
        markers.IsBaseOverlay = False
        markers.Name = "Hoteles"

        Dim feats As New Collection(Of Feature)

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

        markers.FeatureSource.Open()
        For Each feat As Feature In feats
            If feat.ColumnValues("FEATTYP") = "7324" Then
                markers.FeatureSource.AddFeature(feat)
            End If
        Next
        markers.FeatureSource.Close()
 

 But it throws a nullReferenceException when I open the featureSource of the markerLayer 


 


I also have tried this:



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

        Dim markers As New FeatureMarkerOverlay()
        markers.FeatureSource = PointLayer.FeatureSource
        markers.IsBaseOverlay = False
        markers.Name = "Hoteles"
        'proj4.Close()

        markers.FeatureSource.Open()
        Dim features As Collection(Of Feature) = markers.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns)
        markers.FeatureSource.Close()

        markers.FeatureSource.Open()
        For Each feat As Feature In features
            If Not feat.ColumnValues("FEATTYP") = "7314" Then
                markers.FeatureSource.BeginTransaction()
                markers.FeatureSource.DeleteFeature(feat.ColumnValues("ID"))
                markers.FeatureSource.CommitTransaction()
            End If
        Next
        markers.FeatureSource.Close()

 But it throws an IOException when I commitTransaction.


 


Any idea of the reason or how to solve this?


Thanks again!



Miren, 



FeatureMarkerOverlay.FeatureSource by default is null, that’s why you have that exception in your first piece of code. The 2nd exception is because the following line 

markers.FeatureSource = PointLayer.FeatureSource 

passed the PointLayer.FeatureSource to markers.FeatureSource by reference, that means whenever you call a method within markers.FeatureSource, in fact it calls the methods within PointLayer.FeatureSource; as trying to edit the shape file, you may get an IO exception if the file is opened readonly or something. 



For your case, I think the best way is to use InMemoryMarkerOverlay. With that you can add/remove markers easily. Here is the code how to do it: 


Dim markers As New InMemoryMarkerOverlay()
markers.IsBaseOverlay = False
markers.Name = "Hoteles"

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

 


FeatureMarkerOverlay is for the case you want to initialize your markers directly from a shape file for example, but you cannot add/remove any marker. Your sample let us realize maybe we should provide the ability for doing this, thanks for the insights and we will consider adding this feature.


Let me know for any queries. 



Ben.