Skip to content

Commit c7d964f

Browse files
committed
[WIP] PointClusteringExample
1 parent cad214b commit c7d964f

20 files changed

+1666
-45
lines changed

src/libs/Mapbox.Maui/IMapboxView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ partial interface IMapboxView {
4141

4242
public interface IAnnotationController
4343
{
44-
public IPolygonAnnotationManager CreatePolygonAnnotationManager(string id, LayerPosition layerPosition);
45-
public ICircleAnnotationManager CreateCircleAnnotationManager(string id, LayerPosition layerPosition);
46-
//public IPointAnnotationManager CreatePointAnnotationManager(string id, LayerPosition layerPosition);
44+
IPolygonAnnotationManager CreatePolygonAnnotationManager(string id, LayerPosition layerPosition);
45+
ICircleAnnotationManager CreateCircleAnnotationManager(string id, LayerPosition layerPosition);
46+
IPointAnnotationManager CreatePointAnnotationManager(string id, LayerPosition layerPosition, ClusterOptions clusterOptions = null);
4747
//public IPolylineAnnotationManager CreatePolylineAnnotationManager(string, LayerPosition layerPosition);
4848
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using MapboxMaui.Expressions;
2+
3+
namespace MapboxMaui.Annotations;
4+
5+
public class ClusterOptions
6+
{
7+
/// The circle radius of the cluster items, 18 by default. Units in pixels.
8+
public PropertyValue<double> CircleRadius { get; set; }
9+
10+
/// The circle color, black by default.
11+
public PropertyValue<Color> CircleColor { get; set; }
12+
13+
/// The text color of cluster item, white by default
14+
public PropertyValue<Color> TextColor { get; set; }
15+
16+
/// The text size of cluster item, 12 by default. Units in pixels.
17+
public PropertyValue<double> TextSize { get; set; }
18+
19+
/// Value to use for a text label of the cluster. `get("point_count")` by default which
20+
/// will show the count of points in the cluster
21+
public PropertyValue<string> TextField { get; set; }
22+
23+
/// Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal
24+
/// to the width of a tile, 50 by default. Value must be greater than or equal to 0.
25+
public double ClusterRadius { get; set; }
26+
27+
/// Max zoom on which to cluster points if clustering is enabled. Defaults to one zoom less
28+
/// than maxzoom (so that last zoom features are not clustered). Clusters are re-evaluated at integer zoom
29+
/// levels so setting clusterMaxZoom to 14 means the clusters will be displayed until z15.
30+
public double ClusterMaxZoom { get; set; }
31+
32+
/// An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from
33+
/// clustered points. Has the form `{"property_name": [operator, map_expression]}`.
34+
/// `operator` is any expression function that accepts at
35+
/// least 2 operands (e.g. `"+"` or `"max"`) — it accumulates the property value from clusters/points the
36+
/// cluster contains; `map_expression` produces the value of a single point. Example:
37+
///
38+
/// ``Expression`` syntax:
39+
/// ```
40+
/// let expression = Exp(.sum) {
41+
/// Exp(.get) { "scalerank" }
42+
/// }
43+
/// clusterProperties: ["sum": expression]
44+
/// ```
45+
///
46+
/// JSON syntax:
47+
/// `{"sum": ["+", ["get", "scalerank"]]}`
48+
///
49+
/// For more advanced use cases, in place of `operator`, you can use a custom reduce expression that references a special `["accumulated"]` value. Example:
50+
///
51+
/// ``Expression`` syntax:
52+
/// ```
53+
/// let expression = Exp {
54+
/// Exp(.sum) {
55+
/// Exp(.accumulated)
56+
/// Exp(.get) { "sum" }
57+
/// }
58+
/// Exp(.get) { "scalerank" }
59+
/// }
60+
/// clusterProperties: ["sum": expression]
61+
/// ```
62+
///
63+
/// JSON syntax:
64+
/// `{"sum": [["+", ["accumulated"], ["get", "sum"]], ["get", "scalerank"]]}`
65+
public IDictionary<string, DslExpression> ClusterProperties { get; set; }
66+
}
67+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace MapboxMaui.Annotations;
2+
3+
public interface IPointAnnotationManager : IAnnotationManager<PointAnnotation>
4+
{
5+
bool? IconAllowOverlap { get; set; }
6+
bool? IconIgnorePlacement { get; set; }
7+
bool? IconKeepUpright { get; set; }
8+
bool? IconOptional { get; set; }
9+
double? IconPadding { get; set; }
10+
IconPitchAlignment? IconPitchAlignment { get; set; }
11+
IconRotationAlignment? IconRotationAlignment { get; set; }
12+
IconTextFit? IconTextFit { get; set; }
13+
double[] IconTextFitPadding { get; set; }
14+
bool? SymbolAvoidEdges { get; set; }
15+
SymbolPlacement? SymbolPlacement { get; set; }
16+
double? SymbolSpacing { get; set; }
17+
SymbolZOrder? SymbolZOrder { get; set; }
18+
bool? TextAllowOverlap { get; set; }
19+
string[] TextFont { get; set; }
20+
bool? TextIgnorePlacement { get; set; }
21+
bool? TextKeepUpright { get; set; }
22+
double? TextMaxAngle { get; set; }
23+
bool? TextOptional { get; set; }
24+
double? TextPadding { get; set; }
25+
TextPitchAlignment? TextPitchAlignment { get; set; }
26+
TextRotationAlignment? TextRotationAlignment { get; set; }
27+
TextAnchor[] TextVariableAnchor { get; set; }
28+
TextWritingMode[] TextWritingMode { get; set; }
29+
double[] IconTranslate { get; set; }
30+
IconTranslateAnchor? IconTranslateAnchor { get; set; }
31+
double[] TextTranslate { get; set; }
32+
TextTranslateAnchor? TextTranslateAnchor { get; set; }
33+
double? TextLineHeight { get; set; }
34+
}
35+
36+
public partial class PointAnnotationManager
37+
{
38+
}
39+

0 commit comments

Comments
 (0)