@@ -25,11 +25,11 @@ let pointSource = ShapeSource(identifier: "points") {
2525let clustered = ShapeSource ( identifier: " points " , options: [ . clustered: true , . clusterRadius: 44 ] ) {
2626 // Uses the DSL to quickly construct point features inline
2727 MLNPointFeature ( coordinate: CLLocationCoordinate2D ( latitude: 48.2082 , longitude: 16.3719 ) )
28-
28+
2929 MLNPointFeature ( coordinate: CLLocationCoordinate2D ( latitude: 48.3082 , longitude: 16.3719 ) )
30-
30+
3131 MLNPointFeature ( coordinate: CLLocationCoordinate2D ( latitude: 48.2082 , longitude: 16.9719 ) )
32-
32+
3333 MLNPointFeature ( coordinate: CLLocationCoordinate2D ( latitude: 48.0082 , longitude: 17.9719 ) )
3434}
3535
@@ -89,37 +89,39 @@ let clustered = ShapeSource(identifier: "points", options: [.clustered: true, .c
8989}
9090
9191#Preview( " Clustered Circles with Symbols " ) {
92- @State var camera = MapViewCamera . center ( CLLocationCoordinate2D ( latitude: 48.2082 , longitude: 16.3719 ) , zoom: 5 , direction: 0 )
92+ @State var camera = MapViewCamera . center (
93+ CLLocationCoordinate2D ( latitude: 48.2082 , longitude: 16.3719 ) ,
94+ zoom: 5 ,
95+ direction: 0
96+ )
9397 return MapView ( styleURL: demoTilesURL, camera: $camera) {
9498 // Clusters pins when they would touch
95-
99+
96100 // Cluster == YES shows only those pins that are clustered, using .text
97101 CircleStyleLayer ( identifier: " simple-circles-clusters " , source: clustered)
98102 . radius ( 16 )
99103 . color ( . systemRed)
100104 . strokeWidth ( 2 )
101105 . strokeColor ( . white)
102106 . predicate ( NSPredicate ( format: " cluster == YES " ) )
103-
107+
104108 SymbolStyleLayer ( identifier: " simple-symbols-clusters " , source: clustered)
105109 . textColor ( . white)
106110 . text ( expression: NSExpression ( format: " CAST(point_count, 'NSString') " ) )
107111 . predicate ( NSPredicate ( format: " cluster == YES " ) )
108-
109-
112+
110113 // Cluster != YES shows only those pins that are not clustered, using an icon
111114 CircleStyleLayer ( identifier: " simple-circles-non-clusters " , source: clustered)
112115 . radius ( 16 )
113116 . color ( . systemRed)
114117 . strokeWidth ( 2 )
115118 . strokeColor ( . white)
116119 . predicate ( NSPredicate ( format: " cluster != YES " ) )
117-
118- SymbolStyleLayer ( identifier: " simple-symbols-non-clusters " , source: clustered)
119- . iconImage ( UIImage ( systemName: " mappin " ) !. withRenderingMode ( . alwaysTemplate) )
120- . iconColor ( . white)
121- . predicate ( NSPredicate ( format: " cluster != YES " ) )
122-
120+
121+ SymbolStyleLayer ( identifier: " simple-symbols-non-clusters " , source: clustered)
122+ . iconImage ( UIImage ( systemName: " mappin " ) !. withRenderingMode ( . alwaysTemplate) )
123+ . iconColor ( . white)
124+ . predicate ( NSPredicate ( format: " cluster != YES " ) )
123125 }
124126 . ignoresSafeArea ( . all)
125127}
0 commit comments