react-native-maps 1.0.0-beta.8 → 1.1.0-beta.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/airbnb/android/react/maps/AirMapManager.java +1 -1
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +41 -13
- package/ios/AirMaps/AIRMapManager.m +2 -3
- package/lib/MapView.d.ts +1 -9
- package/lib/MapView.js +7 -65
- package/package.json +13 -10
- package/react-native-google-maps.podspec +4 -5
- package/react-native-maps.podspec +4 -5
|
@@ -123,7 +123,7 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
123
123
|
|
|
124
124
|
@ReactProp(name = "customMapStyleString")
|
|
125
125
|
public void setMapStyle(AirMapView view, @Nullable String customMapStyleString) {
|
|
126
|
-
view.
|
|
126
|
+
view.setMapStyle(customMapStyleString);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
@ReactProp(name = "mapPadding")
|
|
@@ -9,6 +9,7 @@ import android.graphics.PorterDuff;
|
|
|
9
9
|
import android.graphics.Rect;
|
|
10
10
|
import android.os.Build;
|
|
11
11
|
|
|
12
|
+
import androidx.annotation.Nullable;
|
|
12
13
|
import androidx.core.content.PermissionChecker;
|
|
13
14
|
import androidx.core.view.GestureDetectorCompat;
|
|
14
15
|
import androidx.core.view.MotionEventCompat;
|
|
@@ -46,6 +47,7 @@ import com.google.android.gms.maps.model.CameraPosition;
|
|
|
46
47
|
import com.google.android.gms.maps.model.GroundOverlay;
|
|
47
48
|
import com.google.android.gms.maps.model.LatLng;
|
|
48
49
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
50
|
+
import com.google.android.gms.maps.model.MapStyleOptions;
|
|
49
51
|
import com.google.android.gms.maps.model.Marker;
|
|
50
52
|
import com.google.android.gms.maps.model.MarkerOptions;
|
|
51
53
|
import com.google.android.gms.maps.model.PointOfInterest;
|
|
@@ -92,6 +94,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
92
94
|
private boolean moveOnMarkerPress = true;
|
|
93
95
|
private boolean cacheEnabled = false;
|
|
94
96
|
private ReadableMap initialRegion;
|
|
97
|
+
private ReadableMap region;
|
|
98
|
+
private String customMapStyleString;
|
|
95
99
|
private boolean initialRegionSet = false;
|
|
96
100
|
private boolean initialCameraSet = false;
|
|
97
101
|
private LatLngBounds cameraLastIdleBounds;
|
|
@@ -219,10 +223,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
219
223
|
this.map.setOnMarkerDragListener(this);
|
|
220
224
|
this.map.setOnPoiClickListener(this);
|
|
221
225
|
this.map.setOnIndoorStateChangeListener(this);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
initialRegionSet = true;
|
|
225
|
-
}
|
|
226
|
+
|
|
227
|
+
applyBridgedProps();
|
|
226
228
|
|
|
227
229
|
manager.pushEvent(context, this, "onMapReady", new WritableNativeMap());
|
|
228
230
|
|
|
@@ -465,9 +467,9 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
465
467
|
public void setInitialRegion(ReadableMap initialRegion) {
|
|
466
468
|
this.initialRegion = initialRegion;
|
|
467
469
|
// Theoretically onMapReady might be called before setInitialRegion
|
|
468
|
-
// In that case, trigger
|
|
470
|
+
// In that case, trigger moveToRegion manually
|
|
469
471
|
if (!initialRegionSet && map != null) {
|
|
470
|
-
|
|
472
|
+
moveToRegion(initialRegion);
|
|
471
473
|
initialRegionSet = true;
|
|
472
474
|
}
|
|
473
475
|
}
|
|
@@ -479,16 +481,28 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
479
481
|
}
|
|
480
482
|
}
|
|
481
483
|
|
|
482
|
-
|
|
484
|
+
private void applyBridgedProps() {
|
|
485
|
+
if(initialRegion != null) {
|
|
486
|
+
moveToRegion(initialRegion);
|
|
487
|
+
initialRegionSet = true;
|
|
488
|
+
} else {
|
|
489
|
+
moveToRegion(region);
|
|
490
|
+
}
|
|
491
|
+
if(customMapStyleString != null) {
|
|
492
|
+
map.setMapStyle(new MapStyleOptions(customMapStyleString));
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
private void moveToRegion(ReadableMap region) {
|
|
483
497
|
if (region == null) return;
|
|
484
498
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
499
|
+
double lng = region.getDouble("longitude");
|
|
500
|
+
double lat = region.getDouble("latitude");
|
|
501
|
+
double lngDelta = region.getDouble("longitudeDelta");
|
|
502
|
+
double latDelta = region.getDouble("latitudeDelta");
|
|
489
503
|
LatLngBounds bounds = new LatLngBounds(
|
|
490
|
-
|
|
491
|
-
|
|
504
|
+
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
|
|
505
|
+
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
|
|
492
506
|
);
|
|
493
507
|
if (super.getHeight() <= 0 || super.getWidth() <= 0) {
|
|
494
508
|
// in this case, our map has not been laid out yet, so we save the bounds in a local
|
|
@@ -503,6 +517,13 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
503
517
|
}
|
|
504
518
|
}
|
|
505
519
|
|
|
520
|
+
public void setRegion(ReadableMap region) {
|
|
521
|
+
this.region = region;
|
|
522
|
+
if(region != null && map != null) {
|
|
523
|
+
moveToRegion(region);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
506
527
|
public void setCamera(ReadableMap camera) {
|
|
507
528
|
if (camera == null) return;
|
|
508
529
|
|
|
@@ -532,6 +553,13 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
532
553
|
}
|
|
533
554
|
}
|
|
534
555
|
|
|
556
|
+
public void setMapStyle(@Nullable String customMapStyleString) {
|
|
557
|
+
this.customMapStyleString = customMapStyleString;
|
|
558
|
+
if(map != null && customMapStyleString != null) {
|
|
559
|
+
map.setMapStyle(new MapStyleOptions(customMapStyleString));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
535
563
|
public void setShowsUserLocation(boolean showUserLocation) {
|
|
536
564
|
this.showUserLocation = showUserLocation; // hold onto this for lifecycle handling
|
|
537
565
|
if (hasPermissions()) {
|
|
@@ -671,12 +671,11 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
if (nearestDistance <= maxMeters) {
|
|
674
|
-
AIRMapCoordinate *firstCoord = nearestPolyline.coordinates.firstObject;
|
|
675
674
|
id event = @{
|
|
676
675
|
@"action": @"polyline-press",
|
|
677
676
|
@"coordinate": @{
|
|
678
|
-
@"latitude": @(
|
|
679
|
-
@"longitude": @(
|
|
677
|
+
@"latitude": @(tapCoordinate.latitude),
|
|
678
|
+
@"longitude": @(tapCoordinate.longitude)
|
|
680
679
|
}
|
|
681
680
|
};
|
|
682
681
|
nearestPolyline.onPress(event);
|
package/lib/MapView.d.ts
CHANGED
|
@@ -568,20 +568,12 @@ declare type NativeProps = Omit<ModifiedProps, 'customMapStyle' | 'onRegionChang
|
|
|
568
568
|
declare type State = {
|
|
569
569
|
isReady: boolean;
|
|
570
570
|
};
|
|
571
|
-
declare
|
|
572
|
-
declare class MapView extends React.Component<MapViewProps, State, SnapShot> {
|
|
571
|
+
declare class MapView extends React.Component<MapViewProps, State> {
|
|
573
572
|
static Animated: Animated.AnimatedComponent<typeof MapView>;
|
|
574
573
|
private map;
|
|
575
|
-
private __lastRegion;
|
|
576
|
-
private __layoutCalled;
|
|
577
574
|
constructor(props: MapViewProps);
|
|
578
575
|
setNativeProps(props: Partial<NativeProps>): void;
|
|
579
|
-
getSnapshotBeforeUpdate(prevProps: MapViewProps): Region | null;
|
|
580
|
-
componentDidUpdate(_prevProps: MapViewProps, _prevState: State, region: SnapShot): void;
|
|
581
|
-
componentDidMount(): void;
|
|
582
|
-
private _updateStyle;
|
|
583
576
|
private _onMapReady;
|
|
584
|
-
private _onLayout;
|
|
585
577
|
private _onChange;
|
|
586
578
|
getCamera(): Promise<Camera>;
|
|
587
579
|
setCamera(camera: Partial<Camera>): void;
|
package/lib/MapView.js
CHANGED
|
@@ -40,8 +40,6 @@ const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NON
|
|
|
40
40
|
class MapView extends React.Component {
|
|
41
41
|
static Animated;
|
|
42
42
|
map;
|
|
43
|
-
__lastRegion;
|
|
44
|
-
__layoutCalled;
|
|
45
43
|
constructor(props) {
|
|
46
44
|
super(props);
|
|
47
45
|
this.map = React.createRef();
|
|
@@ -50,79 +48,19 @@ class MapView extends React.Component {
|
|
|
50
48
|
};
|
|
51
49
|
this._onMapReady = this._onMapReady.bind(this);
|
|
52
50
|
this._onChange = this._onChange.bind(this);
|
|
53
|
-
this._onLayout = this._onLayout.bind(this);
|
|
54
51
|
}
|
|
55
52
|
setNativeProps(props) {
|
|
56
53
|
this.map.current?.setNativeProps(props);
|
|
57
54
|
}
|
|
58
|
-
getSnapshotBeforeUpdate(prevProps) {
|
|
59
|
-
if (this.state.isReady &&
|
|
60
|
-
this.props.customMapStyle !== prevProps.customMapStyle) {
|
|
61
|
-
this._updateStyle(this.props.customMapStyle);
|
|
62
|
-
}
|
|
63
|
-
return this.props.region || null;
|
|
64
|
-
}
|
|
65
|
-
componentDidUpdate(_prevProps, _prevState, region) {
|
|
66
|
-
const a = this.__lastRegion;
|
|
67
|
-
const b = region;
|
|
68
|
-
if (!a || !b) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (a.latitude !== b.latitude ||
|
|
72
|
-
a.longitude !== b.longitude ||
|
|
73
|
-
a.latitudeDelta !== b.latitudeDelta ||
|
|
74
|
-
a.longitudeDelta !== b.longitudeDelta) {
|
|
75
|
-
this.map.current?.setNativeProps({ region: b });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
componentDidMount() {
|
|
79
|
-
const { isReady } = this.state;
|
|
80
|
-
if (isReady) {
|
|
81
|
-
this._updateStyle(this.props.customMapStyle);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
_updateStyle(customMapStyle) {
|
|
85
|
-
this.map.current?.setNativeProps({
|
|
86
|
-
customMapStyleString: JSON.stringify(customMapStyle),
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
55
|
_onMapReady() {
|
|
90
|
-
const {
|
|
91
|
-
if (region) {
|
|
92
|
-
this.map.current?.setNativeProps({ region });
|
|
93
|
-
}
|
|
94
|
-
else if (initialRegion) {
|
|
95
|
-
this.map.current?.setNativeProps({ initialRegion });
|
|
96
|
-
}
|
|
97
|
-
this._updateStyle(this.props.customMapStyle);
|
|
56
|
+
const { onMapReady } = this.props;
|
|
98
57
|
this.setState({ isReady: true }, () => {
|
|
99
58
|
if (onMapReady) {
|
|
100
59
|
onMapReady();
|
|
101
60
|
}
|
|
102
61
|
});
|
|
103
62
|
}
|
|
104
|
-
_onLayout(e) {
|
|
105
|
-
const { layout } = e.nativeEvent;
|
|
106
|
-
if (!layout.width || !layout.height) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (this.state.isReady && !this.__layoutCalled) {
|
|
110
|
-
const { region, initialRegion } = this.props;
|
|
111
|
-
if (region) {
|
|
112
|
-
this.__layoutCalled = true;
|
|
113
|
-
this.map.current?.setNativeProps({ region });
|
|
114
|
-
}
|
|
115
|
-
else if (initialRegion) {
|
|
116
|
-
this.__layoutCalled = true;
|
|
117
|
-
this.map.current?.setNativeProps({ initialRegion });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (this.props.onLayout) {
|
|
121
|
-
this.props.onLayout(e);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
63
|
_onChange({ nativeEvent }) {
|
|
125
|
-
this.__lastRegion = nativeEvent.region;
|
|
126
64
|
const isGesture = nativeEvent.isGesture;
|
|
127
65
|
const details = { isGesture };
|
|
128
66
|
if (nativeEvent.continuous) {
|
|
@@ -354,8 +292,10 @@ class MapView extends React.Component {
|
|
|
354
292
|
initialRegion: null,
|
|
355
293
|
onChange: this._onChange,
|
|
356
294
|
onMapReady: this._onMapReady,
|
|
357
|
-
onLayout: this._onLayout,
|
|
358
295
|
ref: this.map,
|
|
296
|
+
customMapStyleString: this.props.customMapStyle
|
|
297
|
+
? JSON.stringify(this.props.customMapStyle)
|
|
298
|
+
: undefined,
|
|
359
299
|
...this.props,
|
|
360
300
|
};
|
|
361
301
|
if (react_native_1.Platform.OS === 'ios' &&
|
|
@@ -376,7 +316,9 @@ class MapView extends React.Component {
|
|
|
376
316
|
ref: this.map,
|
|
377
317
|
onChange: this._onChange,
|
|
378
318
|
onMapReady: this._onMapReady,
|
|
379
|
-
|
|
319
|
+
customMapStyleString: this.props.customMapStyle
|
|
320
|
+
? JSON.stringify(this.props.customMapStyle)
|
|
321
|
+
: undefined,
|
|
380
322
|
};
|
|
381
323
|
}
|
|
382
324
|
if (react_native_1.Platform.OS === 'android' && this.props.liteMode) {
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-maps",
|
|
3
3
|
"description": "React Native Mapview component for iOS + Android",
|
|
4
|
+
"source": "src/index",
|
|
4
5
|
"main": "lib/index.js",
|
|
5
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
6
|
-
"
|
|
7
|
+
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
+
"version": "1.1.0-beta.1",
|
|
7
9
|
"license": "MIT",
|
|
8
10
|
"scripts": {
|
|
9
11
|
"lint": "eslint . --max-warnings 0",
|
|
10
12
|
"tscheck": "tsc --noEmit",
|
|
11
|
-
"build": "tsc",
|
|
13
|
+
"build": "tsc --project tsconfig.build.json",
|
|
12
14
|
"test": "jest",
|
|
13
15
|
"prepare": "husky install",
|
|
14
|
-
"release": "semantic-release"
|
|
16
|
+
"release": "semantic-release",
|
|
17
|
+
"bootstrap": "yarn --cwd example && yarn && (cd example && cd ios && pod install)"
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
20
|
"lib",
|
|
@@ -49,17 +52,17 @@
|
|
|
49
52
|
}
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "17.0.
|
|
53
|
-
"@commitlint/config-conventional": "17.0.
|
|
54
|
-
"@react-native-community/eslint-config": "
|
|
55
|
-
"@types/react-native": "0.
|
|
55
|
+
"@commitlint/cli": "17.0.3",
|
|
56
|
+
"@commitlint/config-conventional": "17.0.3",
|
|
57
|
+
"@react-native-community/eslint-config": "3.0.3",
|
|
58
|
+
"@types/react-native": "0.69.2",
|
|
56
59
|
"babel-jest": "^27.3.1",
|
|
57
|
-
"eslint": "7.32.0",
|
|
60
|
+
"eslint": "^7.32.0",
|
|
58
61
|
"husky": "8.0.1",
|
|
59
62
|
"jest": "^27.3.1",
|
|
60
63
|
"prettier": "2.7.1",
|
|
61
|
-
"react": "
|
|
62
|
-
"react-native": "0.
|
|
64
|
+
"react": "18.0.0",
|
|
65
|
+
"react-native": "0.69.1",
|
|
63
66
|
"semantic-release": "19.0.3",
|
|
64
67
|
"typescript": "4.7.4"
|
|
65
68
|
},
|
|
@@ -5,11 +5,10 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
6
|
s.name = "react-native-google-maps"
|
|
7
7
|
s.version = package['version']
|
|
8
|
-
s.summary = "
|
|
9
|
-
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.license = "MIT"
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.authors = package["author"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
13
12
|
s.platform = :ios, "13.0"
|
|
14
13
|
|
|
15
14
|
s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
|
|
@@ -5,11 +5,10 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
6
|
s.name = "react-native-maps"
|
|
7
7
|
s.version = package['version']
|
|
8
|
-
s.summary = "
|
|
9
|
-
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.license = "MIT"
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.authors = package["author"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
13
12
|
s.platform = :ios, "11.0"
|
|
14
13
|
|
|
15
14
|
s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag=> "v#{s.version}" }
|