@@ -21,7 +21,7 @@ extension AppleMapController: AnnotationDelegate {
2121 } else {
2222 annotation. selectedProgrammatically = false
2323 }
24-
24+
2525 if annotation. infoWindowConsumesTapEvents {
2626 let tapGestureRecognizer = InfoWindowTapGestureRecognizer ( target: self , action: #selector( onCalloutTapped) )
2727 tapGestureRecognizer. annotationId = annotation. id
@@ -30,7 +30,7 @@ extension AppleMapController: AnnotationDelegate {
3030 }
3131 }
3232 }
33-
33+
3434 public func mapView( _ mapView: MKMapView , viewFor annotation: MKAnnotation ) -> MKAnnotationView ? {
3535 if annotation is MKUserLocation {
3636 return nil
@@ -39,7 +39,7 @@ extension AppleMapController: AnnotationDelegate {
3939 }
4040 return nil
4141 }
42-
42+
4343 func getAnnotationView( annotation: FlutterAnnotation ) -> MKAnnotationView {
4444 let identifier : String = annotation. id
4545 var annotationView = self . mapView. dequeueReusableAnnotationView ( withIdentifier: identifier)
@@ -166,7 +166,7 @@ extension AppleMapController: AnnotationDelegate {
166166 }
167167 }
168168 }
169-
169+
170170 @objc func onCalloutTapped( infoWindowTap: InfoWindowTapGestureRecognizer ) {
171171 if infoWindowTap. annotationId != nil && self . currentlySelectedAnnotation == infoWindowTap. annotationId! {
172172 self . channel. invokeMethod ( " infoWindow#onTap " , arguments: [ " annotationId " : infoWindowTap. annotationId] )
@@ -179,7 +179,7 @@ extension AppleMapController: AnnotationDelegate {
179179 private func getAnnotation( with id: String ) -> FlutterAnnotation ? {
180180 return self . mapView. annotations. filter { annotation in return ( annotation as? FlutterAnnotation ) ? . id == id } . first as? FlutterAnnotation
181181 }
182-
182+
183183 private func annotationExists( with id: String ) -> Bool {
184184 return self . getAnnotation ( with: id) != nil
185185 }
@@ -188,7 +188,7 @@ extension AppleMapController: AnnotationDelegate {
188188 let annotation : FlutterAnnotation = FlutterAnnotation ( fromDictionary: annotationData, registrar: registrar)
189189 self . addAnnotation ( annotation: annotation)
190190 }
191-
191+
192192 /**
193193 Checks if an Annotation with the same id exists and removes it before adding if necessary
194194 - Parameter annotation: the FlutterAnnotation that should be added
@@ -203,15 +203,15 @@ extension AppleMapController: AnnotationDelegate {
203203 }
204204 self . mapView. addAnnotation ( annotation)
205205 }
206-
206+
207207 private func getNextAnnotationZIndex( ) -> Double {
208208 let mapViewAnnotations = self . mapView. getMapViewAnnotations ( )
209209 if mapViewAnnotations. isEmpty {
210210 return 0 ;
211211 }
212212 return ( mapViewAnnotations. last?? . zIndex ?? 0 ) + 1
213213 }
214-
214+
215215 private func isAnnoationInFront( zIndex: Double ) -> Bool {
216216 return ( self . mapView. getMapViewAnnotations ( ) . last?? . zIndex ?? 0 ) == zIndex
217217 }
@@ -224,8 +224,12 @@ extension AppleMapController: AnnotationDelegate {
224224 } else {
225225 pinAnnotationView = MKPinAnnotationView . init ( annotation: annotation, reuseIdentifier: id)
226226 }
227-
228227 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+
229233 return pinAnnotationView
230234 }
231235
@@ -234,6 +238,11 @@ extension AppleMapController: AnnotationDelegate {
234238 self . mapView. register ( FlutterMarkerAnnotationView . self, forAnnotationViewWithReuseIdentifier: id)
235239 let markerAnnotationView : FlutterMarkerAnnotationView = self . mapView. dequeueReusableAnnotationView ( withIdentifier: id, for: annotation) as! FlutterMarkerAnnotationView
236240 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+
237246 return markerAnnotationView
238247 }
239248
@@ -260,7 +269,7 @@ extension AppleMapController: AnnotationDelegate {
260269 private func getInfoWindowYOffset( annotationView: MKAnnotationView , annotation: FlutterAnnotation ) -> CGFloat {
261270 return annotationView. frame. height * CGFloat( annotation. calloutOffset. y)
262271 }
263-
272+
264273 private func moveToFront( annotation: FlutterAnnotation ) {
265274 let id : String = annotation. id
266275 annotation. zIndex = self . getNextAnnotationZIndex ( )
0 commit comments