react-native-maps 1.12.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +447 -420
- package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +294 -292
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +1 -27
- package/android/src/main/java/com/rnmaps/maps/MapView.java +33 -44
- package/lib/MapView.d.ts +8 -1
- package/lib/MapView.js +3 -8
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -2
- package/package.json +1 -1
|
@@ -25,165 +25,167 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
25
25
|
|
|
26
26
|
public class MapMarkerManager extends ViewGroupManager<MapMarker> {
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
public static class AirMapMarkerSharedIcon {
|
|
29
|
+
private BitmapDescriptor iconBitmapDescriptor;
|
|
30
|
+
private Bitmap bitmap;
|
|
31
|
+
private final Map<MapMarker, Boolean> markers;
|
|
32
|
+
private boolean loadImageStarted;
|
|
33
|
+
|
|
34
|
+
public AirMapMarkerSharedIcon() {
|
|
35
|
+
this.markers = new WeakHashMap<>();
|
|
36
|
+
this.loadImageStarted = false;
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
/**
|
|
40
|
+
* check whether the load image process started.
|
|
41
|
+
* caller AirMapMarker will only need to load it when this returns true.
|
|
42
|
+
*
|
|
43
|
+
* @return true if it is not started, false otherwise.
|
|
44
|
+
*/
|
|
45
|
+
public synchronized boolean shouldLoadImage() {
|
|
46
|
+
if (!this.loadImageStarted) {
|
|
47
|
+
this.loadImageStarted = true;
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* subscribe icon update for given marker.
|
|
55
|
+
* <p>
|
|
56
|
+
* The marker is wrapped in weakReference, so no need to remove it explicitly.
|
|
57
|
+
*
|
|
58
|
+
* @param marker
|
|
59
|
+
*/
|
|
60
|
+
public synchronized void addMarker(MapMarker marker) {
|
|
61
|
+
this.markers.put(marker, true);
|
|
62
|
+
if (this.iconBitmapDescriptor != null) {
|
|
63
|
+
marker.setIconBitmapDescriptor(this.iconBitmapDescriptor, this.bitmap);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Remove marker from this shared icon.
|
|
69
|
+
* <p>
|
|
70
|
+
* Marker will only need to call it when the marker receives a different marker image uri.
|
|
71
|
+
*
|
|
72
|
+
* @param marker
|
|
73
|
+
*/
|
|
74
|
+
public synchronized void removeMarker(MapMarker marker) {
|
|
75
|
+
this.markers.remove(marker);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* check if there is markers still listening on this icon.
|
|
80
|
+
* when there are not markers listen on it, we can remove it.
|
|
81
|
+
*
|
|
82
|
+
* @return true if there is, false otherwise
|
|
83
|
+
*/
|
|
84
|
+
public synchronized boolean hasMarker() {
|
|
85
|
+
return this.markers.isEmpty();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Update the bitmap descriptor and bitmap for the image uri.
|
|
90
|
+
* And notify all subscribers about the update.
|
|
91
|
+
*
|
|
92
|
+
* @param bitmapDescriptor
|
|
93
|
+
* @param bitmap
|
|
94
|
+
*/
|
|
95
|
+
public synchronized void updateIcon(BitmapDescriptor bitmapDescriptor, Bitmap bitmap) {
|
|
96
|
+
|
|
97
|
+
this.iconBitmapDescriptor = bitmapDescriptor;
|
|
98
|
+
this.bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
99
|
+
|
|
100
|
+
if (this.markers.isEmpty()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
for (Map.Entry<MapMarker, Boolean> markerEntry : markers.entrySet()) {
|
|
105
|
+
if (markerEntry.getKey() != null) {
|
|
106
|
+
markerEntry.getKey().setIconBitmapDescriptor(bitmapDescriptor, bitmap);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
51
110
|
}
|
|
52
111
|
|
|
112
|
+
private final Map<String, AirMapMarkerSharedIcon> sharedIcons = new ConcurrentHashMap<>();
|
|
113
|
+
|
|
53
114
|
/**
|
|
54
|
-
*
|
|
115
|
+
* get the shared icon object, if not existed, create a new one and store it.
|
|
55
116
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param marker
|
|
117
|
+
* @param uri
|
|
118
|
+
* @return the icon object for the given uri.
|
|
59
119
|
*/
|
|
60
|
-
public
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
120
|
+
public AirMapMarkerSharedIcon getSharedIcon(String uri) {
|
|
121
|
+
AirMapMarkerSharedIcon icon = this.sharedIcons.get(uri);
|
|
122
|
+
if (icon == null) {
|
|
123
|
+
synchronized (this) {
|
|
124
|
+
if ((icon = this.sharedIcons.get(uri)) == null) {
|
|
125
|
+
icon = new AirMapMarkerSharedIcon();
|
|
126
|
+
this.sharedIcons.put(uri, icon);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return icon;
|
|
65
131
|
}
|
|
66
132
|
|
|
67
133
|
/**
|
|
68
|
-
* Remove
|
|
134
|
+
* Remove the share icon object from our sharedIcons map when no markers are listening for it.
|
|
69
135
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param marker
|
|
136
|
+
* @param uri
|
|
73
137
|
*/
|
|
74
|
-
public
|
|
75
|
-
|
|
138
|
+
public void removeSharedIconIfEmpty(String uri) {
|
|
139
|
+
AirMapMarkerSharedIcon icon = this.sharedIcons.get(uri);
|
|
140
|
+
if (icon == null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!icon.hasMarker()) {
|
|
144
|
+
synchronized (this) {
|
|
145
|
+
if ((icon = this.sharedIcons.get(uri)) != null && !icon.hasMarker()) {
|
|
146
|
+
this.sharedIcons.remove(uri);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
76
150
|
}
|
|
77
151
|
|
|
78
|
-
|
|
79
|
-
* check if there is markers still listening on this icon.
|
|
80
|
-
* when there are not markers listen on it, we can remove it.
|
|
81
|
-
*
|
|
82
|
-
* @return true if there is, false otherwise
|
|
83
|
-
*/
|
|
84
|
-
public synchronized boolean hasMarker(){
|
|
85
|
-
return this.markers.isEmpty();
|
|
152
|
+
public MapMarkerManager() {
|
|
86
153
|
}
|
|
87
154
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* @param bitmapDescriptor
|
|
93
|
-
* @param bitmap
|
|
94
|
-
*/
|
|
95
|
-
public synchronized void updateIcon(BitmapDescriptor bitmapDescriptor, Bitmap bitmap) {
|
|
155
|
+
@Override
|
|
156
|
+
public String getName() {
|
|
157
|
+
return "AIRMapMarker";
|
|
158
|
+
}
|
|
96
159
|
|
|
97
|
-
|
|
98
|
-
|
|
160
|
+
@Override
|
|
161
|
+
public MapMarker createViewInstance(ThemedReactContext context) {
|
|
162
|
+
return new MapMarker(context, this);
|
|
163
|
+
}
|
|
99
164
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
165
|
+
@ReactProp(name = "coordinate")
|
|
166
|
+
public void setCoordinate(MapMarker view, ReadableMap map) {
|
|
167
|
+
view.setCoordinate(map);
|
|
168
|
+
}
|
|
103
169
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
170
|
+
@ReactProp(name = "title")
|
|
171
|
+
public void setTitle(MapMarker view, String title) {
|
|
172
|
+
view.setTitle(title);
|
|
109
173
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* get the shared icon object, if not existed, create a new one and store it.
|
|
116
|
-
*
|
|
117
|
-
* @param uri
|
|
118
|
-
* @return the icon object for the given uri.
|
|
119
|
-
*/
|
|
120
|
-
public AirMapMarkerSharedIcon getSharedIcon(String uri) {
|
|
121
|
-
AirMapMarkerSharedIcon icon = this.sharedIcons.get(uri);
|
|
122
|
-
if (icon == null) {
|
|
123
|
-
synchronized (this) {
|
|
124
|
-
if((icon = this.sharedIcons.get(uri)) == null) {
|
|
125
|
-
icon = new AirMapMarkerSharedIcon();
|
|
126
|
-
this.sharedIcons.put(uri, icon);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
174
|
+
|
|
175
|
+
@ReactProp(name = "identifier")
|
|
176
|
+
public void setIdentifier(MapMarker view, String identifier) {
|
|
177
|
+
view.setIdentifier(identifier);
|
|
129
178
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* Remove the share icon object from our sharedIcons map when no markers are listening for it.
|
|
135
|
-
*
|
|
136
|
-
* @param uri
|
|
137
|
-
*/
|
|
138
|
-
public void removeSharedIconIfEmpty(String uri) {
|
|
139
|
-
AirMapMarkerSharedIcon icon = this.sharedIcons.get(uri);
|
|
140
|
-
if (icon == null) {return;}
|
|
141
|
-
if (!icon.hasMarker()) {
|
|
142
|
-
synchronized (this) {
|
|
143
|
-
if((icon = this.sharedIcons.get(uri)) != null && !icon.hasMarker()) {
|
|
144
|
-
this.sharedIcons.remove(uri);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
179
|
+
|
|
180
|
+
@ReactProp(name = "description")
|
|
181
|
+
public void setDescription(MapMarker view, String description) {
|
|
182
|
+
view.setSnippet(description);
|
|
147
183
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
@Override
|
|
154
|
-
public String getName() {
|
|
155
|
-
return "AIRMapMarker";
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
@Override
|
|
159
|
-
public MapMarker createViewInstance(ThemedReactContext context) {
|
|
160
|
-
return new MapMarker(context, this);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@ReactProp(name = "coordinate")
|
|
164
|
-
public void setCoordinate(MapMarker view, ReadableMap map) {
|
|
165
|
-
view.setCoordinate(map);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
@ReactProp(name = "title")
|
|
169
|
-
public void setTitle(MapMarker view, String title) {
|
|
170
|
-
view.setTitle(title);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@ReactProp(name = "identifier")
|
|
174
|
-
public void setIdentifier(MapMarker view, String identifier) {
|
|
175
|
-
view.setIdentifier(identifier);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@ReactProp(name = "description")
|
|
179
|
-
public void setDescription(MapMarker view, String description) {
|
|
180
|
-
view.setSnippet(description);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// NOTE(lmr):
|
|
184
|
-
// android uses normalized coordinate systems for this, and is provided through the
|
|
185
|
-
// `anchor` property and `calloutAnchor` instead. Perhaps some work could be done
|
|
186
|
-
// to normalize iOS and android to use just one of the systems.
|
|
184
|
+
|
|
185
|
+
// NOTE(lmr):
|
|
186
|
+
// android uses normalized coordinate systems for this, and is provided through the
|
|
187
|
+
// `anchor` property and `calloutAnchor` instead. Perhaps some work could be done
|
|
188
|
+
// to normalize iOS and android to use just one of the systems.
|
|
187
189
|
// @ReactProp(name = "centerOffset")
|
|
188
190
|
// public void setCenterOffset(AirMapMarker view, ReadableMap map) {
|
|
189
191
|
//
|
|
@@ -194,167 +196,167 @@ public class MapMarkerManager extends ViewGroupManager<MapMarker> {
|
|
|
194
196
|
//
|
|
195
197
|
// }
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
@ReactProp(name = "anchor")
|
|
200
|
+
public void setAnchor(MapMarker view, ReadableMap map) {
|
|
201
|
+
// should default to (0.5, 1) (bottom middle)
|
|
202
|
+
double x = map != null && map.hasKey("x") ? map.getDouble("x") : 0.5;
|
|
203
|
+
double y = map != null && map.hasKey("y") ? map.getDouble("y") : 1.0;
|
|
204
|
+
view.setAnchor(x, y);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@ReactProp(name = "calloutAnchor")
|
|
208
|
+
public void setCalloutAnchor(MapMarker view, ReadableMap map) {
|
|
209
|
+
// should default to (0.5, 0) (top middle)
|
|
210
|
+
double x = map != null && map.hasKey("x") ? map.getDouble("x") : 0.5;
|
|
211
|
+
double y = map != null && map.hasKey("y") ? map.getDouble("y") : 0.0;
|
|
212
|
+
view.setCalloutAnchor(x, y);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@ReactProp(name = "image")
|
|
216
|
+
public void setImage(MapMarker view, @Nullable String source) {
|
|
217
|
+
view.setImage(source);
|
|
218
|
+
}
|
|
217
219
|
// public void setImage(AirMapMarker view, ReadableMap image) {
|
|
218
220
|
// view.setImage(image);
|
|
219
221
|
// }
|
|
220
222
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
@ReactProp(name = "rotation", defaultFloat = 0.0f)
|
|
235
|
-
public void setMarkerRotation(MapMarker view, float rotation) {
|
|
236
|
-
view.setRotation(rotation);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@ReactProp(name = "flat", defaultBoolean = false)
|
|
240
|
-
public void setFlat(MapMarker view, boolean flat) {
|
|
241
|
-
view.setFlat(flat);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@ReactProp(name = "draggable", defaultBoolean = false)
|
|
245
|
-
public void setDraggable(MapMarker view, boolean draggable) {
|
|
246
|
-
view.setDraggable(draggable);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
@Override
|
|
250
|
-
@ReactProp(name = "zIndex", defaultFloat = 0.0f)
|
|
251
|
-
public void setZIndex(MapMarker view, float zIndex) {
|
|
252
|
-
super.setZIndex(view, zIndex);
|
|
253
|
-
int integerZIndex = Math.round(zIndex);
|
|
254
|
-
view.setZIndex(integerZIndex);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
@Override
|
|
258
|
-
@ReactProp(name = "opacity", defaultFloat = 1.0f)
|
|
259
|
-
public void setOpacity(MapMarker view, float opacity) {
|
|
260
|
-
super.setOpacity(view, opacity);
|
|
261
|
-
view.setOpacity(opacity);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
@ReactProp(name = "tracksViewChanges", defaultBoolean = true)
|
|
265
|
-
public void setTracksViewChanges(MapMarker view, boolean tracksViewChanges) {
|
|
266
|
-
view.setTracksViewChanges(tracksViewChanges);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
@Override
|
|
270
|
-
public void addView(MapMarker parent, View child, int index) {
|
|
271
|
-
// if an <Callout /> component is a child, then it is a callout view, NOT part of the
|
|
272
|
-
// marker.
|
|
273
|
-
if (child instanceof MapCallout) {
|
|
274
|
-
parent.setCalloutView((MapCallout) child);
|
|
275
|
-
} else {
|
|
276
|
-
super.addView(parent, child, index);
|
|
277
|
-
parent.update(true);
|
|
223
|
+
@ReactProp(name = "icon")
|
|
224
|
+
public void setIcon(MapMarker view, @Nullable String source) {
|
|
225
|
+
view.setImage(source);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@ReactProp(name = "pinColor", defaultInt = Color.RED, customType = "Color")
|
|
229
|
+
public void setPinColor(MapMarker view, int pinColor) {
|
|
230
|
+
float[] hsv = new float[3];
|
|
231
|
+
Color.colorToHSV(pinColor, hsv);
|
|
232
|
+
// NOTE: android only supports a hue
|
|
233
|
+
view.setMarkerHue(hsv[0]);
|
|
278
234
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
235
|
+
|
|
236
|
+
@ReactProp(name = "rotation", defaultFloat = 0.0f)
|
|
237
|
+
public void setMarkerRotation(MapMarker view, float rotation) {
|
|
238
|
+
view.setRotation(rotation);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@ReactProp(name = "flat", defaultBoolean = false)
|
|
242
|
+
public void setFlat(MapMarker view, boolean flat) {
|
|
243
|
+
view.setFlat(flat);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@ReactProp(name = "draggable", defaultBoolean = false)
|
|
247
|
+
public void setDraggable(MapMarker view, boolean draggable) {
|
|
248
|
+
view.setDraggable(draggable);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Override
|
|
252
|
+
@ReactProp(name = "zIndex", defaultFloat = 0.0f)
|
|
253
|
+
public void setZIndex(MapMarker view, float zIndex) {
|
|
254
|
+
super.setZIndex(view, zIndex);
|
|
255
|
+
int integerZIndex = Math.round(zIndex);
|
|
256
|
+
view.setZIndex(integerZIndex);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@Override
|
|
260
|
+
@ReactProp(name = "opacity", defaultFloat = 1.0f)
|
|
261
|
+
public void setOpacity(MapMarker view, float opacity) {
|
|
262
|
+
super.setOpacity(view, opacity);
|
|
263
|
+
view.setOpacity(opacity);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@ReactProp(name = "tracksViewChanges", defaultBoolean = true)
|
|
267
|
+
public void setTracksViewChanges(MapMarker view, boolean tracksViewChanges) {
|
|
268
|
+
view.setTracksViewChanges(tracksViewChanges);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
@Override
|
|
272
|
+
public void addView(MapMarker parent, View child, int index) {
|
|
273
|
+
// if an <Callout /> component is a child, then it is a callout view, NOT part of the
|
|
274
|
+
// marker.
|
|
275
|
+
if (child instanceof MapCallout) {
|
|
276
|
+
parent.setCalloutView((MapCallout) child);
|
|
277
|
+
} else {
|
|
278
|
+
super.addView(parent, child, index);
|
|
279
|
+
parent.update(true);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@Override
|
|
284
|
+
public void removeViewAt(MapMarker parent, int index) {
|
|
285
|
+
super.removeViewAt(parent, index);
|
|
286
|
+
parent.update(true);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@Override
|
|
290
|
+
public void receiveCommand(@NonNull MapMarker view, String commandId, @Nullable ReadableArray args) {
|
|
291
|
+
int duration;
|
|
292
|
+
double lat;
|
|
293
|
+
double lng;
|
|
294
|
+
ReadableMap region;
|
|
295
|
+
|
|
296
|
+
switch (commandId) {
|
|
297
|
+
case "showCallout":
|
|
298
|
+
((Marker) view.getFeature()).showInfoWindow();
|
|
299
|
+
break;
|
|
300
|
+
|
|
301
|
+
case "hideCallout":
|
|
302
|
+
((Marker) view.getFeature()).hideInfoWindow();
|
|
303
|
+
break;
|
|
304
|
+
|
|
305
|
+
case "animateMarkerToCoordinate":
|
|
306
|
+
if (args == null) {
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
region = args.getMap(0);
|
|
310
|
+
duration = args.getInt(1);
|
|
311
|
+
|
|
312
|
+
lng = region.getDouble("longitude");
|
|
313
|
+
lat = region.getDouble("latitude");
|
|
314
|
+
view.animateToCoodinate(new LatLng(lat, lng), duration);
|
|
315
|
+
break;
|
|
316
|
+
|
|
317
|
+
case "redraw":
|
|
318
|
+
view.updateMarkerIcon();
|
|
319
|
+
break;
|
|
306
320
|
}
|
|
307
|
-
|
|
308
|
-
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@Override
|
|
324
|
+
@Nullable
|
|
325
|
+
public Map getExportedCustomDirectEventTypeConstants() {
|
|
326
|
+
return MapBuilder.<String, Map<String, String>>builder()
|
|
327
|
+
.put("onPress", MapBuilder.of("registrationName", "onPress"))
|
|
328
|
+
.put("onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress"))
|
|
329
|
+
.put("onDragStart", MapBuilder.of("registrationName", "onDragStart"))
|
|
330
|
+
.put("onDrag", MapBuilder.of("registrationName", "onDrag"))
|
|
331
|
+
.put("onDragEnd", MapBuilder.of("registrationName", "onDragEnd"))
|
|
332
|
+
.build();
|
|
333
|
+
}
|
|
309
334
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
335
|
+
@Override
|
|
336
|
+
@Nullable
|
|
337
|
+
public Map getExportedCustomBubblingEventTypeConstants() {
|
|
338
|
+
return MapBuilder.<String, Map<String, Object>>builder()
|
|
339
|
+
.put("onSelect", MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onSelect")))
|
|
340
|
+
.put("onDeselect", MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onDeselect")))
|
|
341
|
+
.build();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
@Override
|
|
346
|
+
public LayoutShadowNode createShadowNodeInstance() {
|
|
347
|
+
// we use a custom shadow node that emits the width/height of the view
|
|
348
|
+
// after layout with the updateExtraData method. Without this, we can't generate
|
|
349
|
+
// a bitmap of the appropriate width/height of the rendered view.
|
|
350
|
+
return new SizeReportingShadowNode();
|
|
351
|
+
}
|
|
314
352
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
353
|
+
@Override
|
|
354
|
+
public void updateExtraData(MapMarker view, Object extraData) {
|
|
355
|
+
// This method is called from the shadow node with the width/height of the rendered
|
|
356
|
+
// marker view.
|
|
357
|
+
HashMap<String, Float> data = (HashMap<String, Float>) extraData;
|
|
358
|
+
float width = data.get("width");
|
|
359
|
+
float height = data.get("height");
|
|
360
|
+
view.update((int) width, (int) height);
|
|
318
361
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
@Override
|
|
322
|
-
@Nullable
|
|
323
|
-
public Map getExportedCustomDirectEventTypeConstants() {
|
|
324
|
-
Map<String, Map<String, String>> map = MapBuilder.of(
|
|
325
|
-
"onPress", MapBuilder.of("registrationName", "onPress"),
|
|
326
|
-
"onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress"),
|
|
327
|
-
"onDragStart", MapBuilder.of("registrationName", "onDragStart"),
|
|
328
|
-
"onDrag", MapBuilder.of("registrationName", "onDrag"),
|
|
329
|
-
"onDragEnd", MapBuilder.of("registrationName", "onDragEnd"),
|
|
330
|
-
"onSelect", MapBuilder.of("registrationName", "onSelect"),
|
|
331
|
-
"onDeselect", MapBuilder.of("registrationName", "onDeselect")
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
map.putAll(MapBuilder.of(
|
|
335
|
-
"onDragStart", MapBuilder.of("registrationName", "onDragStart"),
|
|
336
|
-
"onDrag", MapBuilder.of("registrationName", "onDrag"),
|
|
337
|
-
"onDragEnd", MapBuilder.of("registrationName", "onDragEnd")
|
|
338
|
-
));
|
|
339
|
-
|
|
340
|
-
return map;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
@Override
|
|
344
|
-
public LayoutShadowNode createShadowNodeInstance() {
|
|
345
|
-
// we use a custom shadow node that emits the width/height of the view
|
|
346
|
-
// after layout with the updateExtraData method. Without this, we can't generate
|
|
347
|
-
// a bitmap of the appropriate width/height of the rendered view.
|
|
348
|
-
return new SizeReportingShadowNode();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
@Override
|
|
352
|
-
public void updateExtraData(MapMarker view, Object extraData) {
|
|
353
|
-
// This method is called from the shadow node with the width/height of the rendered
|
|
354
|
-
// marker view.
|
|
355
|
-
HashMap<String, Float> data = (HashMap<String, Float>) extraData;
|
|
356
|
-
float width = data.get("width");
|
|
357
|
-
float height = data.get("height");
|
|
358
|
-
view.update((int) width, (int) height);
|
|
359
|
-
}
|
|
360
362
|
}
|
|
@@ -8,10 +8,8 @@ import android.location.Geocoder;
|
|
|
8
8
|
import android.net.Uri;
|
|
9
9
|
import android.util.Base64;
|
|
10
10
|
import android.util.DisplayMetrics;
|
|
11
|
-
import android.util.Log;
|
|
12
11
|
|
|
13
12
|
import androidx.annotation.Nullable;
|
|
14
|
-
import androidx.annotation.NonNull;
|
|
15
13
|
|
|
16
14
|
import com.facebook.react.bridge.Promise;
|
|
17
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -25,8 +23,6 @@ import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
|
25
23
|
import com.facebook.react.uimanager.UIBlock;
|
|
26
24
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
27
25
|
import com.google.android.gms.maps.GoogleMap;
|
|
28
|
-
import com.google.android.gms.maps.MapsInitializer;
|
|
29
|
-
import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
|
|
30
26
|
import com.google.android.gms.maps.model.CameraPosition;
|
|
31
27
|
import com.google.android.gms.maps.model.LatLng;
|
|
32
28
|
|
|
@@ -35,10 +31,9 @@ import java.io.Closeable;
|
|
|
35
31
|
import java.io.File;
|
|
36
32
|
import java.io.FileOutputStream;
|
|
37
33
|
import java.io.IOException;
|
|
38
|
-
|
|
34
|
+
import java.util.HashMap;
|
|
39
35
|
import java.util.List;
|
|
40
36
|
import java.util.Map;
|
|
41
|
-
import java.util.HashMap;
|
|
42
37
|
|
|
43
38
|
@ReactModule(name = MapModule.NAME)
|
|
44
39
|
public class MapModule extends ReactContextBaseJavaModule {
|
|
@@ -356,25 +351,4 @@ public class MapModule extends ReactContextBaseJavaModule {
|
|
|
356
351
|
}
|
|
357
352
|
});
|
|
358
353
|
}
|
|
359
|
-
|
|
360
|
-
@ReactMethod
|
|
361
|
-
public void enableLatestRenderer(final Promise promise) {
|
|
362
|
-
final ReactApplicationContext context = getReactApplicationContext();
|
|
363
|
-
|
|
364
|
-
UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
|
|
365
|
-
uiManager.addUIBlock(new UIBlock()
|
|
366
|
-
{
|
|
367
|
-
@Override
|
|
368
|
-
public void execute(NativeViewHierarchyManager nvhm)
|
|
369
|
-
{
|
|
370
|
-
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, new OnMapsSdkInitializedCallback() {
|
|
371
|
-
@Override
|
|
372
|
-
public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
|
|
373
|
-
Log.d("AirMapRenderer", renderer.toString());
|
|
374
|
-
promise.resolve(renderer.toString());
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
354
|
}
|