Skip to content

Commit a509377

Browse files
author
Rodrigo Solis
committed
* 'master' of https://github.com/airbnb/react-native-maps: v0.16.2 Revert "Issue1176 improve ios marker performance by X100 (react-native-maps#1187)" Fix initial region android (react-native-maps#1563) v0.16.1 Enhance Podfile. (react-native-maps#1252) Update marker component (react-native-maps#1428) Add legalNotice constant (react-native-maps#1458) Issue1176 improve ios marker performance by X100 (react-native-maps#1187) Fix initial region native prop (react-native-maps#1546) fix `Archive` configuration for iOS builds (react-native-maps#1550) v0.16.0 Document MapView min/max zoom properties (react-native-maps#1538) Fix timing function used in AnimatedRegion.spring (react-native-maps#1479) Fix crashing the application when a user presses on the map and the Google Play Services need to be updated or at the moment of the process of updating (react-native-maps#1469) skip region monitoring if map object is null (react-native-maps#1443) Zoom level fixes (react-native-maps#1485) Attempt to fix crashes. A variant of react-native-maps#1403 but for another lifecycle method, as proposed by @Nelrohd. (react-native-maps#1464) Handle Android RN 0.47 breaking change (react-native-maps#1481) add MKTileOverlayRenderer (react-native-maps#1357) Add onMapReady callback (react-native-maps#1369)
2 parents ff2faad + fad3aab commit a509377

19 files changed

+125
-39
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Change Log
22

