Skip to content

Commit 7020e01

Browse files
committed
- iOS run ok for PointAnnotationClusteringExample
1 parent 8e3f067 commit 7020e01

File tree

6 files changed

+30
-23
lines changed

6 files changed

+30
-23
lines changed

src/libs/Mapbox.Maui/Models/Expressions/DslExpression.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MapboxMaui.Expressions;
44

5-
[DebuggerDisplay("{ToString()}")]
5+
[DebuggerDisplay("{GetString()}")]
66
public class DslExpression : List<object>
77
{
88
public DslOperator Operator { get; }
@@ -48,11 +48,10 @@ public object[] ToObjects()
4848
return result.ToArray();
4949
}
5050

51-
public override string ToString()
51+
private string GetString()
5252
{
5353
var items = new List<string>();
5454

55-
5655
if (!string.IsNullOrWhiteSpace(Operator.Value))
5756
{
5857
items.Add(Operator.Value);

src/libs/Mapbox.Maui/Platforms/Android/ExpressionExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ internal static Expression ToPlatformValue(
1111
this DslExpression xvalue
1212
)
1313
{
14-
var expressionBuilder = new Expression.ExpressionBuilder(xvalue.Operator.Value);
14+
var @operator = string.IsNullOrWhiteSpace(xvalue.Operator.Value)
15+
? xvalue.Operator.Value
16+
: xvalue.First();
17+
18+
var expressionBuilder = new Expression.ExpressionBuilder(@operator);
1519

1620
foreach (var argument in xvalue)
1721
{

src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ public IPointAnnotationManager CreatePointAnnotationManager(
301301
new Kotlin.Pair(new Java.Lang.Integer(50), new Java.Lang.Integer(Color.Blue)),
302302
new Kotlin.Pair(new Java.Lang.Integer(0), new Java.Lang.Integer(Color.Green)),
303303
},
304-
null //new Dictionary<string, Java.Lang.Object>(
305-
// clusterOptions.ClusterProperties?
306-
// .Select(
307-
// x => new KeyValuePair<string, Java.Lang.Object>(
308-
// x.Key,
309-
// x.Value.Wrap()
310-
// )
311-
// )
312-
// )
304+
new Dictionary<string, Java.Lang.Object>(
305+
clusterOptions.ClusterProperties?
306+
.Select(
307+
x => new KeyValuePair<string, Java.Lang.Object>(
308+
x.Key,
309+
x.Value.ToPlatformValue()
310+
)
311+
)
312+
)
313313
));
314314
var nativeManager = AnnotationPluginImplKt
315315
.GetAnnotations(mapView)

src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace MapboxMaui;
1414

1515
public static partial class AdditionalExtensions
1616
{
17-
internal static NSDictionary ToNative(this IDictionary<string, DslExpression> dictionary)
17+
internal static NSDictionary<NSString, TMBExpression> ToNative(this IDictionary<string, DslExpression> dictionary)
1818
{
1919
var list = new NSMutableDictionary<NSString, TMBExpression>();
2020
foreach (var item in dictionary)
@@ -122,7 +122,7 @@ internal static NSObject Wrap(this object xvalue)
122122
var result = xvalue switch
123123
{
124124
bool value => NSNumber.FromBoolean(value),
125-
int value => NSNumber.FromLong((nint)value),
125+
int value => NSNumber.FromLong(value),
126126
long value => NSNumber.FromLong((nint)value),
127127
float value => NSNumber.FromDouble(value),
128128
double value => NSNumber.FromDouble(value),

src/libs/Mapbox.Maui/Platforms/iOS/ExpressionExtensions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ internal static TMBExpression ToPlatformValue(
1010
this DslExpression xvalue
1111
)
1212
{
13-
var arguments = NSArray.FromNSObjects(xvalue.Select(x => x.Wrap()).ToArray());
13+
var arguments = xvalue.Select(x => x switch {
14+
DslExpression expression => expression.ToPlatformValue(),
15+
_ => x.Wrap()
16+
}).ToArray() ?? Array.Empty<NSObject>();
1417

1518
return string.IsNullOrWhiteSpace(xvalue.Operator.Value)
1619
? TMBExpression.CreateWithArguments(
17-
arguments
20+
NSArray.FromObjects(arguments)
1821
)
1922
: TMBExpression.CreateWithOperator(
2023
xvalue.Operator.ToPlatformValue(),
21-
arguments
24+
NSArray.FromObjects(arguments)
2225
);
2326
}
2427

src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExample.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void CreateClusters(PointAnnotation[] annotations)
9999
// * 30 when point count is between 50 and 100
100100
// * 35 when point count is greater than or equal to 100
101101
var circleRadiusExpression = DslExpression.step(
102-
DslExpression.geometryType("point_count"),
102+
DslExpression.get("point_count"),
103103
25,
104104
50,
105105
30,
@@ -114,7 +114,7 @@ void CreateClusters(PointAnnotation[] annotations)
114114
// * orange when point count is between 150 and 250
115115
// * light pink when point count is greater than or equal to 250
116116
var circleColorExpression = DslExpression.step(
117-
DslExpression.geometryType("point_count"),
117+
DslExpression.get("point_count"),
118118
Colors.Yellow,
119119
10,
120120
Colors.Green,
@@ -135,8 +135,9 @@ void CreateClusters(PointAnnotation[] annotations)
135135
var sumExpression = DslExpression.args(
136136
DslExpression.sum(
137137
DslExpression.accumulated(),
138-
DslExpression.get("sum"),
139-
1)
138+
DslExpression.get("sum")
139+
),
140+
1
140141
);
141142

142143
// Create a cluster property to add to each cluster
@@ -158,7 +159,7 @@ void CreateClusters(PointAnnotation[] annotations)
158159
};
159160

160161
var pointAnnotationManager = map.AnnotationController.CreatePointAnnotationManager(
161-
Guid.NewGuid().ToString(),
162+
clusterLayerID,
162163
LayerPosition.Unknown(),
163164
clusterOptions
164165
);

0 commit comments

Comments
 (0)