Select to view content in your preferred language

Custom Flare Clusterer and MapTip Issue

1461
3
Jump to solution
07-23-2012 09:19 AM
DanielSanders
Occasional Contributor
I have a feature layer with around 1500 points. When the application initially loads all of the points should be displayed using a clusterer. Then the user should be able to filter the points based on various criteria to display a subset of the 1500 point.
I thought that changing the WHERE clause and reloading the entire feature layer each time the user updates the filter would be very inefficient. So instead I created a custom clusterer that clusters selected graphics only.
      
 protected override Graphic OnCreateGraphic(GraphicCollection cluster, ESRI.ArcGIS.Client.Geometry.MapPoint point, int maxClusterCount)         {             if (cluster != null)             {                 if (cluster.Any(g => g.Selected))                 {                     var graphics = new GraphicCollection(cluster.Where(g => g.Selected));                     return base.OnCreateGraphic(graphics, point, maxClusterCount);                 }                 else                 {                     return new Graphic();                 }             }             return null;         }

In the application, selected points/graphics are visible and unselected points/graphics are hidden. So each time the user updates the filter, the application just selects or unselects the appropriate graphics in the feature layer. It works very well, except for one problem: missing maptips. If a graphic is part of a flare cluster, then it's maptip will display normally. But if the filter is updated such that all of the other graphics in a flare cluster are invisible, then the point appears but no maptip will be displayed. Any ideas how to fix this?
I'm tempted to change the behavior and just reload the whole feature layer. Anyone have a better approach?

Thanks for your help...
0 Kudos
1 Solution

Accepted Solutions
JoshPorter
Occasional Contributor
If you are just trying to exclude specific graphics from the map/cluster Ive found setting the geometry of the graphic you want to hide to Null will cause the map/clusterer/maptips to behave normally as if that specifc graphic isnt there.
This is VB code i have in a class that inherits ESRI.Graphic that serves this purpose
Private mStoredGeometry As ESRI.ArcGIS.Client.Geometry.Geometry     Public Property Visible() As Boolean Implements ILayerItem.Visible         Get             Return Me.Geometry IsNot Nothing         End Get         Set(ByVal value As Boolean)             If value <> Visible Then                 If value Then                     If mStoredGeometry IsNot Nothing Then Me.Geometry = mStoredGeometry                 Else                     If Me.Geometry IsNot Nothing Then mStoredGeometry = Me.Geometry                     Me.Geometry = Nothing                 End If             End If         End Set     End Property

View solution in original post

0 Kudos
3 Replies
HyrumErnstrom
Regular Contributor
Filtering on a Clusterer is not a good idea, since it thinks a cluster is more than one graphic and will place it on the center of the pre-filtered graphics.

It's much better to filter at the GraphicsLayer.Graphics level because then you tell the Clusterer what graphics are available to cluster.
0 Kudos
JoshPorter
Occasional Contributor
If you are just trying to exclude specific graphics from the map/cluster Ive found setting the geometry of the graphic you want to hide to Null will cause the map/clusterer/maptips to behave normally as if that specifc graphic isnt there.
This is VB code i have in a class that inherits ESRI.Graphic that serves this purpose
Private mStoredGeometry As ESRI.ArcGIS.Client.Geometry.Geometry     Public Property Visible() As Boolean Implements ILayerItem.Visible         Get             Return Me.Geometry IsNot Nothing         End Get         Set(ByVal value As Boolean)             If value <> Visible Then                 If value Then                     If mStoredGeometry IsNot Nothing Then Me.Geometry = mStoredGeometry                 Else                     If Me.Geometry IsNot Nothing Then mStoredGeometry = Me.Geometry                     Me.Geometry = Nothing                 End If             End If         End Set     End Property
0 Kudos
DanielSanders
Occasional Contributor
Thank you both for your replies.

I was looking for a visible property on Graphic, but couldn't find one. So you basically create your own - a clever solution. Thanks, I'll give this a try...
0 Kudos