Good Morning.
Looking into the ClusterPointStyle and I have lots of questions on how we configure it to do it’s thing.
I have gone over many of the forum posts and I am still no closer to feeling I have a good understanding of it. When and why it works.
The ClusterPointStyle I am using is below. It should look familiar as it is taken from the samples.
var pointStyleCluster = new PointStyle(PointSymbolType.Triangle, 70, GeoBrushes.DarkRed, new GeoPen(GeoBrushes.White, 2));
var textStyleCluster = new TextStyle("FeatureCount", new GeoFont("Segoe UI", 12, DrawingFontStyles.Bold), GeoBrushes.White)
{
YOffsetInPixel = 1
};
var clusterPointStyle = new ClusterPointStyle(pointStyleCluster, textStyleCluster)
{
MinimumFeaturesPerCellToCluster = 2,
CellSize = 1000
};
locationLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
locationLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(clusterPointStyle);
locationLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Question 1:
In my layer I have 2 features as InternalFeatures. No matter what zoom level I have the map at these two features never get clustered. Why? based on my settings of MinimumFeaturesPerCellToCluster I would assume they should get clustered.
Question 2:
When I have 3 features suddenly all 3 features will get clustered. The closest two on one zoom level and then the third is included on the next zoom level. This is kinda what I expected … but why does it start to work here and not when there was only 2?
Question 3:
What does CellSize relate to? As I moved it from 1 to 1000 I saw the cluster behavior change but I still do not understand what the number indicates.
I assume there is a grid across that map and clustering looks at what is inside each cell of the grid.
- What is the grid laid over?
- Is it the MapView.CurrentExtent?
- What does the number mean or relate to? What grid does a number of 10 mean compared to 1000?
- If not set what is the default value?
Through a trial and error process I have found a value of 1000 is close to what I am expecting from clustering. I am concerned that on varying devices (platform and resolution) this may no longer work as expected. One forum post lead me to think that the value relates to pixels.
Question 4:
- Am I able to interrogate the clusters?
- Can I simply look at the layer and iterate of each cluster and see the features within?
- Can I iterate over the features not clustered?
This question relates to the sample of showing a popup when the user clicks/Taps on a feature. At that moment I take the clicked point as see if there is a feature under that point and it seems for a cluster there is nothing there on the layer?
Note: I did try to discover some of this myself (Q4) by setting breakpoints and using the debugger to browse variables to see what was in them. Unfortunately many objects are disposed by the time I browse to them within the debugger session.
Question 5:
It appears that styles such as ClusterPointStyle and PointStyle are “global” to the layer they are on.
What I mean by that is every feature on the layer will get those two styles if applied to the layer. One feature showing both styles. That makes sense to me.
What if I wanted the ClusterPointStyle to only apply to features it had clustered and not to apply to features it had not clustered? How would I approach that?
A use case for that is I have a set of features and for those not clustered I want them styled as a blue circle and for those clustered a yellow triangle. Some or all of those features may be moving. Think of vehicles.
The user experience is when zoomed out they simply see a few features (clustered) and then as they zoom in they become un-clustered so they can see the detail. I am aware the ClusterPointStyle does handle this with the displayed count to indicate if there is a cluster but often users request a different style entirely for clustered and non-clustered features.
I look forward to your responses.
Cheers
Chris …