Skip to content

Commit dd5599c

Browse files
committed
Animate annotation updates
Instead of removing and re-adding annotations which causes the annotation to flash, changing annotations now animate to their new location.
1 parent 2414c34 commit dd5599c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.3.0
4+
5+
* Animate marker position changes instead of removing and re-adding
36
## 1.2.0
47

58
* Added a `markerAnnotationWithHue()` and `pinAnnotationWithHue()` method to allow custom marker/pin colors

ios/Classes/Annotations/AnnotationController.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ extension AppleMapController: AnnotationDelegate {
9494
let newAnnotation = FlutterAnnotation.init(fromDictionary: annotationData, registrar: registrar)
9595
if annotationToChange != newAnnotation {
9696
if !annotationToChange.wasDragged {
97-
addAnnotation(annotation: newAnnotation)
97+
updateAnnotation(annotation: newAnnotation)
9898
} else {
9999
annotationToChange.wasDragged = false
100100
}
@@ -204,6 +204,16 @@ extension AppleMapController: AnnotationDelegate {
204204
self.mapView.addAnnotation(annotation)
205205
}
206206

207+
private func updateAnnotation(annotation: FlutterAnnotation) {
208+
if self.annotationExists(with: annotation.id) {
209+
UIView.animate(withDuration: 0.32, animations: {
210+
let oldAnnotation = self.getAnnotation(with: annotation.id)
211+
oldAnnotation?.coordinate = annotation.coordinate
212+
oldAnnotation?.title = annotation.title
213+
})
214+
}
215+
}
216+
207217
private func getNextAnnotationZIndex() -> Double {
208218
let mapViewAnnotations = self.mapView.getMapViewAnnotations()
209219
if mapViewAnnotations.isEmpty {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: apple_maps_flutter
22
description: This plugin uses the Flutter platform view to display an Apple Maps widget.
3-
version: 1.2.0
3+
version: 1.3.0
44
homepage: https://luisthein.de
55
repository: https://github.com/LuisThein/apple_maps_flutter
66
issue_tracker: https://github.com/LuisThein/apple_maps_flutter/issues

0 commit comments

Comments
 (0)