react-native-maps 1.21.0-alpha.82 → 1.21.0-alpha.84
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/generated/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +49 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java +24 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +46 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +24 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +22 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +11 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +45 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +11 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +12 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +1 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +0 -1
- package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +95 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +5 -1
- package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +287 -149
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +1 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +22 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +22 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +11 -0
- package/ios/generated/RNMapsSpecs/Props.h +45 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +4 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +1 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +11 -0
- package/ios/generated/RNMapsSpecs/States.h +12 -0
- package/lib/MapMarker.js +6 -1
- package/lib/MapOverlay.d.ts +1 -0
- package/lib/MapOverlay.js +22 -4
- package/lib/decorateMapComponent.js +5 -0
- package/lib/specs/NativeComponentOverlay.d.ts +67 -0
- package/lib/specs/NativeComponentOverlay.js +7 -0
- package/package.json +1 -1
|
@@ -2,8 +2,37 @@ package com.rnmaps.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.Bitmap;
|
|
5
|
+
import android.graphics.Canvas;
|
|
6
|
+
import android.graphics.Color;
|
|
7
|
+
import android.graphics.Paint;
|
|
8
|
+
import android.graphics.drawable.Animatable;
|
|
9
|
+
import android.net.Uri;
|
|
10
|
+
import android.os.Handler;
|
|
11
|
+
import android.os.Looper;
|
|
5
12
|
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
import com.facebook.common.references.CloseableReference;
|
|
16
|
+
import com.facebook.datasource.BaseDataSubscriber;
|
|
17
|
+
import com.facebook.datasource.DataSource;
|
|
18
|
+
import com.facebook.datasource.DataSubscriber;
|
|
19
|
+
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
20
|
+
import com.facebook.drawee.controller.BaseControllerListener;
|
|
21
|
+
import com.facebook.drawee.controller.ControllerListener;
|
|
22
|
+
import com.facebook.drawee.drawable.ScalingUtils;
|
|
23
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
24
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
|
25
|
+
import com.facebook.drawee.view.DraweeHolder;
|
|
26
|
+
import com.facebook.imagepipeline.core.ImagePipeline;
|
|
27
|
+
import com.facebook.imagepipeline.image.CloseableBitmap;
|
|
28
|
+
import com.facebook.imagepipeline.image.CloseableImage;
|
|
29
|
+
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
30
|
+
import com.facebook.imagepipeline.image.ImageInfo;
|
|
31
|
+
import com.facebook.imagepipeline.request.ImageRequest;
|
|
32
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
6
33
|
import com.facebook.react.bridge.ReadableArray;
|
|
34
|
+
import com.facebook.react.common.MapBuilder;
|
|
35
|
+
import com.google.android.gms.common.images.ImageManager;
|
|
7
36
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
8
37
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
9
38
|
import com.google.android.gms.maps.model.GroundOverlay;
|
|
@@ -11,156 +40,265 @@ import com.google.android.gms.maps.model.GroundOverlayOptions;
|
|
|
11
40
|
import com.google.android.gms.maps.model.LatLng;
|
|
12
41
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
13
42
|
import com.google.maps.android.collections.GroundOverlayManager;
|
|
43
|
+
import com.rnmaps.fabric.event.OnPressEvent;
|
|
44
|
+
|
|
45
|
+
import java.util.Map;
|
|
46
|
+
import java.util.concurrent.Executors;
|
|
14
47
|
|
|
15
48
|
public class MapOverlay extends MapFeature implements ImageReadable {
|
|
16
49
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
50
|
+
|
|
51
|
+
private String imageUri;
|
|
52
|
+
|
|
53
|
+
private GroundOverlayOptions groundOverlayOptions;
|
|
54
|
+
private GroundOverlay groundOverlay;
|
|
55
|
+
private LatLngBounds bounds;
|
|
56
|
+
private float bearing;
|
|
57
|
+
private BitmapDescriptor bitmapDescriptor;
|
|
58
|
+
private boolean tappable;
|
|
59
|
+
private float zIndex;
|
|
60
|
+
private float transparency;
|
|
61
|
+
|
|
62
|
+
private DataSource<CloseableReference<CloseableImage>> dataSource;
|
|
63
|
+
|
|
64
|
+
private GroundOverlayManager.Collection groundOverlayCollection;
|
|
65
|
+
|
|
66
|
+
private ImageManager.OnImageLoadedListener imageLoadedListener;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public MapOverlay(Context context) {
|
|
70
|
+
super(context);
|
|
71
|
+
transparency = 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private GenericDraweeHierarchy createDraweeHierarchy() {
|
|
75
|
+
return new GenericDraweeHierarchyBuilder(getResources())
|
|
76
|
+
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
|
|
77
|
+
.setFadeDuration(0)
|
|
78
|
+
.build();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
// seems like apple users north west, south east
|
|
83
|
+
// google uses north east, south west
|
|
84
|
+
private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds) {
|
|
85
|
+
double lat1 = bounds.getArray(0).getDouble(0);
|
|
86
|
+
double lon1 = bounds.getArray(0).getDouble(1);
|
|
87
|
+
double lat2 = bounds.getArray(1).getDouble(0);
|
|
88
|
+
double lon2 = bounds.getArray(1).getDouble(1);
|
|
89
|
+
|
|
90
|
+
// Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
|
|
91
|
+
double southLat = Math.min(lat1, lat2);
|
|
92
|
+
double northLat = Math.max(lat1, lat2);
|
|
93
|
+
double westLon = Math.min(lon1, lon2);
|
|
94
|
+
double eastLon = Math.max(lon1, lon2);
|
|
95
|
+
|
|
96
|
+
// Create corrected LatLngs
|
|
97
|
+
LatLng sw = new LatLng(southLat, westLon);
|
|
98
|
+
LatLng ne = new LatLng(northLat, eastLon);
|
|
99
|
+
return new LatLngBounds(sw, ne);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public void setBounds(ReadableArray bounds) {
|
|
103
|
+
|
|
104
|
+
this.bounds = fixBoundsIfNecessary(bounds);
|
|
105
|
+
if (this.groundOverlay != null) {
|
|
106
|
+
this.groundOverlay.setPositionFromBounds(this.bounds);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public void setBearing(float bearing) {
|
|
111
|
+
this.bearing = bearing;
|
|
112
|
+
if (this.groundOverlay != null) {
|
|
113
|
+
this.groundOverlay.setBearing(bearing);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public void setZIndex(float zIndex) {
|
|
118
|
+
this.zIndex = zIndex;
|
|
119
|
+
if (this.groundOverlay != null) {
|
|
120
|
+
this.groundOverlay.setZIndex(zIndex);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public void setTransparency(float transparency) {
|
|
125
|
+
this.transparency = transparency;
|
|
126
|
+
if (groundOverlay != null) {
|
|
127
|
+
groundOverlay.setTransparency(transparency);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
public void setImage(String uri) {
|
|
133
|
+
boolean shouldLoadImage = true;
|
|
134
|
+
|
|
135
|
+
this.imageUri = uri;
|
|
136
|
+
if (!shouldLoadImage) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (uri == null) {
|
|
141
|
+
bitmapDescriptor = null;
|
|
142
|
+
} else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
143
|
+
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
144
|
+
|
|
145
|
+
ImageRequest imageRequest = ImageRequestBuilder
|
|
146
|
+
.newBuilderWithSource(Uri.parse(uri))
|
|
147
|
+
.build();
|
|
148
|
+
|
|
149
|
+
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
150
|
+
dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
151
|
+
|
|
152
|
+
DataSubscriber<CloseableReference<CloseableImage>> subscriber = new BaseDataSubscriber<CloseableReference<CloseableImage>>() {
|
|
153
|
+
@Override
|
|
154
|
+
protected void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
|
155
|
+
if (!dataSource.isFinished()) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
CloseableReference<CloseableImage> imageReference = dataSource.getResult();
|
|
160
|
+
if (imageReference != null) {
|
|
161
|
+
try {
|
|
162
|
+
CloseableImage closeableImage = imageReference.get();
|
|
163
|
+
if (closeableImage instanceof CloseableBitmap) {
|
|
164
|
+
Bitmap bitmap = ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
|
|
165
|
+
if (bitmap != null) {
|
|
166
|
+
bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} finally {
|
|
170
|
+
CloseableReference.closeSafely(imageReference);
|
|
171
|
+
}
|
|
172
|
+
new Handler(Looper.getMainLooper()).post(() -> update());
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@Override
|
|
177
|
+
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
|
178
|
+
// Handle failure
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
dataSource.subscribe(subscriber, Executors.newSingleThreadExecutor());
|
|
183
|
+
|
|
184
|
+
} else {
|
|
185
|
+
bitmapDescriptor = getBitmapDescriptorByName(uri);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
private BitmapDescriptor getBitmapDescriptorByName(String name) {
|
|
191
|
+
return BitmapDescriptorFactory.fromResource(getDrawableResourceByName(name));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private int getDrawableResourceByName(String name) {
|
|
195
|
+
return getResources().getIdentifier(
|
|
196
|
+
name,
|
|
197
|
+
"drawable",
|
|
198
|
+
getContext().getPackageName());
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public void setTappable(boolean tapabble) {
|
|
202
|
+
this.tappable = tapabble;
|
|
203
|
+
if (groundOverlay != null) {
|
|
204
|
+
groundOverlay.setClickable(tappable);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
209
|
+
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
210
|
+
builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
|
|
211
|
+
return builder.build();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public GroundOverlayOptions getGroundOverlayOptions() {
|
|
215
|
+
if (this.groundOverlayOptions == null) {
|
|
216
|
+
this.groundOverlayOptions = createGroundOverlayOptions();
|
|
217
|
+
}
|
|
218
|
+
return this.groundOverlayOptions;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private GroundOverlayOptions createGroundOverlayOptions() {
|
|
222
|
+
if (this.groundOverlayOptions != null) {
|
|
223
|
+
return this.groundOverlayOptions;
|
|
224
|
+
}
|
|
225
|
+
GroundOverlayOptions options = new GroundOverlayOptions();
|
|
226
|
+
if (this.bitmapDescriptor != null) {
|
|
227
|
+
options.image(bitmapDescriptor);
|
|
228
|
+
} else {
|
|
229
|
+
// add stub image to be able to instantiate the overlay
|
|
230
|
+
// and store a reference to it in MapView
|
|
231
|
+
options.image(BitmapDescriptorFactory.defaultMarker());
|
|
232
|
+
// hide overlay until real image gets added
|
|
233
|
+
options.visible(false);
|
|
234
|
+
}
|
|
235
|
+
options.positionFromBounds(bounds);
|
|
236
|
+
options.zIndex(zIndex);
|
|
237
|
+
options.bearing(bearing);
|
|
238
|
+
// options.transparency(transparency);
|
|
239
|
+
return options;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@Override
|
|
243
|
+
public Object getFeature() {
|
|
244
|
+
return groundOverlay;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Override
|
|
248
|
+
public void addToMap(Object collection) {
|
|
249
|
+
GroundOverlayManager.Collection groundOverlayCollection = (GroundOverlayManager.Collection) collection;
|
|
250
|
+
GroundOverlayOptions groundOverlayOptions = getGroundOverlayOptions();
|
|
251
|
+
if (groundOverlayOptions != null) {
|
|
252
|
+
groundOverlay = groundOverlayCollection.addGroundOverlay(groundOverlayOptions);
|
|
253
|
+
groundOverlay.setClickable(this.tappable);
|
|
254
|
+
} else {
|
|
255
|
+
this.groundOverlayCollection = groundOverlayCollection;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@Override
|
|
260
|
+
public void removeFromMap(Object collection) {
|
|
261
|
+
if (groundOverlay != null) {
|
|
262
|
+
GroundOverlayManager.Collection groundOverlayCollection = (GroundOverlayManager.Collection) collection;
|
|
263
|
+
groundOverlayCollection.remove(groundOverlay);
|
|
264
|
+
groundOverlay = null;
|
|
265
|
+
groundOverlayOptions = null;
|
|
266
|
+
}
|
|
267
|
+
groundOverlayCollection = null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@Override
|
|
271
|
+
public void setIconBitmap(Bitmap bitmap) {
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@Override
|
|
275
|
+
public void setBitmapDescriptor(
|
|
276
|
+
BitmapDescriptor bitmapDescriptor) {
|
|
277
|
+
this.bitmapDescriptor = bitmapDescriptor;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@Override
|
|
281
|
+
public void update() {
|
|
282
|
+
this.groundOverlay = getGroundOverlay();
|
|
283
|
+
if (this.groundOverlay != null) {
|
|
284
|
+
this.groundOverlay.setVisible(true);
|
|
285
|
+
this.groundOverlay.setImage(this.bitmapDescriptor);
|
|
286
|
+
// this.groundOverlay.setTransparency(this.transparency);
|
|
287
|
+
this.groundOverlay.setClickable(this.tappable);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private GroundOverlay getGroundOverlay() {
|
|
292
|
+
if (this.groundOverlay != null) {
|
|
293
|
+
return this.groundOverlay;
|
|
294
|
+
}
|
|
295
|
+
if (this.groundOverlayCollection == null) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
GroundOverlayOptions groundOverlayOptions = getGroundOverlayOptions();
|
|
299
|
+
if (groundOverlayOptions != null) {
|
|
300
|
+
return this.groundOverlayCollection.addGroundOverlay(groundOverlayOptions);
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
166
304
|
}
|
|
@@ -22,6 +22,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDe
|
|
|
22
22
|
registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
|
|
23
23
|
registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
|
|
24
24
|
registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
|
|
25
|
+
registry->add(concreteComponentDescriptorProvider<RNMapsOverlayComponentDescriptor>());
|
|
25
26
|
registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -22,6 +22,7 @@ using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMap
|
|
|
22
22
|
using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
|
|
23
23
|
using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
|
|
24
24
|
using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
|
|
25
|
+
using RNMapsOverlayComponentDescriptor = ConcreteComponentDescriptor<RNMapsOverlayShadowNode>;
|
|
25
26
|
using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
|
|
26
27
|
|
|
27
28
|
void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
|
|
@@ -938,6 +938,28 @@ $payload.setProperty(runtime, "id", $event.id);
|
|
|
938
938
|
}
|
|
939
939
|
|
|
940
940
|
|
|
941
|
+
void RNMapsOverlayEventEmitter::onPress(OnPress $event) const {
|
|
942
|
+
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
|
+
auto $payload = jsi::Object(runtime);
|
|
944
|
+
$payload.setProperty(runtime, "action", $event.action);
|
|
945
|
+
$payload.setProperty(runtime, "id", $event.id);
|
|
946
|
+
{
|
|
947
|
+
auto coordinate = jsi::Object(runtime);
|
|
948
|
+
coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
|
|
949
|
+
coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
|
|
950
|
+
$payload.setProperty(runtime, "coordinate", coordinate);
|
|
951
|
+
}
|
|
952
|
+
{
|
|
953
|
+
auto position = jsi::Object(runtime);
|
|
954
|
+
position.setProperty(runtime, "x", $event.position.x);
|
|
955
|
+
position.setProperty(runtime, "y", $event.position.y);
|
|
956
|
+
$payload.setProperty(runtime, "position", position);
|
|
957
|
+
}
|
|
958
|
+
return $payload;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
|
|
941
963
|
void RNMapsPolylineEventEmitter::onPress(OnPress $event) const {
|
|
942
964
|
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
965
|
auto $payload = jsi::Object(runtime);
|
|
@@ -806,6 +806,28 @@ class RNMapsMarkerEventEmitter : public ViewEventEmitter {
|
|
|
806
806
|
|
|
807
807
|
void onSelect(OnSelect value) const;
|
|
808
808
|
};
|
|
809
|
+
class RNMapsOverlayEventEmitter : public ViewEventEmitter {
|
|
810
|
+
public:
|
|
811
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
812
|
+
|
|
813
|
+
struct OnPressCoordinate {
|
|
814
|
+
double latitude;
|
|
815
|
+
double longitude;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
struct OnPressPosition {
|
|
819
|
+
double x;
|
|
820
|
+
double y;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
struct OnPress {
|
|
824
|
+
std::string action;
|
|
825
|
+
std::string id;
|
|
826
|
+
OnPressCoordinate coordinate;
|
|
827
|
+
OnPressPosition position;
|
|
828
|
+
};
|
|
829
|
+
void onPress(OnPress value) const;
|
|
830
|
+
};
|
|
809
831
|
class RNMapsPolylineEventEmitter : public ViewEventEmitter {
|
|
810
832
|
public:
|
|
811
833
|
using ViewEventEmitter::ViewEventEmitter;
|
|
@@ -163,6 +163,17 @@ RNMapsMarkerProps::RNMapsMarkerProps(
|
|
|
163
163
|
subtitleVisibility(convertRawProp(context, rawProps, "subtitleVisibility", sourceProps.subtitleVisibility, {RNMapsMarkerSubtitleVisibility::Adaptive})),
|
|
164
164
|
useLegacyPinView(convertRawProp(context, rawProps, "useLegacyPinView", sourceProps.useLegacyPinView, {false}))
|
|
165
165
|
{}
|
|
166
|
+
RNMapsOverlayProps::RNMapsOverlayProps(
|
|
167
|
+
const PropsParserContext &context,
|
|
168
|
+
const RNMapsOverlayProps &sourceProps,
|
|
169
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
170
|
+
|
|
171
|
+
bearing(convertRawProp(context, rawProps, "bearing", sourceProps.bearing, {0.0})),
|
|
172
|
+
bounds(convertRawProp(context, rawProps, "bounds", sourceProps.bounds, {})),
|
|
173
|
+
image(convertRawProp(context, rawProps, "image", sourceProps.image, {})),
|
|
174
|
+
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {1.0})),
|
|
175
|
+
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
176
|
+
{}
|
|
166
177
|
RNMapsPolylineProps::RNMapsPolylineProps(
|
|
167
178
|
const PropsParserContext &context,
|
|
168
179
|
const RNMapsPolylineProps &sourceProps,
|
|
@@ -1092,6 +1092,51 @@ class RNMapsMarkerProps final : public ViewProps {
|
|
|
1092
1092
|
bool useLegacyPinView{false};
|
|
1093
1093
|
};
|
|
1094
1094
|
|
|
1095
|
+
struct RNMapsOverlayBoundsStruct {
|
|
1096
|
+
double latitude{0.0};
|
|
1097
|
+
double longitude{0.0};
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
|
|
1101
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1102
|
+
|
|
1103
|
+
auto tmp_latitude = map.find("latitude");
|
|
1104
|
+
if (tmp_latitude != map.end()) {
|
|
1105
|
+
fromRawValue(context, tmp_latitude->second, result.latitude);
|
|
1106
|
+
}
|
|
1107
|
+
auto tmp_longitude = map.find("longitude");
|
|
1108
|
+
if (tmp_longitude != map.end()) {
|
|
1109
|
+
fromRawValue(context, tmp_longitude->second, result.longitude);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
|
|
1114
|
+
return "[Object RNMapsOverlayBoundsStruct]";
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNMapsOverlayBoundsStruct> &result) {
|
|
1118
|
+
auto items = (std::vector<RawValue>)value;
|
|
1119
|
+
for (const auto &item : items) {
|
|
1120
|
+
RNMapsOverlayBoundsStruct newItem;
|
|
1121
|
+
fromRawValue(context, item, newItem);
|
|
1122
|
+
result.emplace_back(newItem);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
class RNMapsOverlayProps final : public ViewProps {
|
|
1127
|
+
public:
|
|
1128
|
+
RNMapsOverlayProps() = default;
|
|
1129
|
+
RNMapsOverlayProps(const PropsParserContext& context, const RNMapsOverlayProps &sourceProps, const RawProps &rawProps);
|
|
1130
|
+
|
|
1131
|
+
#pragma mark - Props
|
|
1132
|
+
|
|
1133
|
+
Float bearing{0.0};
|
|
1134
|
+
std::vector<RNMapsOverlayBoundsStruct> bounds{};
|
|
1135
|
+
ImageSource image{};
|
|
1136
|
+
Float opacity{1.0};
|
|
1137
|
+
bool tappable{false};
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1095
1140
|
enum class RNMapsPolylineLineCap { Butt, Round, Square };
|
|
1096
1141
|
|
|
1097
1142
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineLineCap &result) {
|
|
@@ -18,6 +18,7 @@ extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
|
|
|
18
18
|
extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
|
|
19
19
|
extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
|
|
20
20
|
extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
|
|
21
|
+
extern const char RNMapsOverlayComponentName[] = "RNMapsOverlay";
|
|
21
22
|
extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
|
|
22
23
|
|
|
23
24
|
} // namespace facebook::react
|
|
@@ -84,6 +84,17 @@ using RNMapsMarkerShadowNode = ConcreteViewShadowNode<
|
|
|
84
84
|
RNMapsMarkerEventEmitter,
|
|
85
85
|
RNMapsMarkerState>;
|
|
86
86
|
|
|
87
|
+
JSI_EXPORT extern const char RNMapsOverlayComponentName[];
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* `ShadowNode` for <RNMapsOverlay> component.
|
|
91
|
+
*/
|
|
92
|
+
using RNMapsOverlayShadowNode = ConcreteViewShadowNode<
|
|
93
|
+
RNMapsOverlayComponentName,
|
|
94
|
+
RNMapsOverlayProps,
|
|
95
|
+
RNMapsOverlayEventEmitter,
|
|
96
|
+
RNMapsOverlayState>;
|
|
97
|
+
|
|
87
98
|
JSI_EXPORT extern const char RNMapsPolylineComponentName[];
|
|
88
99
|
|
|
89
100
|
/*
|
|
@@ -86,6 +86,18 @@ public:
|
|
|
86
86
|
#endif
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
class RNMapsOverlayState {
|
|
90
|
+
public:
|
|
91
|
+
RNMapsOverlayState() = default;
|
|
92
|
+
|
|
93
|
+
#ifdef ANDROID
|
|
94
|
+
RNMapsOverlayState(RNMapsOverlayState const &previousState, folly::dynamic data){};
|
|
95
|
+
folly::dynamic getDynamic() const {
|
|
96
|
+
return {};
|
|
97
|
+
};
|
|
98
|
+
#endif
|
|
99
|
+
};
|
|
100
|
+
|
|
89
101
|
class RNMapsPolylineState {
|
|
90
102
|
public:
|
|
91
103
|
RNMapsPolylineState() = default;
|