Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (24 commits)
  v0.15.2 (react-native-maps#1352)
  Remove AIRGMSPolyline.h and AIRGMSPolyline.m references from AirMaps.xcodeproj (react-native-maps#1351)
  v0.15.1 (react-native-maps#1347)
  fix compile error in rn version >= 0.40 (react-native-maps#1341)
  Add Marker rotation for Google Maps on iOS (react-native-maps#1326)
  Fixing reference to AirMapsExplorer in installation docs (react-native-maps#1328)
  Update README: Use callback in `ref` attribute (react-native-maps#1345)
  [iOS] Added onPress support for Polyline on Google Maps (react-native-maps#1194)
  [rnpm] Fix sourceDir for Android (react-native-maps#1313)
  Update license date (react-native-maps#1316)
  Fix overlay issues in Android introduced in 0.13.1 (react-native-maps#1311)
  v0.15.0 (react-native-maps#1305)
  fixing code snippet (react-native-maps#1196)
  small typo fixed (react-native-maps#1211)
  Update installation.md (react-native-maps#1226)
  Fixed path in `android/settings.gradle` (react-native-maps#1230)
  Add babelrc to npmignore (react-native-maps#1246)
  Update installation.md (react-native-maps#1179)
  Update docs to specify how to access event data (react-native-maps#1178)
  Update path in android installation (react-native-maps#1249)
  ...
  • Loading branch information
sorodrigo committed May 26, 2017
2 parents abf6ce5 + 8893578 commit 108be14
Show file tree
Hide file tree
Showing 27 changed files with 211 additions and 37 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
example
.babelrc
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
# Change Log

## 0.15.2 (May 20, 2017)

* iOS: [#1351](https://github.com/airbnb/react-native-maps/pull/1351) Fix file references

## 0.15.1 (May 19, 2017)

* iOS: [#1341](https://github.com/airbnb/react-native-maps/pull/1341) Fix compile error in rn version >= 0.40
* iOS: [#1194](https://github.com/airbnb/react-native-maps/pull/1194) Add onPress support for Google Maps Polyline
* iOS: [#1326](https://github.com/airbnb/react-native-maps/pull/1326) Add Marker rotation for Google Maps on iOS
* Android: [#1311](https://github.com/airbnb/react-native-maps/pull/1311) Fix overlay issue
* Common [#1313](https://github.com/airbnb/react-native-maps/pull/1313) Fix Android sourceDir for react-native-link

## 0.15.0 (May 8, 2017)

* iOS: [#1195](https://github.com/airbnb/react-native-maps/pull/1195) Rename project file to fix iOS build error
* Android: Update Google Play Services to version `10.2.4`

## 0.14.0 (April 4, 2017)

## Enhancements

* Restructure project #1164

* Add showsIndoorLevelPicker -> setIndoorLevelPickerEnabled to MapView #1019
[#1188](https://github.com/airbnb/react-native-maps/pull/1188)

* iOS - Added onPress support for Polygons on Google Maps
[#1024](https://github.com/airbnb/react-native-maps/pull/1024)

* Add customized user location annotation text
[#1049](https://github.com/airbnb/react-native-maps/pull/1049)

* iOS - Google Maps - Add `showsMyLocationButton` support
[#1157](https://github.com/airbnb/react-native-maps/pull/1157)


## Patches

* Fix getResources() null crash in mapview
[#1188](https://github.com/airbnb/react-native-maps/pull/1188)

* Rename MapKit category to avoid conflicts with the one in RN
[#1172](https://github.com/airbnb/react-native-maps/pull/1172)

* Upgrade GMS dependencies to 10.2.0
[#1169](https://github.com/airbnb/react-native-maps/pull/1169)

* fix multiple-instance memory leak
[#1130](https://github.com/airbnb/react-native-maps/pull/1130)

* fix onSelected event for markers with custom view
[#1079](https://github.com/airbnb/react-native-maps/pull/1079)

* Crash in our App fix
[#1096](https://github.com/airbnb/react-native-maps/pull/1096)

* Use local RCTConvert+MapKit instead of the one in React Native
[#1138](https://github.com/airbnb/react-native-maps/pull/1138)


## 0.13.1 (March 21, 2017)


Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ getInitialState() {
takeSnapshot () {
// 'takeSnapshot' takes a config object with the
// following options
const snapshot = this.refs.map.takeSnapshot({
const snapshot = this.map.takeSnapshot({
width: 300, // optional, when omitted the view-width is used
height: 300, // optional, when omitted the view-height is used
region: {..}, // iOS only, optional region to render
Expand All @@ -421,7 +421,7 @@ takeSnapshot () {
render() {
return (
<View>
<MapView initialRegion={...} ref="map">
<MapView initialRegion={...} ref={map => { this.map = map }}>
<MapView.Marker coordinate={this.state.coordinate} />
</MapView>
<Image source={{ uri: this.state.mapSnapshot.uri }} />
Expand Down Expand Up @@ -494,7 +494,7 @@ Good:
License
--------

Copyright (c) 2015 Airbnb
Copyright (c) 2017 Airbnb

Licensed under the The MIT License (MIT) (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}

Expand Down
14 changes: 7 additions & 7 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ react-native link react-native-maps
### Option 1: CocoaPods - Same as the included AirMapsExplorer example

1. Setup your `Podfile` like the included [example/ios/Podfile](../example/ios/Podfile), replace all references to `AirMapExplorer` with your project name, and then run `pod install`.
1. Setup your `Podfile` like the included [example/ios/Podfile](../example/ios/Podfile), replace all references to `AirMapsExplorer` with your project name, and then run `pod install`.
(If you do not need `GoogleMaps` support for iOS, then you can probably completely skip this step.)
1. Open your project in Xcode workspace
1. If you need `GoogleMaps` support also
- Drag this folder `node_modules/react-native-maps/ios/AirGoogleMaps/` into your project, and choose `Create groups` in the popup window.
- Drag this folder `node_modules/react-native-maps/lib/ios/AirGoogleMaps/` into your project, and choose `Create groups` in the popup window.
- In `AppDelegate.m`, add `@import GoogleMaps;` before `@implementation AppDelegate`. In `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions`, add `[GMSServices provideAPIKey:@"YOUR_GOOGLE_MAP_API_KEY"];`
- In your project's `Build Settings` > `Header Search Paths`, double click the value field. In the popup, add `$(SRCROOT)/../node_modules/react-native-maps/ios/AirMaps` and change `non-recursive` to `recursive`. (Dragging the folder `node_modules/react-native-maps/ios/AirMaps/` into your project introduces duplicate symbols. We should not do it.)
- In your project's `Build Settings` > `Header Search Paths`, double click the value field. In the popup, add `$(SRCROOT)/../node_modules/react-native-maps/lib/ios/AirMaps` and change `non-recursive` to `recursive`. (Dragging the folder `node_modules/react-native-maps/lib/ios/AirMaps/` into your project introduces duplicate symbols. We should not do it.)

Note: We recommend using a version of React Native >= .40. Newer versions (>= .40) require `package.json` to be set to `"react-native-maps": "^0.13.0"`, while older versions require `"react-native-maps": "^0.12.4"`.

Expand All @@ -52,7 +52,7 @@ After your `Podfile` is setup properly, run `pod install`.
>This was already done for you if you ran "react-native link"
1. Open your project in Xcode, right click on `Libraries` and click `Add
Files to "Your Project Name"` Look under `node_modules/react-native-maps/ios` and add `AIRMaps.xcodeproj`.
Files to "Your Project Name"` Look under `node_modules/react-native-maps/lib/ios` and add `AIRMaps.xcodeproj`.
1. Add `libAIRMaps.a` to `Build Phases -> Link Binary With Libraries.
1. Click on `AIRMaps.xcodeproj` in `Libraries` and go the `Build
Settings` tab. Double click the text to the right of `Header Search
Expand Down Expand Up @@ -98,7 +98,7 @@ After your `Podfile` is setup properly, run `pod install`.
```groovy
...
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
```

1. Specify your Google Maps API Key:
Expand Down Expand Up @@ -203,7 +203,7 @@ Enter the name of the API key and create it.
1. Clean the cache :
```
watchman watch-del-all
npm cache clean
npm clean cache
```

1. When starting emulator, make sure you have enabled `Wipe user data`.
Expand All @@ -213,7 +213,7 @@ Enter the name of the API key and create it.
1. If you encounter `com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim`, then clear build folder.
```
cd android
gradlew clean
./gradlew clean
cd ..
```

Expand Down
8 changes: 5 additions & 3 deletions docs/mapview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| `initialRegion` | `Region` | | The initial region to be displayed by the map. Use this prop instead of `region` only if you don't want to control the viewport of the map besides the initial region.<br/><br/> Changing this prop after the component has mounted will not result in a region change.<br/><br/> This is similar to the `initialValue` prop of a text input.
| `liteMode` | `Boolean` | `false` | Enable lite mode. **Note**: Android only.
| `mapType` | `String` | `"standard"` | The map type to be displayed. <br/><br/> - standard: standard road map (default)<br/> - satellite: satellite view<br/> - hybrid: satellite view with roads and points of interest overlayed<br/> - terrain: (Android only) topographic view
| `customMapStyle` | `Array` | | Adds custom styling to the map component. See [README](https://github.com/airbnb/react-native-maps#customizing-the-map-style) for more information.
| `customMapStyle` | `Array` | | Adds custom styling to the map component. See [README](https://github.com/airbnb/react-native-maps#customizing-the-map-style) for more information.
| `showsUserLocation` | `Boolean` | `false` | If `true` the app will ask for the user's location. **NOTE**: You need to add `NSLocationWhenInUseUsageDescription` key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!
| `userLocationAnnotationTitle` | `String` | | The title of the annotation for current user location. This only works if `showsUserLocation` is true. There is a default value `My Location` set by MapView. **Note**: iOS only.
| `followsUserLocation` | `Boolean` | `false` | If `true` the map will focus on the user's location. This only works if `showsUserLocation` is true and the user has shared their location. **Note**: iOS only.
Expand All @@ -36,6 +36,8 @@

## Events

To access event data, you will need to use `e.nativeEvent`. For example, `onPress={e => console.log(e.nativeEvent)}` will log the entire event object to your console.

| Event Name | Returns | Notes
|---|---|---|
| `onRegionChange` | `Region` | Callback that is called continuously when the region changes, such as when a user is dragging the map.
Expand All @@ -59,9 +61,9 @@
|---|---|---|
| `animateToRegion` | `region: Region`, `duration: Number` |
| `animateToCoordinate` | `coordinate: LatLng`, `duration: Number` |
| `fitToElements` | `animated: Boolean` |
| `fitToElements` | `animated: Boolean` |
| `fitToSuppliedMarkers` | `markerIDs: String[]`, `animated: Boolean` | If you need to use this in `ComponentDidMount`, make sure you put it in a timeout or it will cause performance problems.
| `fitToCoordinates` | `coordinates: Array<LatLng>, options: { edgePadding: EdgePadding, animated: Boolean }` | If called in `ComponentDidMount` in android, it will cause an exception. It is recommended to call it from the MapView `onLayout` event.
| `fitToCoordinates` | `coordinates: Array<LatLng>, options: { edgePadding: EdgePadding, animated: Boolean }` | If called in `ComponentDidMount` in android, it will cause an exception. It is recommended to call it from the MapView `onLayout` event.



Expand Down
4 changes: 3 additions & 1 deletion docs/marker.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
| `calloutAnchor` | `Point` | | Specifies the point in the marker image at which to anchor the callout when it is displayed. This is specified in the same coordinate system as the anchor. See the `anchor` prop for more details.<br/><br/> The default is the top middle of the image.<br/><br/> For ios, see the `calloutOffset` prop.
| `flat` | `Boolean` | | Sets whether this marker should be flat against the map true or a billboard facing the camera false.
| `identifier` | `String` | | An identifier used to reference this marker at a later date.
| `rotation` | `Float` | | A float number indicating marker's rotation angle.
| `rotation` | `Float` | | A float number indicating marker's rotation angle, in degrees.
| `draggable` | `<null>` | | This is a non-value based prop. Adding this allows the marker to be draggable (re-positioned).

## Events

To access event data, you will need to use `e.nativeEvent`. For example, `onPress={e => console.log(e.nativeEvent)}` will log the entire event object to your console.

| Event Name | Returns | Notes
|---|---|---|
| `onPress` | `{ coordinate: LatLng, position: Point }` | Callback that is called when the user presses on the marker
Expand Down
1 change: 1 addition & 0 deletions example/examples/EventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class EventListener extends React.Component {
<MapView.Polyline
strokeColor={'rgba(255,0,0,1)'}
onPress={this.recordEvent('Polyline::onPress')}
tappable
coordinates={[{
latitude: LATITUDE + (LATITUDE_DELTA / 5),
longitude: LONGITUDE - (LONGITUDE_DELTA / 4),
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Mar 02 17:03:11 PST 2017
#Mon May 08 11:03:28 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
4 changes: 2 additions & 2 deletions lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ android {

dependencies {
provided "com.facebook.react:react-native:+"
compile "com.google.android.gms:play-services-base:10.2.0"
compile "com.google.android.gms:play-services-maps:10.2.0"
compile "com.google.android.gms:play-services-base:10.2.4"
compile "com.google.android.gms:play-services-maps:10.2.4"
}
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.13.1
VERSION_NAME=0.15.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 @@ -59,7 +59,7 @@ public String getName() {

@Override
protected AirMapView createViewInstance(ThemedReactContext context) {
return new AirMapView(context, this, googleMapOptions);
return new AirMapView(context, this.appContext, this, googleMapOptions);
}

private void emitMapError(ThemedReactContext context, String message, String type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.airbnb.android.react.maps;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
Expand All @@ -20,6 +22,7 @@
import android.widget.RelativeLayout;

import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
Expand Down Expand Up @@ -85,9 +88,40 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
private final ThemedReactContext context;
private final EventDispatcher eventDispatcher;

public AirMapView(ThemedReactContext reactContext, AirMapManager manager,
GoogleMapOptions googleMapOptions) {
super(reactContext, googleMapOptions);
private static boolean contextHasBug(Context context) {
return context == null ||
context.getResources() == null ||
context.getResources().getConfiguration() == null;
}

// We do this to fix this bug:
// https://github.com/airbnb/react-native-maps/issues/271
//
// which conflicts with another bug regarding the passed in context:
// https://github.com/airbnb/react-native-maps/issues/1147
//
// Doing this allows us to avoid both bugs.
private static Context getNonBuggyContext(ThemedReactContext reactContext,
ReactApplicationContext appContext) {
Context superContext = reactContext;
if (!contextHasBug(appContext.getCurrentActivity())) {
superContext = appContext.getCurrentActivity();
} else if (contextHasBug(superContext)) {
// we have the bug! let's try to find a better context to use
if (!contextHasBug(reactContext.getCurrentActivity())) {
superContext = reactContext.getCurrentActivity();
} else if (!contextHasBug(reactContext.getApplicationContext())) {
superContext = reactContext.getApplicationContext();
} else {
// ¯\_(ツ)_/¯
}
}
return superContext;
}

public AirMapView(ThemedReactContext reactContext, ReactApplicationContext appContext, AirMapManager manager,
GoogleMapOptions googleMapOptions) {
super(getNonBuggyContext(reactContext, appContext), googleMapOptions);

this.manager = manager;
this.context = reactContext;
Expand Down
5 changes: 5 additions & 0 deletions lib/components/MapPolyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const propTypes = {
*/
onPress: PropTypes.func,

/* Boolean to allow a polyline to be tappable and use the
* onPress function
*/
tappable: PropTypes.bool,

/**
* The fill color to use for the path.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/AirGoogleMaps/AIRGMSPolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

#import <GoogleMaps/GoogleMaps.h>
#import "UIView+React.h"
#import <React/UIView+React.h>

@class AIRGoogleMapPolygon;

Expand Down
16 changes: 16 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGMSPolyline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AIRGMSPolyline.h
// AirMaps
//
// Created by Guilherme Pontes 04/05/2017.
//

#import <GoogleMaps/GoogleMaps.h>
#import "UIView+React.h"

@class AIRGoogleMapPolyline;

@interface AIRGMSPolyline : GMSPolyline
@property (nonatomic, strong) NSString *identifier;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@end
11 changes: 11 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGMSPolyline.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// AIRGMSPolyline.m
// AirMaps
//
// Created by Guilherme Pontes 04/05/2017.
//

#import "AIRGMSPolyline.h"

@implementation AIRGMSPolyline
@end
1 change: 1 addition & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@property (nonatomic, assign) BOOL showsMyLocationButton;

- (BOOL)didTapMarker:(GMSMarker *)marker;
- (void)didTapPolyline:(GMSPolyline *)polyline;
- (void)didTapPolygon:(GMSPolygon *)polygon;
- (void)didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;
- (void)didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate;
Expand Down
10 changes: 10 additions & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ - (BOOL)didTapMarker:(GMSMarker *)marker {
return NO;
}

- (void)didTapPolyline:(GMSOverlay *)polyline {
AIRGMSPolyline *airPolyline = (AIRGMSPolyline *)polyline;

id event = @{@"action": @"polyline-press",
@"id": airPolyline.identifier ?: @"unknown",
};

if (airPolyline.onPress) airPolyline.onPress(event);
}

- (void)didTapPolygon:(GMSOverlay *)polygon {
AIRGMSPolygon *airPolygon = (AIRGMSPolygon *)polygon;

Expand Down
1 change: 1 addition & 0 deletions lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@property (nonatomic, strong) AIRGoogleMapCallout *calloutView;
@property (nonatomic, strong) NSString *identifier;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, assign) CLLocationDegrees rotation;
@property (nonatomic, strong) AIRGMSMarker* realMarker;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, copy) RCTDirectEventBlock onDragStart;
Expand Down
Loading

0 comments on commit 108be14

Please sign in to comment.