@@ -54,33 +54,84 @@ class MapMarkerBuilder(
5454 }
5555
5656 fun update (
57- marker : Marker ,
5857 prev : RNMarker ,
5958 next : RNMarker ,
59+ marker : Marker ,
6060 ) {
61- marker.position =
62- next.coordinate.toLatLng()
61+ if (prev.coordinate.latitude != next.coordinate.latitude ||
62+ prev.coordinate.longitude != next.coordinate.longitude
63+ ) {
64+ marker.position = next.coordinate.toLatLng()
65+ }
6366
6467 if (! prev.markerStyleEquals(next)) {
6568 buildIconAsync(marker.id, next) { icon ->
6669 marker.setIcon(icon)
70+ if (prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x ||
71+ prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y
72+ ) {
73+ marker.setInfoWindowAnchor(
74+ (next.infoWindowAnchor?.x ? : 0.5f ).toFloat(),
75+ (next.infoWindowAnchor?.y ? : 0f ).toFloat(),
76+ )
77+ }
78+
79+ if (prev.anchor?.x != next.anchor?.x ||
80+ prev.anchor?.y != next.anchor?.y
81+ ) {
82+ marker.setAnchor(
83+ (next.anchor?.x ? : 0.5f ).toFloat(),
84+ (next.anchor?.y ? : 1.0f ).toFloat(),
85+ )
86+ }
6787 }
88+ } else {
89+ if (prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x ||
90+ prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y
91+ ) {
92+ marker.setInfoWindowAnchor(
93+ (next.infoWindowAnchor?.x ? : 0.5f ).toFloat(),
94+ (next.infoWindowAnchor?.y ? : 0f ).toFloat(),
95+ )
96+ }
97+
98+ if (prev.anchor?.x != next.anchor?.x ||
99+ prev.anchor?.y != next.anchor?.y
100+ ) {
101+ marker.setAnchor(
102+ (next.anchor?.x ? : 0.5f ).toFloat(),
103+ (next.anchor?.y ? : 1.0f ).toFloat(),
104+ )
105+ }
106+ }
107+
108+ if (prev.title != next.title) {
109+ marker.title = next.title
110+ }
111+
112+ if (prev.snippet != next.snippet) {
113+ marker.snippet = next.snippet
114+ }
115+
116+ if (prev.opacity != next.opacity) {
117+ marker.alpha = next.opacity?.toFloat() ? : 1f
118+ }
119+
120+ if (prev.flat != next.flat) {
121+ marker.isFlat = next.flat ? : false
122+ }
123+
124+ if (prev.draggable != next.draggable) {
125+ marker.isDraggable = next.draggable ? : false
126+ }
127+
128+ if (prev.rotation != next.rotation) {
129+ marker.rotation = next.rotation?.toFloat() ? : 0f
130+ }
131+
132+ if (prev.zIndex != next.zIndex) {
133+ marker.zIndex = next.zIndex?.toFloat() ? : 0f
68134 }
69- marker.title = next.title
70- marker.snippet = next.snippet
71- marker.alpha = next.opacity?.toFloat() ? : 1f
72- marker.isFlat = next.flat ? : false
73- marker.isDraggable = next.draggable ? : false
74- marker.rotation = next.rotation?.toFloat() ? : 0f
75- marker.setInfoWindowAnchor(
76- (next.infoWindowAnchor?.x ? : 0.5 ).toFloat(),
77- (next.infoWindowAnchor?.y ? : 0 ).toFloat(),
78- )
79- marker.setAnchor(
80- (next.anchor?.x ? : 0.5 ).toFloat(),
81- (next.anchor?.y ? : 1.0 ).toFloat(),
82- )
83- marker.zIndex = next.zIndex?.toFloat() ? : 0f
84135 }
85136
86137 fun buildIconAsync (
0 commit comments