react-native-maps 1.21.0-alpha.134 → 1.21.0-alpha.136
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/fabric/UrlTileManager.java +124 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +13 -2
- package/android/src/main/java/com/rnmaps/maps/MapUrlTile.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapUrlTileManager.java +0 -4
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +1 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +1 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +7 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +17 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +20 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +1 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +11 -0
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.h +12 -0
- package/ios/AirMaps/AIRMapMarker.m +57 -44
- package/package.json +1 -1
- package/src/decorateMapComponent.ts +4 -0
- package/src/specs/NativeComponentUrlTile.ts +128 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
package com.rnmaps.fabric;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
8
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
9
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
11
|
+
import com.facebook.react.viewmanagers.RNMapsUrlTileManagerDelegate;
|
|
12
|
+
import com.facebook.react.viewmanagers.RNMapsUrlTileManagerInterface;
|
|
13
|
+
import com.rnmaps.maps.MapPolyline;
|
|
14
|
+
import com.rnmaps.maps.MapUrlTile;
|
|
15
|
+
|
|
16
|
+
import java.util.HashMap;
|
|
17
|
+
import java.util.Map;
|
|
18
|
+
|
|
19
|
+
@ReactModule(name = UrlTileManager.REACT_CLASS)
|
|
20
|
+
public class UrlTileManager extends ViewGroupManager<MapUrlTile> implements RNMapsUrlTileManagerInterface<MapUrlTile> {
|
|
21
|
+
public static final String REACT_CLASS = "RNMapsUrlTile";
|
|
22
|
+
|
|
23
|
+
public UrlTileManager(ReactApplicationContext context) {
|
|
24
|
+
super(context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private final RNMapsUrlTileManagerDelegate<MapUrlTile, UrlTileManager> delegate =
|
|
28
|
+
new RNMapsUrlTileManagerDelegate<>(this);
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public ViewManagerDelegate<MapUrlTile> getDelegate() {
|
|
32
|
+
return delegate;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public String getName() {
|
|
37
|
+
return REACT_CLASS;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public MapUrlTile createViewInstance(ThemedReactContext context) {
|
|
42
|
+
return new MapUrlTile(context);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@Nullable
|
|
47
|
+
@Override
|
|
48
|
+
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
49
|
+
return new HashMap<>();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Nullable
|
|
53
|
+
@Override
|
|
54
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
55
|
+
return new HashMap<>();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Override
|
|
59
|
+
public void setDoubleTileSize(MapUrlTile view, boolean value) {
|
|
60
|
+
view.setDoubleTileSize(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public void setFlipY(MapUrlTile view, boolean value) {
|
|
65
|
+
view.setFlipY(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public void setMaximumNativeZ(MapUrlTile view, int value) {
|
|
70
|
+
view.setMaximumNativeZ(value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public void setMaximumZ(MapUrlTile view, int value) {
|
|
75
|
+
view.setMaximumZ(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
public void setMinimumZ(MapUrlTile view, int value) {
|
|
80
|
+
view.setMinimumZ(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Override
|
|
84
|
+
public void setOfflineMode(MapUrlTile view, boolean value) {
|
|
85
|
+
view.setOfflineMode(value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Override
|
|
89
|
+
public void setShouldReplaceMapContent(MapUrlTile view, boolean value) {
|
|
90
|
+
// not supported
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
@Override
|
|
94
|
+
public void setZIndex(@NonNull MapUrlTile view, float zIndex) {
|
|
95
|
+
super.setZIndex(view, zIndex);
|
|
96
|
+
view.setZIndex(zIndex);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
public void setOpacity(@NonNull MapUrlTile view, float opacity) {
|
|
101
|
+
super.setOpacity(view, opacity);
|
|
102
|
+
view.setOpacity(opacity);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Override
|
|
106
|
+
public void setTileCacheMaxAge(MapUrlTile view, int value) {
|
|
107
|
+
view.setTileCacheMaxAge(value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
public void setTileCachePath(MapUrlTile view, @Nullable String value) {
|
|
112
|
+
view.setTileCachePath(value);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Override
|
|
116
|
+
public void setTileSize(MapUrlTile view, int value) {
|
|
117
|
+
view.setTileSize(value);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@Override
|
|
121
|
+
public void setUrlTemplate(MapUrlTile view, @Nullable String value) {
|
|
122
|
+
view.setUrlTemplate(value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -17,6 +17,7 @@ import com.rnmaps.fabric.NativeAirMapsModule;
|
|
|
17
17
|
import com.rnmaps.fabric.OverlayManager;
|
|
18
18
|
import com.rnmaps.fabric.PolygonManager;
|
|
19
19
|
import com.rnmaps.fabric.PolylineManager;
|
|
20
|
+
import com.rnmaps.fabric.UrlTileManager;
|
|
20
21
|
|
|
21
22
|
import java.util.HashMap;
|
|
22
23
|
import java.util.List;
|
|
@@ -26,7 +27,14 @@ public class MapAirModulePackage extends TurboReactPackage {
|
|
|
26
27
|
|
|
27
28
|
@Override
|
|
28
29
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
29
|
-
return List.of(new MapViewManager(reactContext),
|
|
30
|
+
return List.of(new MapViewManager(reactContext),
|
|
31
|
+
new MarkerManager(reactContext),
|
|
32
|
+
new CalloutManager(reactContext),
|
|
33
|
+
new PolygonManager(reactContext),
|
|
34
|
+
new PolylineManager(reactContext),
|
|
35
|
+
new CircleManager(reactContext),
|
|
36
|
+
new OverlayManager(reactContext),
|
|
37
|
+
new UrlTileManager(reactContext));
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
|
|
@@ -53,8 +61,11 @@ public class MapAirModulePackage extends TurboReactPackage {
|
|
|
53
61
|
if (MapViewManager.REACT_CLASS.equals(name)) {
|
|
54
62
|
return new MapViewManager(reactContext);
|
|
55
63
|
}
|
|
64
|
+
if (UrlTileManager.REACT_CLASS.equals(name)) {
|
|
65
|
+
return new UrlTileManager(reactContext);
|
|
66
|
+
}
|
|
56
67
|
if (NativeAirMapsModuleSpec.NAME.equals(name)) {
|
|
57
|
-
return
|
|
68
|
+
return new NativeAirMapsModule(reactContext);
|
|
58
69
|
} else {
|
|
59
70
|
return null;
|
|
60
71
|
}
|
|
@@ -13,10 +13,6 @@ public class MapUrlTileManager extends ViewGroupManager<MapUrlTile> {
|
|
|
13
13
|
|
|
14
14
|
public MapUrlTileManager(ReactApplicationContext reactContext) {
|
|
15
15
|
super();
|
|
16
|
-
DisplayMetrics metrics = new DisplayMetrics();
|
|
17
|
-
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
18
|
-
.getDefaultDisplay()
|
|
19
|
-
.getRealMetrics(metrics);
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
@Override
|
|
@@ -24,6 +24,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescript
|
|
|
24
24
|
registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
|
|
25
25
|
registry->add(concreteComponentDescriptorProvider<RNMapsOverlayComponentDescriptor>());
|
|
26
26
|
registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
|
|
27
|
+
registry->add(concreteComponentDescriptorProvider<RNMapsUrlTileComponentDescriptor>());
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
} // namespace facebook::react
|
|
@@ -24,6 +24,7 @@ using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapVi
|
|
|
24
24
|
using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
|
|
25
25
|
using RNMapsOverlayComponentDescriptor = ConcreteComponentDescriptor<RNMapsOverlayShadowNode>;
|
|
26
26
|
using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
|
|
27
|
+
using RNMapsUrlTileComponentDescriptor = ConcreteComponentDescriptor<RNMapsUrlTileShadowNode>;
|
|
27
28
|
|
|
28
29
|
void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
|
|
29
30
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
@@ -842,5 +842,12 @@ class RNMapsPolylineEventEmitter : public ViewEventEmitter {
|
|
|
842
842
|
OnPressPosition position;
|
|
843
843
|
};
|
|
844
844
|
void onPress(OnPress value) const;
|
|
845
|
+
};
|
|
846
|
+
class RNMapsUrlTileEventEmitter : public ViewEventEmitter {
|
|
847
|
+
public:
|
|
848
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
845
852
|
};
|
|
846
853
|
} // namespace facebook::react
|
|
@@ -191,5 +191,22 @@ RNMapsPolylineProps::RNMapsPolylineProps(
|
|
|
191
191
|
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {0.0})),
|
|
192
192
|
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
193
193
|
{}
|
|
194
|
+
RNMapsUrlTileProps::RNMapsUrlTileProps(
|
|
195
|
+
const PropsParserContext &context,
|
|
196
|
+
const RNMapsUrlTileProps &sourceProps,
|
|
197
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
198
|
+
|
|
199
|
+
doubleTileSize(convertRawProp(context, rawProps, "doubleTileSize", sourceProps.doubleTileSize, {false})),
|
|
200
|
+
flipY(convertRawProp(context, rawProps, "flipY", sourceProps.flipY, {false})),
|
|
201
|
+
maximumNativeZ(convertRawProp(context, rawProps, "maximumNativeZ", sourceProps.maximumNativeZ, {0})),
|
|
202
|
+
maximumZ(convertRawProp(context, rawProps, "maximumZ", sourceProps.maximumZ, {0})),
|
|
203
|
+
minimumZ(convertRawProp(context, rawProps, "minimumZ", sourceProps.minimumZ, {0})),
|
|
204
|
+
offlineMode(convertRawProp(context, rawProps, "offlineMode", sourceProps.offlineMode, {false})),
|
|
205
|
+
shouldReplaceMapContent(convertRawProp(context, rawProps, "shouldReplaceMapContent", sourceProps.shouldReplaceMapContent, {false})),
|
|
206
|
+
tileCacheMaxAge(convertRawProp(context, rawProps, "tileCacheMaxAge", sourceProps.tileCacheMaxAge, {0})),
|
|
207
|
+
tileCachePath(convertRawProp(context, rawProps, "tileCachePath", sourceProps.tileCachePath, {})),
|
|
208
|
+
tileSize(convertRawProp(context, rawProps, "tileSize", sourceProps.tileSize, {0})),
|
|
209
|
+
urlTemplate(convertRawProp(context, rawProps, "urlTemplate", sourceProps.urlTemplate, {}))
|
|
210
|
+
{}
|
|
194
211
|
|
|
195
212
|
} // namespace facebook::react
|
|
@@ -1222,4 +1222,24 @@ class RNMapsPolylineProps final : public ViewProps {
|
|
|
1222
1222
|
bool tappable{false};
|
|
1223
1223
|
};
|
|
1224
1224
|
|
|
1225
|
+
class RNMapsUrlTileProps final : public ViewProps {
|
|
1226
|
+
public:
|
|
1227
|
+
RNMapsUrlTileProps() = default;
|
|
1228
|
+
RNMapsUrlTileProps(const PropsParserContext& context, const RNMapsUrlTileProps &sourceProps, const RawProps &rawProps);
|
|
1229
|
+
|
|
1230
|
+
#pragma mark - Props
|
|
1231
|
+
|
|
1232
|
+
bool doubleTileSize{false};
|
|
1233
|
+
bool flipY{false};
|
|
1234
|
+
int maximumNativeZ{0};
|
|
1235
|
+
int maximumZ{0};
|
|
1236
|
+
int minimumZ{0};
|
|
1237
|
+
bool offlineMode{false};
|
|
1238
|
+
bool shouldReplaceMapContent{false};
|
|
1239
|
+
int tileCacheMaxAge{0};
|
|
1240
|
+
std::string tileCachePath{};
|
|
1241
|
+
int tileSize{0};
|
|
1242
|
+
std::string urlTemplate{};
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1225
1245
|
} // namespace facebook::react
|
|
@@ -20,5 +20,6 @@ extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
|
|
|
20
20
|
extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
|
|
21
21
|
extern const char RNMapsOverlayComponentName[] = "RNMapsOverlay";
|
|
22
22
|
extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
|
|
23
|
+
extern const char RNMapsUrlTileComponentName[] = "RNMapsUrlTile";
|
|
23
24
|
|
|
24
25
|
} // namespace facebook::react
|
|
@@ -106,4 +106,15 @@ using RNMapsPolylineShadowNode = ConcreteViewShadowNode<
|
|
|
106
106
|
RNMapsPolylineEventEmitter,
|
|
107
107
|
RNMapsPolylineState>;
|
|
108
108
|
|
|
109
|
+
JSI_EXPORT extern const char RNMapsUrlTileComponentName[];
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* `ShadowNode` for <RNMapsUrlTile> component.
|
|
113
|
+
*/
|
|
114
|
+
using RNMapsUrlTileShadowNode = ConcreteViewShadowNode<
|
|
115
|
+
RNMapsUrlTileComponentName,
|
|
116
|
+
RNMapsUrlTileProps,
|
|
117
|
+
RNMapsUrlTileEventEmitter,
|
|
118
|
+
RNMapsUrlTileState>;
|
|
119
|
+
|
|
109
120
|
} // namespace facebook::react
|
|
@@ -110,4 +110,16 @@ public:
|
|
|
110
110
|
#endif
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
class RNMapsUrlTileState {
|
|
114
|
+
public:
|
|
115
|
+
RNMapsUrlTileState() = default;
|
|
116
|
+
|
|
117
|
+
#ifdef ANDROID
|
|
118
|
+
RNMapsUrlTileState(RNMapsUrlTileState const &previousState, folly::dynamic data){};
|
|
119
|
+
folly::dynamic getDynamic() const {
|
|
120
|
+
return {};
|
|
121
|
+
};
|
|
122
|
+
#endif
|
|
123
|
+
};
|
|
124
|
+
|
|
113
125
|
} // namespace facebook::react
|
|
@@ -30,7 +30,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
30
30
|
BOOL _calloutIsOpen;
|
|
31
31
|
NSInteger _zIndexBeforeOpen;
|
|
32
32
|
BOOL _useLegacyPinView;
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
CADisplayLink *_displayLink;
|
|
35
35
|
CLLocationCoordinate2D _startCoordinate;
|
|
36
36
|
CLLocationCoordinate2D _endCoordinate;
|
|
@@ -52,13 +52,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
52
52
|
// Make sure we use the image size when available
|
|
53
53
|
CGSize size = self.image ? self.image.size : frame.size;
|
|
54
54
|
CGRect bounds = {CGPointZero, size};
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
// The MapView is basically in charge of figuring out the center position of the marker view. If the view changed in
|
|
57
57
|
// height though, we need to compensate in such a way that the bottom of the marker stays at the same spot on the
|
|
58
58
|
// map.
|
|
59
59
|
CGFloat dy = (bounds.size.height - self.bounds.size.height) / 2;
|
|
60
60
|
CGPoint center = (CGPoint){ self.center.x, self.center.y - dy };
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
// Avoid crashes due to nan coords
|
|
63
63
|
if (isnan(center.x) || isnan(center.y) ||
|
|
64
64
|
isnan(bounds.origin.x) || isnan(bounds.origin.y) ||
|
|
@@ -67,7 +67,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
67
67
|
self.reactTag, self, NSStringFromCGPoint(center), NSStringFromCGRect(bounds));
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
self.center = center;
|
|
72
72
|
self.bounds = bounds;
|
|
73
73
|
}
|
|
@@ -102,31 +102,31 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
102
102
|
{
|
|
103
103
|
if ([self shouldUsePinView]) {
|
|
104
104
|
// In this case, we want to render a platform "default" legacy marker.
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
|
|
106
|
+
|
|
107
107
|
if (_pinView == nil && _useLegacyPinView) {
|
|
108
108
|
_pinView = [[MKPinAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
|
|
109
109
|
[self addGestureRecognizerToView:_pinView];
|
|
110
110
|
_pinView.annotation = self;
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
if ([_pinView respondsToSelector:@selector(setPinTintColor:)]) {
|
|
113
113
|
_pinView.pinTintColor = self.pinColor;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
_pinView.draggable = self.draggable;
|
|
117
117
|
_pinView.layer.zPosition = self.zIndex;
|
|
118
118
|
_pinView.displayPriority = self.displayPriority;
|
|
119
119
|
_pinView.zPriority = self.zIndex;
|
|
120
120
|
return _pinView;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
125
|
if (_markerView == nil && !_useLegacyPinView) {
|
|
126
126
|
_markerView = [[MKMarkerAnnotationView alloc] initWithAnnotation:self reuseIdentifier: nil];
|
|
127
127
|
[self addGestureRecognizerToView:_markerView];
|
|
128
128
|
_markerView.annotation = self;
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
_markerView.draggable = self.draggable;
|
|
131
131
|
_markerView.layer.zPosition = self.zIndex;
|
|
132
132
|
_markerView.markerTintColor = self.pinColor;
|
|
@@ -135,7 +135,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
135
135
|
_markerView.displayPriority = self.displayPriority;
|
|
136
136
|
_markerView.zPriority = self.zIndex;
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
}
|
|
140
140
|
return _markerView ?: _pinView;
|
|
141
141
|
} else {
|
|
@@ -152,14 +152,14 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
152
152
|
- (void)fillCalloutView:(SMCalloutView *)calloutView
|
|
153
153
|
{
|
|
154
154
|
// Set everything necessary on the calloutView before it becomes visible.
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
// Apply the MKAnnotationView's desired calloutOffset (from the top-middle of the view)
|
|
157
157
|
if ([self shouldUsePinView] && !_hasSetCalloutOffset && _useLegacyPinView) {
|
|
158
158
|
calloutView.calloutOffset = CGPointMake(-8,0);
|
|
159
159
|
} else {
|
|
160
160
|
calloutView.calloutOffset = self.calloutOffset;
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
if (self.calloutView) {
|
|
164
164
|
calloutView.title = nil;
|
|
165
165
|
calloutView.subtitle = nil;
|
|
@@ -172,13 +172,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
172
172
|
// as a result, we use the default "masked" background view.
|
|
173
173
|
calloutView.backgroundView = [SMCalloutMaskedBackgroundView new];
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
// when this is set, the callout's content will be whatever react views the user has put as the callout's
|
|
177
177
|
// children.
|
|
178
178
|
calloutView.contentView = self.calloutView;
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
} else {
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
// if there is no calloutView, it means the user wants to use the default callout behavior with title/subtitle
|
|
183
183
|
// pairs.
|
|
184
184
|
calloutView.title = self.title;
|
|
@@ -192,12 +192,12 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
192
192
|
{
|
|
193
193
|
_calloutIsOpen = YES;
|
|
194
194
|
[self setZIndex:_zIndexBeforeOpen];
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
MKAnnotationView *annotationView = [self getAnnotationView];
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
[self setSelected:YES animated:NO];
|
|
199
199
|
[self.map selectAnnotation:self animated:NO];
|
|
200
|
-
|
|
200
|
+
|
|
201
201
|
id event = @{
|
|
202
202
|
@"action": @"marker-select",
|
|
203
203
|
@"id": self.identifier ?: @"unknown",
|
|
@@ -206,17 +206,17 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
206
206
|
@"longitude": @(self.coordinate.longitude)
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
if (self.map.onMarkerSelect) self.map.onMarkerSelect(event);
|
|
211
211
|
if (self.onSelect) self.onSelect(event);
|
|
212
|
-
|
|
212
|
+
|
|
213
213
|
if (![self shouldShowCalloutView]) {
|
|
214
214
|
// no callout to show
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
[self fillCalloutView:self.map.calloutView];
|
|
219
|
-
|
|
219
|
+
|
|
220
220
|
// This is where we present our custom callout view... MapKit's built-in callout doesn't have the flexibility
|
|
221
221
|
// we need, but a lot of work was done by Nick Farina to make this identical to MapKit's built-in.
|
|
222
222
|
[self.map.calloutView presentCalloutFromRect:annotationView.bounds
|
|
@@ -244,12 +244,12 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
244
244
|
- (void)_handleTap:(UITapGestureRecognizer *)recognizer {
|
|
245
245
|
AIRMapMarker *marker = self;
|
|
246
246
|
if (!marker) return;
|
|
247
|
-
|
|
247
|
+
|
|
248
248
|
if (marker.selected) {
|
|
249
249
|
CGPoint touchPoint = [recognizer locationInView:marker.map.calloutView];
|
|
250
250
|
CGRect bubbleFrame = [self.calloutView convertRect:marker.map.calloutView.bounds toView:marker.map];
|
|
251
251
|
CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
|
|
252
|
-
|
|
252
|
+
|
|
253
253
|
UIView *calloutView = [marker.map.calloutView hitTest:touchPoint withEvent:nil];
|
|
254
254
|
if (calloutView) {
|
|
255
255
|
// the callout (or its subview) got clicked, not the marker
|
|
@@ -263,7 +263,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
263
263
|
}
|
|
264
264
|
tmp = tmp.superview;
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
id event = @{
|
|
268
268
|
@"action": calloutSubview ? @"callout-inside-press" : @"callout-press",
|
|
269
269
|
@"id": marker.identifier ?: @"unknown",
|
|
@@ -278,7 +278,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
278
278
|
@"height": @(bubbleFrame.size.height),
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
if (calloutSubview) calloutSubview.onPress(event);
|
|
283
283
|
if (marker.onCalloutPress) marker.onCalloutPress(event);
|
|
284
284
|
if (marker.calloutView && marker.calloutView.onPress) marker.calloutView.onPress(event);
|
|
@@ -286,7 +286,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
// the actual marker got clicked
|
|
291
291
|
CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
|
|
292
292
|
id event = @{
|
|
@@ -301,10 +301,10 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
301
301
|
@"y": @(touchPointReal.y),
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
|
-
|
|
304
|
+
|
|
305
305
|
if (marker.onPress) marker.onPress(event);
|
|
306
306
|
if (marker.map.onMarkerPress) marker.map.onMarkerPress(event);
|
|
307
|
-
|
|
307
|
+
|
|
308
308
|
[marker.map selectAnnotation:marker animated:NO];
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -314,10 +314,10 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
314
314
|
[self setZIndex:_zIndexBeforeOpen];
|
|
315
315
|
// hide the callout view
|
|
316
316
|
[self.map.calloutView dismissCalloutAnimated:YES];
|
|
317
|
-
|
|
317
|
+
|
|
318
318
|
[self setSelected:NO animated:NO];
|
|
319
319
|
[self.map deselectAnnotation:self animated:NO];
|
|
320
|
-
|
|
320
|
+
|
|
321
321
|
id event = @{
|
|
322
322
|
@"action": @"marker-deselect",
|
|
323
323
|
@"id": self.identifier ?: @"unknown",
|
|
@@ -326,7 +326,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
326
326
|
@"longitude": @(self.coordinate.longitude)
|
|
327
327
|
}
|
|
328
328
|
};
|
|
329
|
-
|
|
329
|
+
|
|
330
330
|
if (self.map.onMarkerDeselect) self.map.onMarkerDeselect(event);
|
|
331
331
|
if (self.onDeselect) self.onDeselect(event);
|
|
332
332
|
}
|
|
@@ -355,13 +355,13 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
355
355
|
- (void)setImageSrc:(NSString *)imageSrc
|
|
356
356
|
{
|
|
357
357
|
_imageSrc = imageSrc;
|
|
358
|
-
|
|
358
|
+
|
|
359
359
|
if (_reloadImageCancellationBlock) {
|
|
360
360
|
_reloadImageCancellationBlock();
|
|
361
361
|
_reloadImageCancellationBlock = nil;
|
|
362
362
|
}
|
|
363
363
|
__weak __typeof(self) weakSelf = self;
|
|
364
|
-
|
|
364
|
+
|
|
365
365
|
_reloadImageCancellationBlock = [[[RCTBridge currentBridge] moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
|
|
366
366
|
size:self.bounds.size
|
|
367
367
|
scale:RCTScreenScale()
|
|
@@ -384,7 +384,7 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
384
384
|
- (void)setPinColor:(UIColor *)pinColor
|
|
385
385
|
{
|
|
386
386
|
_pinColor = pinColor;
|
|
387
|
-
|
|
387
|
+
|
|
388
388
|
if(_useLegacyPinView && [_pinView respondsToSelector:@selector(setPinTintColor:)]) {
|
|
389
389
|
_pinView.pinTintColor = _pinColor;
|
|
390
390
|
} else {
|
|
@@ -412,6 +412,19 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
412
412
|
self.layer.zPosition = _zIndex;
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
+
- (void)layoutSubviews
|
|
416
|
+
{
|
|
417
|
+
[super layoutSubviews];
|
|
418
|
+
|
|
419
|
+
CGRect reactFrame = self.frame;
|
|
420
|
+
|
|
421
|
+
UIView *firstSubView = self.subviews.firstObject;
|
|
422
|
+
if (firstSubView && (CGRectGetWidth(firstSubView.frame) > CGRectGetWidth(reactFrame) ||
|
|
423
|
+
CGRectGetHeight(firstSubView.frame) > CGRectGetHeight(reactFrame))) {
|
|
424
|
+
reactFrame = firstSubView.frame;
|
|
425
|
+
}
|
|
426
|
+
[self reactSetFrame:reactFrame];
|
|
427
|
+
}
|
|
415
428
|
|
|
416
429
|
- (void)setUseLegacyPinView:(BOOL)value {
|
|
417
430
|
_useLegacyPinView = value;
|
|
@@ -422,16 +435,16 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
422
435
|
NSLog(@"Animation already in progress. Rejecting new animation request.");
|
|
423
436
|
return;
|
|
424
437
|
}
|
|
425
|
-
|
|
438
|
+
|
|
426
439
|
// Mark as animating
|
|
427
440
|
_isAnimating = YES;
|
|
428
|
-
|
|
441
|
+
|
|
429
442
|
// Store animation parameters
|
|
430
443
|
_startCoordinate = self.coordinate;
|
|
431
444
|
_endCoordinate = newCoordinate;
|
|
432
445
|
_animationDuration = duration;
|
|
433
446
|
_animationStartTime = [NSDate timeIntervalSinceReferenceDate];
|
|
434
|
-
|
|
447
|
+
|
|
435
448
|
// Start a CADisplayLink
|
|
436
449
|
if (_displayLink) {
|
|
437
450
|
[_displayLink invalidate];
|
|
@@ -443,15 +456,15 @@ NSInteger const AIR_CALLOUT_OPEN_ZINDEX_BASELINE = 999;
|
|
|
443
456
|
- (void)updatePosition {
|
|
444
457
|
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _animationStartTime;
|
|
445
458
|
CGFloat progress = MIN(elapsed / _animationDuration, 1.0);
|
|
446
|
-
|
|
459
|
+
|
|
447
460
|
// Interpolate coordinates
|
|
448
461
|
CLLocationDegrees currentLatitude = _startCoordinate.latitude + progress * (_endCoordinate.latitude - _startCoordinate.latitude);
|
|
449
462
|
CLLocationDegrees currentLongitude = _startCoordinate.longitude + progress * (_endCoordinate.longitude - _startCoordinate.longitude);
|
|
450
|
-
|
|
463
|
+
|
|
451
464
|
// Update annotation's coordinate
|
|
452
465
|
CLLocationCoordinate2D currentCoordinate = CLLocationCoordinate2DMake(currentLatitude, currentLongitude);
|
|
453
466
|
[self setValue:[NSValue valueWithMKCoordinate:currentCoordinate] forKey:@"coordinate"];
|
|
454
|
-
|
|
467
|
+
|
|
455
468
|
// Stop the animation when complete
|
|
456
469
|
if (progress == 1.0) {
|
|
457
470
|
[_displayLink invalidate];
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.21.0-alpha.
|
|
8
|
+
"version": "1.21.0-alpha.136",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -22,6 +22,7 @@ import {MapWMSTile} from './MapWMSTile';
|
|
|
22
22
|
import {Commands} from './MapViewNativeComponent';
|
|
23
23
|
import GooglePolygon from './specs/NativeComponentGooglePolygon';
|
|
24
24
|
import FabricMarker from './specs/NativeComponentMarker';
|
|
25
|
+
import FabricUrlTile from './specs/NativeComponentUrlTile';
|
|
25
26
|
import FabricCallout from './specs/NativeComponentCallout';
|
|
26
27
|
import FabricPolyline from './specs/NativeComponentPolyline';
|
|
27
28
|
import FabricCircle from './specs/NativeComponentCircle';
|
|
@@ -104,6 +105,9 @@ export default function decorateMapComponent<Type extends Component>(
|
|
|
104
105
|
} else if (componentName === 'Overlay') {
|
|
105
106
|
// @ts-ignore
|
|
106
107
|
return FabricOverlay;
|
|
108
|
+
} else if (componentName === 'UrlTile') {
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
return FabricUrlTile;
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
const key = provider || 'default';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type {HostComponent, ViewProps} from 'react-native';
|
|
2
|
+
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
import {Int32} from 'react-native/Libraries/Types/CodegenTypes';
|
|
5
|
+
|
|
6
|
+
export interface UrlTileFabricNativeProps extends ViewProps {
|
|
7
|
+
/**
|
|
8
|
+
* Doubles tile size from 256 to 512 utilising higher zoom levels
|
|
9
|
+
* i.e loading 4 higher zoom level tiles and combining them for one high-resolution tile.
|
|
10
|
+
* iOS does this automatically, even if it is not desirable always.
|
|
11
|
+
* NB! using this makes text labels smaller than in the original map style.
|
|
12
|
+
*
|
|
13
|
+
* @platform iOS: Not supported
|
|
14
|
+
* @platform Android: Supported
|
|
15
|
+
*/
|
|
16
|
+
doubleTileSize?: boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Allow tiles using the TMS coordinate system (origin bottom left) to be used,
|
|
20
|
+
* and displayed at their correct coordinates.
|
|
21
|
+
*
|
|
22
|
+
* @platform iOS: Supported
|
|
23
|
+
* @platform Android: Supported
|
|
24
|
+
*/
|
|
25
|
+
flipY?: boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The maximum native zoom level for this tile overlay i.e. the highest zoom level that the tile server provides.
|
|
29
|
+
* Tiles are auto-scaled for higher zoom levels.
|
|
30
|
+
*
|
|
31
|
+
* @platform iOS: Apple Maps only
|
|
32
|
+
* @platform Android: Supported
|
|
33
|
+
*/
|
|
34
|
+
maximumNativeZ?: Int32;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The maximum zoom level for this tile overlay.
|
|
38
|
+
*
|
|
39
|
+
* @platform iOS: Supported
|
|
40
|
+
* @platform Android: Supported
|
|
41
|
+
*/
|
|
42
|
+
maximumZ?: Int32;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The minimum zoom level for this tile overlay.
|
|
46
|
+
*
|
|
47
|
+
* @platform iOS: Supported
|
|
48
|
+
* @platform Android: Supported
|
|
49
|
+
*/
|
|
50
|
+
minimumZ?: Int32;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* In offline-mode tiles are not fetched from the tile servers, rather only tiles stored in the cache directory are used.
|
|
54
|
+
* Furthermore, automated tile scaling is activated: if tile at a desired zoom level is not found from the cache directory,
|
|
55
|
+
* then lower zoom level tile is used (up to 4 levels lower) and scaled.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
* @platform iOS: Apple Maps only
|
|
59
|
+
* @platform Android: Supported
|
|
60
|
+
*/
|
|
61
|
+
offlineMode?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Corresponds to MKTileOverlay canReplaceMapContent i.e. if true then underlying iOS basemap is not shown.
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
67
|
+
* @platform iOS: Apple Maps only
|
|
68
|
+
* @platform Android: Not supported
|
|
69
|
+
*/
|
|
70
|
+
shouldReplaceMapContent?: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Defines maximum age in seconds for a cached tile before it's refreshed.
|
|
74
|
+
*
|
|
75
|
+
* NB! Refresh logic is "serve-stale-while-refresh"
|
|
76
|
+
* i.e. to ensure map availability a stale (over max age) tile is served
|
|
77
|
+
* while a tile refresh process is started in the background.
|
|
78
|
+
*
|
|
79
|
+
* @platform iOS: Apple Maps only
|
|
80
|
+
* @platform Android: Supported
|
|
81
|
+
*/
|
|
82
|
+
tileCacheMaxAge?: Int32;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Enable caching of tiles in the specified directory.
|
|
86
|
+
* Directory can be specified either as a normal path or in URL format (`file://`).
|
|
87
|
+
*
|
|
88
|
+
* Tiles are stored in tileCachePath directory as `/{z}/{x}/{y}` i.e. in sub-directories 2-levels deep,
|
|
89
|
+
* filename is tile y-coordinate without any filetype-extension.
|
|
90
|
+
*
|
|
91
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles to manage use of storage space etc.
|
|
92
|
+
*
|
|
93
|
+
* @platform iOS: Apple Maps only
|
|
94
|
+
* @platform Android: Supported
|
|
95
|
+
*/
|
|
96
|
+
tileCachePath?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Tile size, default size is 256 (for tiles of 256 _ 256 pixels).
|
|
100
|
+
* High-res (aka 'retina') tiles are 512 (tiles of 512 _ 512 pixels)
|
|
101
|
+
*
|
|
102
|
+
* @platform iOS: Apple Maps only
|
|
103
|
+
* @platform Android: Supported
|
|
104
|
+
*/
|
|
105
|
+
tileSize?: Int32;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The url template of the map tileserver.
|
|
109
|
+
* (URLTile) The patterns {x} {y} {z} will be replaced at runtime.
|
|
110
|
+
* For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png.
|
|
111
|
+
*
|
|
112
|
+
* It is also possible to refer to tiles in local filesystem with file:///top-level-directory/sub-directory/{z}/{x}/{y}.png URL-format.
|
|
113
|
+
* (WMSTile) The patterns {minX} {maxX} {minY} {maxY} {width} {height} will be replaced at runtime according to EPSG:900913 specification bounding box.
|
|
114
|
+
* For example, https://demo.geo-solutions.it/geoserver/tiger/wms?service=WMS&version=1.1.0&request=GetMap&layers=tiger:poi&styles=&bbox={minX},{minY},{maxX},{maxY}&width={width}&height={height}&srs=EPSG:900913&format=image/png&transparent=true&format_options=dpi:213.
|
|
115
|
+
*
|
|
116
|
+
* @platform iOS: Supported
|
|
117
|
+
* @platform Android: Supported
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
urlTemplate: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default codegenNativeComponent<UrlTileFabricNativeProps>(
|
|
124
|
+
'RNMapsUrlTile',
|
|
125
|
+
{
|
|
126
|
+
excludedPlatforms: ['iOS'],
|
|
127
|
+
},
|
|
128
|
+
) as HostComponent<UrlTileFabricNativeProps>;
|