@@ -21,7 +21,7 @@ extension AppleMapController: AnnotationDelegate {
21
21
} else {
22
22
annotation. selectedProgrammatically = false
23
23
}
24
-
24
+
25
25
if annotation. infoWindowConsumesTapEvents {
26
26
let tapGestureRecognizer = InfoWindowTapGestureRecognizer ( target: self , action: #selector( onCalloutTapped) )
27
27
tapGestureRecognizer. annotationId = annotation. id
@@ -30,7 +30,7 @@ extension AppleMapController: AnnotationDelegate {
30
30
}
31
31
}
32
32
}
33
-
33
+
34
34
public func mapView( _ mapView: MKMapView , viewFor annotation: MKAnnotation ) -> MKAnnotationView ? {
35
35
if annotation is MKUserLocation {
36
36
return nil
@@ -39,7 +39,7 @@ extension AppleMapController: AnnotationDelegate {
39
39
}
40
40
return nil
41
41
}
42
-
42
+
43
43
func getAnnotationView( annotation: FlutterAnnotation ) -> MKAnnotationView {
44
44
let identifier : String = annotation. id
45
45
var annotationView = self . mapView. dequeueReusableAnnotationView ( withIdentifier: identifier)
@@ -166,7 +166,7 @@ extension AppleMapController: AnnotationDelegate {
166
166
}
167
167
}
168
168
}
169
-
169
+
170
170
@objc func onCalloutTapped( infoWindowTap: InfoWindowTapGestureRecognizer ) {
171
171
if infoWindowTap. annotationId != nil && self . currentlySelectedAnnotation == infoWindowTap. annotationId! {
172
172
self . channel. invokeMethod ( " infoWindow#onTap " , arguments: [ " annotationId " : infoWindowTap. annotationId] )
@@ -179,7 +179,7 @@ extension AppleMapController: AnnotationDelegate {
179
179
private func getAnnotation( with id: String ) -> FlutterAnnotation ? {
180
180
return self . mapView. annotations. filter { annotation in return ( annotation as? FlutterAnnotation ) ? . id == id } . first as? FlutterAnnotation
181
181
}
182
-
182
+
183
183
private func annotationExists( with id: String ) -> Bool {
184
184
return self . getAnnotation ( with: id) != nil
185
185
}
@@ -188,7 +188,7 @@ extension AppleMapController: AnnotationDelegate {
188
188
let annotation : FlutterAnnotation = FlutterAnnotation ( fromDictionary: annotationData, registrar: registrar)
189
189
self . addAnnotation ( annotation: annotation)
190
190
}
191
-
191
+
192
192
/**
193
193
Checks if an Annotation with the same id exists and removes it before adding if necessary
194
194
- Parameter annotation: the FlutterAnnotation that should be added
@@ -203,15 +203,15 @@ extension AppleMapController: AnnotationDelegate {
203
203
}
204
204
self . mapView. addAnnotation ( annotation)
205
205
}
206
-
206
+
207
207
private func getNextAnnotationZIndex( ) -> Double {
208
208
let mapViewAnnotations = self . mapView. getMapViewAnnotations ( )
209
209
if mapViewAnnotations. isEmpty {
210
210
return 0 ;
211
211
}
212
212
return ( mapViewAnnotations. last?? . zIndex ?? 0 ) + 1
213
213
}
214
-
214
+
215
215
private func isAnnoationInFront( zIndex: Double ) -> Bool {
216
216
return ( self . mapView. getMapViewAnnotations ( ) . last?? . zIndex ?? 0 ) == zIndex
217
217
}
@@ -224,8 +224,12 @@ extension AppleMapController: AnnotationDelegate {
224
224
} else {
225
225
pinAnnotationView = MKPinAnnotationView . init ( annotation: annotation, reuseIdentifier: id)
226
226
}
227
-
228
227
pinAnnotationView. layer. zPosition = annotation. zIndex
228
+
229
+ if let hueColor: Double = annotation. icon. hueColor {
230
+ pinAnnotationView. pinTintColor = UIColor . init ( hue: hueColor, saturation: 1 , brightness: 1 , alpha: 1 )
231
+ }
232
+
229
233
return pinAnnotationView
230
234
}
231
235
@@ -234,6 +238,11 @@ extension AppleMapController: AnnotationDelegate {
234
238
self . mapView. register ( FlutterMarkerAnnotationView . self, forAnnotationViewWithReuseIdentifier: id)
235
239
let markerAnnotationView : FlutterMarkerAnnotationView = self . mapView. dequeueReusableAnnotationView ( withIdentifier: id, for: annotation) as! FlutterMarkerAnnotationView
236
240
markerAnnotationView. stickyZPosition = annotation. zIndex
241
+
242
+ if let hueColor: Double = annotation. icon. hueColor {
243
+ markerAnnotationView. markerTintColor = UIColor . init ( hue: hueColor, saturation: 1 , brightness: 1 , alpha: 1 )
244
+ }
245
+
237
246
return markerAnnotationView
238
247
}
239
248
@@ -260,7 +269,7 @@ extension AppleMapController: AnnotationDelegate {
260
269
private func getInfoWindowYOffset( annotationView: MKAnnotationView , annotation: FlutterAnnotation ) -> CGFloat {
261
270
return annotationView. frame. height * CGFloat( annotation. calloutOffset. y)
262
271
}
263
-
272
+
264
273
private func moveToFront( annotation: FlutterAnnotation ) {
265
274
let id : String = annotation. id
266
275
annotation. zIndex = self . getNextAnnotationZIndex ( )
0 commit comments