Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* '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)
  • Loading branch information
Rodrigo Solis committed Aug 21, 2017
2 parents ff2faad + fad3aab commit a509377
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 39 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Change Log

## 0.16.2 (August 17, 2017)
* Android: [#1563](https://github.com/airbnb/react-native-maps/pull/#1563) Add missing native method for setting initial region
* iOS: [#1187](https://github.com/airbnb/react-native-maps/pull/1187) Reverted due to build issues

## 0.16.1 (August 15, 2017)
* Android: [#1428](https://github.com/airbnb/react-native-maps/pull/#1428) Add ability to load marker image from drawable
* iOS: [#1187](https://github.com/airbnb/react-native-maps/pull/1187) Improve marker performance
* iOS/Android: [#1458](https://github.com/airbnb/react-native-maps/pull/1458) Add Google Maps legalNotice constant
* JS: [#1546](https://github.com/airbnb/react-native-maps/pull/1546) Fix initial region native prop

## 0.16.0 (August 9, 2017)
* Android: [#1481](https://github.com/airbnb/react-native-maps/pull/1481) Handle Android RN 0.47 breaking change
* iOS: [#1357](https://github.com/airbnb/react-native-maps/pull/1357) add MKTileOverlayRenderer
* iOS: [#1369](https://github.com/airbnb/react-native-maps/pull/1369) Add onMapReady callback
* Android/iOS/JS: [#1360](https://github.com/airbnb/react-native-maps/pull/1360) Add minZoom and maxZoom properties for android and ios
* JS: [#1479](https://github.com/airbnb/react-native-maps/pull/1479) Fix timing function used in AnimatedRegion.spring

## 0.15.3 (June 27, 2017)

* iOS: [#1362](https://github.com/airbnb/react-native-maps/pull/1362) Updates for React 0.43-0.45 and React 16.
Expand Down
3 changes: 3 additions & 0 deletions docs/mapview.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
| `showsIndoors` | `Boolean` | `true` | A Boolean indicating whether indoor maps should be enabled.
| `showsIndoorLevelPicker` | `Boolean` | `false` | A Boolean indicating whether indoor level picker should be enabled. **Note:** Android only.
| `zoomEnabled` | `Boolean` | `true` | If `false` the user won't be able to pinch/zoom the map.
| `minZoomLevel` | `Number` | `0` | Minimum zoom value for the map, must be between 0 and 20
| `maxZoomLevel` | `Number` | `20` | Maximum zoom value for the map, must be between 0 and 20
| `rotateEnabled` | `Boolean` | `true` | If `false` the user won't be able to pinch/rotate the map.
| `scrollEnabled` | `Boolean` | `true` | If `false` the user won't be able to change the map region being displayed.
| `pitchEnabled` | `Boolean` | `true` | If `false` the user won't be able to adjust the camera’s pitch angle.
Expand All @@ -40,6 +42,7 @@ To access event data, you will need to use `e.nativeEvent`. For example, `onPres

| Event Name | Returns | Notes
|---|---|---|
| `onMapReady` | | Callback that is called once the map is fully loaded.
| `onRegionChange` | `Region` | Callback that is called continuously when the region changes, such as when a user is dragging the map.
| `onRegionChangeComplete` | `Region` | Callback that is called once when the region changes, such as when the user is done moving the map.
| `onPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when user taps on the map.
Expand Down
17 changes: 10 additions & 7 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ platform :ios, '8.0'

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

pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
pod 'React', path: '../../node_modules/react-native', :subspecs => [
pod 'Yoga', path: "#{rn_path}/ReactCommon/yoga/Yoga.podspec"
pod 'React', path: rn_path, subspecs: [
'Core',
'RCTActionSheet',
'RCTAnimation',
Expand All @@ -22,19 +23,21 @@ target 'AirMapsExplorer' do
'BatchedBridge'
]

pod 'GoogleMaps' # <~~ remove this line if you do not want to support GoogleMaps on iOS
pod 'GoogleMaps' # Remove this line if you don't want to support GoogleMaps on iOS
pod 'react-native-maps', path: '../../'
pod 'react-native-google-maps', path: '../../' # <~~ if you need GoogleMaps support on iOS

pod 'react-native-google-maps', path: '../../' # If you need GoogleMaps support on iOS
end


post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "react-native-google-maps"
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end

if target.name == "React"
target.remove_from_project
end
end
end
2 changes: 1 addition & 1 deletion lib/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_CODE=4
VERSION_NAME=0.15.3
VERSION_NAME=0.16.2
GROUP=com.airbnb.android

POM_DESCRIPTION=React Native Map view component for Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public void setRegion(AirMapView view, ReadableMap region) {
view.setRegion(region);
}

@ReactProp(name = "initialRegion")
public void setInitialRegion(AirMapView view, ReadableMap initialRegion) {
view.setInitialRegion(initialRegion);
}

@ReactProp(name = "mapType")
public void setMapType(AirMapView view, @Nullable String mapType) {
int typeId = MAP_TYPES.get(mapType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
import com.facebook.react.uimanager.UIBlock;
import com.facebook.react.uimanager.UIManagerModule;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.common.GoogleApiAvailability;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import java.util.Map;
import java.util.HashMap;

import javax.annotation.Nullable;

public class AirMapModule extends ReactContextBaseJavaModule {
Expand All @@ -40,6 +44,13 @@ public String getName() {
return "AirMapModule";
}

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("legalNotice", GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(getReactApplicationContext()));
return constants;
}

public Activity getActivity() {
return getCurrentActivity();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
private boolean handlePanDrag = false;
private boolean moveOnMarkerPress = true;
private boolean cacheEnabled = false;
private boolean initialRegionSet = false;

private static final String[] PERMISSIONS = new String[]{
"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
Expand Down Expand Up @@ -305,7 +306,9 @@ public void onHostResume() {
map.setMyLocationEnabled(showUserLocation);
}
synchronized (AirMapView.this) {
AirMapView.this.onResume();
if (!destroyed) {
AirMapView.this.onResume();
}
paused = false;
}
}
Expand Down Expand Up @@ -359,6 +362,13 @@ public synchronized void doDestroy() {
onDestroy();
}

public void setInitialRegion(ReadableMap initialRegion) {
if (!initialRegionSet && initialRegion != null) {
setRegion(initialRegion);
initialRegionSet = true;
}
}

public void setRegion(ReadableMap region) {
if (region == null) return;

Expand Down Expand Up @@ -713,13 +723,13 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
// Timer Implementation

public void startMonitoringRegion() {
if (isMonitoringRegion) return;
if (map == null || isMonitoringRegion) return;
timerHandler.postDelayed(timerRunnable, 100);
isMonitoringRegion = true;
}

public void stopMonitoringRegion() {
if (!isMonitoringRegion) return;
if (map == null || !isMonitoringRegion) return;
timerHandler.removeCallbacks(timerRunnable);
isMonitoringRegion = false;
}
Expand All @@ -732,16 +742,18 @@ public void stopMonitoringRegion() {
@Override
public void run() {

Projection projection = map.getProjection();
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;

if ((bounds != null) &&
(lastBoundsEmitted == null ||
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
LatLng center = map.getCameraPosition().target;
lastBoundsEmitted = bounds;
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));
if (map != null) {
Projection projection = map.getProjection();
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;

if ((bounds != null) &&
(lastBoundsEmitted == null ||
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
LatLng center = map.getCameraPosition().target;
lastBoundsEmitted = bounds;
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));
}
}

timerHandler.postDelayed(this, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
return Arrays.<NativeModule>asList(new AirMapModule(reactContext));
}

@Override
// Deprecated RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/components/AnimatedRegion.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,25 @@ export default class AnimatedMapRegion extends AnimatedWithChildren {
spring(config) {
var animations = [];
config.hasOwnProperty('latitude') &&
animations.push(Animated.timing(this.latitude, {
animations.push(Animated.spring(this.latitude, {
...config,
toValue: config.latitude
}));

config.hasOwnProperty('longitude') &&
animations.push(Animated.timing(this.longitude, {
animations.push(Animated.spring(this.longitude, {
...config,
toValue: config.longitude
}));

config.hasOwnProperty('latitudeDelta') &&
animations.push(Animated.timing(this.latitudeDelta, {
animations.push(Animated.spring(this.latitudeDelta, {
...config,
toValue: config.latitudeDelta
}));

config.hasOwnProperty('longitudeDelta') &&
animations.push(Animated.timing(this.longitudeDelta, {
animations.push(Animated.spring(this.longitudeDelta, {
...config,
toValue: config.longitudeDelta
}));
Expand Down
2 changes: 1 addition & 1 deletion lib/components/MapMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class MapMarker extends React.Component {
let image;
if (this.props.image) {
image = resolveAssetSource(this.props.image) || {};
image = image.uri;
image = image.uri || this.props.image;
}

const AIRMapMarker = this.getAirComponent();
Expand Down
18 changes: 14 additions & 4 deletions lib/components/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ const propTypes = {
*/
legalLabelInsets: EdgeInsetsPropType,

/**
* Callback that is called once the map is fully loaded.
*/
onMapReady: PropTypes.func,

/**
* Callback that is called continuously when the user is dragging the map.
*/
Expand Down Expand Up @@ -444,24 +449,29 @@ class MapView extends React.Component {
}

_onMapReady() {
const { region, initialRegion } = this.props;
const { region, initialRegion, onMapReady } = this.props;
if (region) {
this.map.setNativeProps({ region });
} else if (initialRegion) {
this.map.setNativeProps({ region: initialRegion });
this.map.setNativeProps({ initialRegion });
}
this._updateStyle();
this.setState({ isReady: true });
this.setState({ isReady: true }, () => {
if (onMapReady) onMapReady();
});
}

_onLayout(e) {
const { layout } = e.nativeEvent;
if (!layout.width || !layout.height) return;
if (this.state.isReady && !this.__layoutCalled) {
const region = this.props.region || this.props.initialRegion;
const { region, initialRegion } = this.props;
if (region) {
this.__layoutCalled = true;
this.map.setNativeProps({ region });
} else if (initialRegion) {
this.__layoutCalled = true;
this.map.setNativeProps({ initialRegion });
}
}
if (this.props.onLayout) {
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
@property (nonatomic, assign) MKCoordinateRegion region;
@property (nonatomic, assign) NSString *customMapStyleString;
@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, copy) RCTBubblingEventBlock onLongPress;
@property (nonatomic, copy) RCTBubblingEventBlock onMarkerPress;
Expand All @@ -40,6 +41,7 @@
@property (nonatomic, assign) BOOL showsUserLocation;
@property (nonatomic, assign) BOOL showsMyLocationButton;

- (void)didFinishTileRendering;
- (BOOL)didTapMarker:(GMSMarker *)marker;
- (void)didTapPolyline:(GMSPolyline *)polyline;
- (void)didTapPolygon:(GMSPolygon *)polygon;
Expand Down
4 changes: 4 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ - (void)setRegion:(MKCoordinateRegion)region {
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
}

- (void)didFinishTileRendering {
if (self.onMapReady) self.onMapReady(@{});
}

- (BOOL)didTapMarker:(GMSMarker *)marker {
AIRGMSMarker *airMarker = (AIRGMSMarker *)marker;

Expand Down
9 changes: 9 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showsMyLocationButton, BOOL)
RCT_EXPORT_VIEW_PROPERTY(customMapStyleString, NSString)
RCT_EXPORT_VIEW_PROPERTY(onMapReady, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
Expand Down Expand Up @@ -221,6 +222,14 @@ - (UIView *)view
}];
}

- (NSDictionary *)constantsToExport {
return @{ @"legalNotice": [GMSServices openSourceLicenseInfo] };
}

- (void)mapViewDidFinishTileRendering:(GMSMapView *)mapView {
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
[googleMapView didFinishTileRendering];
}

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
AIRGoogleMap *googleMapView = (AIRGoogleMap *)mapView;
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/AirMaps/AIRMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
extern const CLLocationDegrees AIRMapDefaultSpan;
extern const NSTimeInterval AIRMapRegionChangeObserveInterval;
extern const CGFloat AIRMapZoomBoundBuffer;
extern const NSInteger AIRMapMaxZoomLevel;

@interface AIRMap: MKMapView<SMCalloutViewDelegate>

Expand Down Expand Up @@ -46,6 +47,7 @@ extern const CGFloat AIRMapZoomBoundBuffer;

@property (nonatomic, assign) BOOL ignoreRegionChanges;

@property (nonatomic, copy) RCTBubblingEventBlock onMapReady;
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, copy) RCTBubblingEventBlock onPanDrag;
Expand Down
4 changes: 4 additions & 0 deletions lib/ios/AirMaps/AIRMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
const CLLocationDegrees AIRMapDefaultSpan = 0.005;
const NSTimeInterval AIRMapRegionChangeObserveInterval = 0.1;
const CGFloat AIRMapZoomBoundBuffer = 0.01;
const NSInteger AIRMapMaxZoomLevel = 20;


@interface MKMapView (UIGestureRecognizer)
Expand Down Expand Up @@ -79,6 +80,9 @@ - (instancetype)init
// be identical to the built-in callout view (which has a private API)
self.calloutView = [SMCalloutView platformCalloutView];
self.calloutView.delegate = self;

self.minZoomLevel = 0;
self.maxZoomLevel = AIRMapMaxZoomLevel;
}
return self;
}
Expand Down
1 change: 0 additions & 1 deletion lib/ios/AirMaps/AIRMapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#define MERCATOR_RADIUS 85445659.44705395
#define MERCATOR_OFFSET 268435456
#define MAX_GOOGLE_LEVELS 20

@interface AIRMapManager : RCTViewManager

Expand Down
Loading

0 comments on commit a509377

Please sign in to comment.