3+
## 0.16.2 (August 17, 2017)
4+
* Android: [#1563](https://github.com/airbnb/react-native-maps/pull/#1563) Add missing native method for setting initial region
5+
* iOS: [#1187](https://github.com/airbnb/react-native-maps/pull/1187) Reverted due to build issues
6+
7+
## 0.16.1 (August 15, 2017)
8+
* Android: [#1428](https://github.com/airbnb/react-native-maps/pull/#1428) Add ability to load marker image from drawable
9+
* iOS: [#1187](https://github.com/airbnb/react-native-maps/pull/1187) Improve marker performance
10+
* iOS/Android: [#1458](https://github.com/airbnb/react-native-maps/pull/1458) Add Google Maps legalNotice constant
11+
* JS: [#1546](https://github.com/airbnb/react-native-maps/pull/1546) Fix initial region native prop
12+
13+
## 0.16.0 (August 9, 2017)
14+
* Android: [#1481](https://github.com/airbnb/react-native-maps/pull/1481) Handle Android RN 0.47 breaking change
15+
* iOS: [#1357](https://github.com/airbnb/react-native-maps/pull/1357) add MKTileOverlayRenderer
16+
* iOS: [#1369](https://github.com/airbnb/react-native-maps/pull/1369) Add onMapReady callback
17+
* Android/iOS/JS: [#1360](https://github.com/airbnb/react-native-maps/pull/1360) Add minZoom and maxZoom properties for android and ios
18+
* JS: [#1479](https://github.com/airbnb/react-native-maps/pull/1479) Fix timing function used in AnimatedRegion.spring
19+
320
## 0.15.3 (June 27, 2017)
421

522
* iOS: [#1362](https://github.com/airbnb/react-native-maps/pull/1362) Updates for React 0.43-0.45 and React 16.

docs/mapview.md

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
| `showsIndoors` | `Boolean` | `true` | A Boolean indicating whether indoor maps should be enabled.
2323
| `showsIndoorLevelPicker` | `Boolean` | `false` | A Boolean indicating whether indoor level picker should be enabled. **Note:** Android only.
2424
| `zoomEnabled` | `Boolean` | `true` | If `false` the user won't be able to pinch/zoom the map.
25+
| `minZoomLevel` | `Number` | `0` | Minimum zoom value for the map, must be between 0 and 20
26+
| `maxZoomLevel` | `Number` | `20` | Maximum zoom value for the map, must be between 0 and 20
2527
| `rotateEnabled` | `Boolean` | `true` | If `false` the user won't be able to pinch/rotate the map.
2628
| `scrollEnabled` | `Boolean` | `true` | If `false` the user won't be able to change the map region being displayed.
2729
| `pitchEnabled` | `Boolean` | `true` | If `false` the user won't be able to adjust the camera’s pitch angle.
@@ -40,6 +42,7 @@ To access event data, you will need to use `e.nativeEvent`. For example, `onPres
4042

4143
| Event Name | Returns | Notes
4244
|---|---|---|
45+
| `onMapReady` | | Callback that is called once the map is fully loaded.
4346
| `onRegionChange` | `Region` | Callback that is called continuously when the region changes, such as when a user is dragging the map.
4447
| `onRegionChangeComplete` | `Region` | Callback that is called once when the region changes, such as when the user is done moving the map.
4548
| `onPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user taps on the map.

example/ios/Podfile

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ platform :ios, '8.0'
55

66
# Change 'AirMapsExplorer' to match the target in your Xcode project.
77
target 'AirMapsExplorer' do
8+
rn_path = '../../node_modules/react-native'
89

9-
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
10-
pod 'React', path: '../../node_modules/react-native', :subspecs => [
10+
pod 'Yoga', path: "#{rn_path}/ReactCommon/yoga/Yoga.podspec"
11+
pod 'React', path: rn_path, subspecs: [
1112
'Core',
1213
'RCTActionSheet',
1314
'RCTAnimation',
@@ -22,19 +23,21 @@ target 'AirMapsExplorer' do
2223
'BatchedBridge'
2324
]
2425

25-
pod 'GoogleMaps' # <~~ remove this line if you do not want to support GoogleMaps on iOS
26+
pod 'GoogleMaps' # Remove this line if you don't want to support GoogleMaps on iOS
2627
pod 'react-native-maps', path: '../../'
27-
pod 'react-native-google-maps', path: '../../' # <~~ if you need GoogleMaps support on iOS
28-
28+
pod 'react-native-google-maps', path: '../../' # If you need GoogleMaps support on iOS
2929
end
3030

31-
3231
post_install do |installer|
3332
installer.pods_project.targets.each do |target|
34-
if target.name == "react-native-google-maps"
33+
if target.name == 'react-native-google-maps'
3534
target.build_configurations.each do |config|
3635
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
3736
end
3837
end
38+
39+
if target.name == "React"
40+
target.remove_from_project
41+
end
3942
end
4043
end

lib/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VERSION_CODE=4
2-
VERSION_NAME=0.15.3
2+
VERSION_NAME=0.16.2
33
GROUP=com.airbnb.android
44

55
POM_DESCRIPTION=React Native Map view component for Android

lib/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public void setRegion(AirMapView view, ReadableMap region) {
7575
view.setRegion(region);
7676
}
7777

78+
@ReactProp(name = "initialRegion")
79+
public void setInitialRegion(AirMapView view, ReadableMap initialRegion) {
80+
view.setInitialRegion(initialRegion);
81+
}
82+
7883
@ReactProp(name = "mapType")
7984
public void setMapType(AirMapView view, @Nullable String mapType) {
8085
int typeId = MAP_TYPES.get(mapType);

lib/android/src/main/java/com/airbnb/android/react/maps/AirMapModule.java

+11
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
import com.facebook.react.uimanager.UIBlock;
1616
import com.facebook.react.uimanager.UIManagerModule;
1717
import com.google.android.gms.maps.GoogleMap;
18+
import com.google.android.gms.common.GoogleApiAvailability;
1819

1920
import java.io.ByteArrayOutputStream;
2021
import java.io.Closeable;
2122
import java.io.File;
2223
import java.io.FileOutputStream;
2324
import java.io.IOException;
2425

26+
import java.util.Map;
27+
import java.util.HashMap;
28+
2529
import javax.annotation.Nullable;
2630

2731
public class AirMapModule extends ReactContextBaseJavaModule {
@@ -40,6 +44,13 @@ public String getName() {
4044
return "AirMapModule";
4145
}
4246

47+
@Override
48+
public Map<String, Object> getConstants() {
49+
final Map<String, Object> constants = new HashMap<>();
50+
constants.put("legalNotice", GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(getReactApplicationContext()));
51+
return constants;
52+
}
53+
4354
public Activity getActivity() {
4455
return getCurrentActivity();
4556
}

lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java

+25-13
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
7171
private boolean handlePanDrag = false;
7272
private boolean moveOnMarkerPress = true;
7373
private boolean cacheEnabled = false;
74+
private boolean initialRegionSet = false;
7475

7576
private static final String[] PERMISSIONS = new String[]{
7677
"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
@@ -305,7 +306,9 @@ public void onHostResume() {
305306
map.setMyLocationEnabled(showUserLocation);
306307
}
307308
synchronized (AirMapView.this) {
308-
AirMapView.this.onResume();
309+
if (!destroyed) {
310+
AirMapView.this.onResume();
311+
}
309312
paused = false;
310313
}
311314
}
@@ -359,6 +362,13 @@ public synchronized void doDestroy() {
359362
onDestroy();
360363
}
361364

365+
public void setInitialRegion(ReadableMap initialRegion) {
366+
if (!initialRegionSet && initialRegion != null) {
367+
setRegion(initialRegion);
368+
initialRegionSet = true;
369+
}
370+
}
371+
362372
public void setRegion(ReadableMap region) {
363373
if (region == null) return;
364374

@@ -713,13 +723,13 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
713723
// Timer Implementation
714724

715725
public void startMonitoringRegion() {
716-
if (isMonitoringRegion) return;
726+
if (map == null || isMonitoringRegion) return;
717727
timerHandler.postDelayed(timerRunnable, 100);
718728
isMonitoringRegion = true;
719729
}
720730

721731
public void stopMonitoringRegion() {
722-
if (!isMonitoringRegion) return;
732+
if (map == null || !isMonitoringRegion) return;
723733
timerHandler.removeCallbacks(timerRunnable);
724734
isMonitoringRegion = false;
725735
}
@@ -732,16 +742,18 @@ public void stopMonitoringRegion() {
732742
@Override
733743
public void run() {
734744

735-
Projection projection = map.getProjection();
736-
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
737-
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;
738-
739-
if ((bounds != null) &&
740-
(lastBoundsEmitted == null ||
741-
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
742-
LatLng center = map.getCameraPosition().target;
743-
lastBoundsEmitted = bounds;
744-
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));
745+
if (map != null) {
746+
Projection projection = map.getProjection();
747+
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
748+
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;
749+
750+
if ((bounds != null) &&
751+
(lastBoundsEmitted == null ||
752+
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
753+
LatLng center = map.getCameraPosition().target;
754+
lastBoundsEmitted = bounds;
755+
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));
756+
}
745757
}
746758

747759
timerHandler.postDelayed(this, 100);

lib/android/src/main/java/com/airbnb/android/react/maps/MapsPackage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
2424
return Arrays.<NativeModule>asList(new AirMapModule(reactContext));
2525
}
2626

27-
@Override
27+
// Deprecated RN 0.47
2828
public List<Class<? extends JavaScriptModule>> createJSModules() {
2929
return Collections.emptyList();
3030
}

lib/components/AnimatedRegion.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,25 @@ export default class AnimatedMapRegion extends AnimatedWithChildren {
111111
spring(config) {
112112
var animations = [];
113113
config.hasOwnProperty('latitude') &&
114-
animations.push(Animated.timing(this.latitude, {
114+
animations.push(Animated.spring(this.latitude, {
115115
...config,
116116
toValue: config.latitude
117117
}));
118118

119119
config.hasOwnProperty('longitude') &&
120-
animations.push(Animated.timing(this.longitude, {
120+
animations.push(Animated.spring(this.longitude, {
121121
...config,
122122
toValue: config.longitude
123123
}));
124124

125125
config.hasOwnProperty('latitudeDelta') &&
126-
animations.push(Animated.timing(this.latitudeDelta, {
126+
animations.push(Animated.spring(this.latitudeDelta, {
127127
...config,
128128
toValue: config.latitudeDelta
129129
}));
130130

131131
config.hasOwnProperty('longitudeDelta') &&
132-
animations.push(Animated.timing(this.longitudeDelta, {
132+
animations.push(Animated.spring(this.longitudeDelta, {
133133
...config,
134134
toValue: config.longitudeDelta
135135
}));

lib/components/MapMarker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class MapMarker extends React.Component {
257257
let image;
258258
if (this.props.image) {
259259
image = resolveAssetSource(this.props.image) || {};
260-
image = image.uri;
260+
image = image.uri || this.props.image;
261261
}
262262

263263
const AIRMapMarker = this.getAirComponent();

lib/components/MapView.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ const propTypes = {
321321
*/
322322
legalLabelInsets: EdgeInsetsPropType,
323323

324+
/**
325+
* Callback that is called once the map is fully loaded.
326+
*/
327+
onMapReady: PropTypes.func,
328+
324329
/**
325330
* Callback that is called continuously when the user is dragging the map.
326331
*/
@@ -444,24 +449,29 @@ class MapView extends React.Component {
444449
}
445450

446451
_onMapReady() {
447-
const { region, initialRegion } = this.props;
452+
const { region, initialRegion, onMapReady } = this.props;
448453
if (region) {
449454
this.map.setNativeProps({ region });
450455
} else if (initialRegion) {
451-
this.map.setNativeProps({ region: initialRegion });
456+
this.map.setNativeProps({ initialRegion });
452457
}
453458
this._updateStyle();
454-
this.setState({ isReady: true });
459+
this.setState({ isReady: true }, () => {
460+
if (onMapReady) onMapReady();
461+
});
455462
}
456463

457464
_onLayout(e) {
458465
const { layout } = e.nativeEvent;
459466
if (!layout.width || !layout.height) return;
460467
if (this.state.isReady && !this.__layoutCalled) {
461-
const region = this.props.region || this.props.initialRegion;
468+
const { region, initialRegion } = this.props;
462469
if (region) {
463470
this.__layoutCalled = true;
464471
this.map.setNativeProps({ region });
472+
} else if (initialRegion) {
473+
this.__layoutCalled = true;
474+
this.map.setNativeProps({ initialRegion });
465475
}
466476
}
467477
if (this.props.onLayout) {

lib/ios/AirGoogleMaps/AIRGoogleMap.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
1919
@property (nonatomic, assign) MKCoordinateRegion region;
2020
@property (nonatomic, assign) NSString *customMapStyleString;
21+
@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
2122
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
2223
@property (nonatomic, copy) RCTBubblingEventBlock onLongPress;
2324
@property (nonatomic, copy) RCTBubblingEventBlock onMarkerPress;
@@ -40,6 +41,7 @@
4041
@property (nonatomic, assign) BOOL showsUserLocation;
4142
@property (nonatomic, assign) BOOL showsMyLocationButton;
4243

44+
- (void)didFinishTileRendering;
4345
- (BOOL)didTapMarker:(GMSMarker *)marker;
4446
- (void)didTapPolyline:(GMSPolyline *)polyline;
4547
- (void)didTapPolygon:(GMSPolygon *)polygon;

lib/ios/AirGoogleMaps/AIRGoogleMap.m

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ - (void)setRegion:(MKCoordinateRegion)region {
155155
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
156156
}
157157

158+
- (void)didFinishTileRendering {
159+
if (self.onMapReady) self.onMapReady(@{});
160+
}
161+
158162
- (BOOL)didTapMarker:(GMSMarker *)marker {
159163
AIRGMSMarker *airMarker = (AIRGMSMarker *)marker;
160164

lib/ios/AirGoogleMaps/AIRGoogleMapManager.m

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ - (UIView *)view
5959
RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL)
6060
RCT_EXPORT_VIEW_PROPERTY(showsMyLocationButton, BOOL)
6161
RCT_EXPORT_VIEW_PROPERTY(customMapStyleString, NSString)
62+
RCT_EXPORT_VIEW_PROPERTY(onMapReady, RCTBubblingEventBlock)
6263
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
6364
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
6465
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
@@ -221,6 +222,14 @@ - (UIView *)view
221222
}];
222223
}
223224

225+
- (NSDictionary *)constantsToExport {
226+
return @{ @"legalNotice": [GMSServices openSourceLicenseInfo] };
227+
}
228+
229+
- (void)mapViewDidFinishTileRendering:(GMSMapView *)mapView {
230+
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
231+
[googleMapView didFinishTileRendering];
232+
}
224233

225234
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
226235
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;

lib/ios/AirMaps/AIRMap.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
extern const CLLocationDegrees AIRMapDefaultSpan;
1818
extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
1919
extern const CGFloat AIRMapZoomBoundBuffer;
20+
extern const NSInteger AIRMapMaxZoomLevel;
2021

2122
@interface AIRMap: MKMapView<SMCalloutViewDelegate>
2223

@@ -46,6 +47,7 @@ extern const CGFloat AIRMapZoomBoundBuffer;
4647

4748
@property (nonatomic, assign) BOOL ignoreRegionChanges;
4849

50+
@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
4951
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
5052
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
5153
@property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;

lib/ios/AirMaps/AIRMap.m

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
const CLLocationDegrees AIRMapDefaultSpan = 0.005;
2222
const NSTimeInterval AIRMapRegionChangeObserveInterval = 0.1;
2323
const CGFloat AIRMapZoomBoundBuffer = 0.01;
24+
const NSInteger AIRMapMaxZoomLevel = 20;
2425

2526

2627
@interface MKMapView (UIGestureRecognizer)
@@ -79,6 +80,9 @@ - (instancetype)init
7980
// be identical to the built-in callout view (which has a private API)
8081
self.calloutView = [SMCalloutView platformCalloutView];
8182
self.calloutView.delegate = self;
83+
84+
self.minZoomLevel = 0;
85+
self.maxZoomLevel = AIRMapMaxZoomLevel;
8286
}
8387
return self;
8488
}

lib/ios/AirMaps/AIRMapManager.h

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#define MERCATOR_RADIUS 85445659.44705395
1414
#define MERCATOR_OFFSET 268435456
15-
#define MAX_GOOGLE_LEVELS 20
1615

1716
@interface AIRMapManager : RCTViewManager
1817

0 commit comments

Comments
 (0)