ThinkGeo.com    |     Documentation    |     Premium Support

Some questions on ClusterPointStyle

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 …

Hello.

I think I have come across a possible builtin solution to my Question 5.
Thanks to a post by @Richard6 it seems that the ClusterPointStyle also has a CustomStyles property and he uses it. Some doco on these things would be great … save a lot of trial and error. :slight_smile:
His post is:
Cluster point style is showing the default and custom styles simultaneously - ThinkGeo UI for Mobile / iOS - ThinkGeo Discussion Forums

So my code is now this:

var pointStyle = new PointStyle(PointSymbolType.Circle, 10, GeoBrushes.BrightRed, new GeoPen(GeoBrushes.White, 2));

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();
clusterPointStyle.CustomStyles.Add(pointStyle);
locationLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(clusterPointStyle);
locationLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

I am on v12 of the NuGets … Xamarin Forms and my current platform is Android.
The behavior I am seeing is close to what I am after and I think/hope the parts that are not are due to bugs.
I have a series of screen shots here and lets refer to my Features as F1, F2 and F3 going from left to right.

Screenshot 2021-07-01 ClusterA

Here above all 3 are un-clustered and are showing both styles. I hope this is a bug as I am expecting it to show just the PointStyle which is the red circle.

Screenshot 2021-07-01 ClusterB

Here above on next zoom out I think F1 and F2 are being clustered. The cluster point is showing roughly between them. F2 appears gone. Or is F2 simply being clipped by the cluster style? F1 is still showing and I hope that is a bug.

Screenshot 2021-07-01 ClusterC

Here above on the next zoom out it appears all three are now clustered (F1, F2 and F3).
Note how the cluster style has moved more to the right to be between all three features.
Note how the F3 is no longer showing on map. F1 is still showing (bug?) and F2 is not showing or is it simply clipped?

Based on this behavior it would seem adding a point style to the CustomStyle property of a ClusterPointStyle is a solution to my Question 5 from my previous post but currently there are some bugs I hope? If you could explain what the CustomStyle property on ClusterPointStyle is for that would be great.

My assumptions are below and please do correct me if they are wrong.

  1. Unclustered features are showing both styles. I think that is a bug and it is meant to show just the set PointStyle.
  2. Once clustered it is using just the ClusterPointStyle but some of the clustered features (F1 and F2) are incorrectly displayed … and correct behavior is how F3 is not shown.

Because the doco appears to not cover my specific needs and quite simple samples (or at least samples not matching my specific needs) I have started to hack around to see what various parts of classes do. Sorry if I am wasting peoples time here.

Cheers
Chris …

Hello.

It has been quite some time since posting and no responses at all.
Is there something additional I need to supply?
Have I posted the question incorrectly?

Looking for some help please.

Regards
Chris …

Hey @Chris_Marassovich,

We responded to your ThinkGeo ticket on the same topic earlier today. You can refer to that since we also attached a class file for you to look at.

Thanks,
Kyle