From 3ee56f50751ed8a018a8870052f5144290acfd62 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 29 Aug 2016 22:09:14 +0100 Subject: [PATCH 1/7] Expose pitchEnabled property (#407) * Expose the 'pitchEnabled' property, so developer can turn off 'two-fingers to tile map' feature. iOS-only so far. * Add `pitchEnabled` property to Android implementation * add `pitchEnabled` to docs --- API.md | 1 + .../ReactNativeMapboxGLManager.java | 5 +++++ .../ReactNativeMapboxGLView.java | 10 ++++++++++ index.js | 2 ++ ios/RCTMapboxGL/RCTMapboxGL.m | 13 +++++++++++-- ios/RCTMapboxGL/RCTMapboxGLManager.m | 1 + 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 2143064..289d7d3 100644 --- a/API.md +++ b/API.md @@ -29,6 +29,7 @@ import { MapView } from 'react-native-mapbox-gl'; | `rotateEnabled` | `boolean` | Optional | Whether the map can rotate. | `true` | | `scrollEnabled` | `boolean` | Optional | Whether the map can be scrolled. | `true` | | `zoomEnabled` | `boolean` | Optional | Whether the map zoom level can be changed. | `true` | +| `pitchEnabled` | `boolean` | Optional | Whether the map pitch (tilt) level can be changed via a two-finger drag (iOS) or three-finger drag (Android). | `true` | | `showsUserLocation` | `boolean` | Optional | Whether the user's location is shown on the map. Note: The map will not zoom to their location. | `false` | | `userTrackingMode` | `enum` | Optional | Wether the map is zoomed to and follows the user's location. One of `Mapbox.userTrackingMode.none`, `Mapbox.userTrackingMode.follow`, `Mapbox.userTrackingMode.followWithCourse`, `Mapbox.userTrackingMode.followWithHeading` | `Mapbox.userTrackingMode.none` | | `userLocationVerticalAlignment` | `enum` | Optional | Change the alignment of where the user location shows on the screen. One of `Mapbox.userLocationVerticalAlignment.top`, `Mapbox.userLocationVerticalAlignment.center`, `Mapbox.userLocationVerticalAlignment.bottom` | `Mapbox.userLocationVerticalAlignment.center` | diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java index 301c22e..adaba93 100644 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java +++ b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java @@ -131,6 +131,11 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager Date: Mon, 29 Aug 2016 23:09:48 +0200 Subject: [PATCH 2/7] specify where to add nodes inside the Manifest.xml (#401) --- android/install.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/install.md b/android/install.md index 46da583..50d2eb6 100644 --- a/android/install.md +++ b/android/install.md @@ -54,7 +54,7 @@ import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage; // <-- import #### Step 3 - Add Mapbox to AndroidManifest.xml -Add the following permissions to your `AndroidManifest.xml`: +Add the following permissions to the `` root node of your `AndroidManifest.xml`: ```xml @@ -63,7 +63,7 @@ Add the following permissions to your `AndroidManifest.xml`: ``` -Also, add the Mapbox analytics service: +Also, add the Mapbox analytics service to the `` node: ```xml From fd63f2b04c3adfbec23ca65a8bfaefe2123ec6bb Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Wed, 31 Aug 2016 12:44:54 -0400 Subject: [PATCH 3/7] Removing iOS in the title (#409) API Docs should now be merged between the two platforms. Removing the iOS designation from the title. Could make new users confused. --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index 289d7d3..5c35fa9 100644 --- a/API.md +++ b/API.md @@ -1,4 +1,4 @@ -# iOS API Docs +# API Docs ## Access token From 66960a6729793294375031ffed0d34d534861014 Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Wed, 31 Aug 2016 16:44:24 -0400 Subject: [PATCH 4/7] Update API.md (#410) Fixing minor syntax issue in example. --- API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 5c35fa9..a52fa08 100644 --- a/API.md +++ b/API.md @@ -228,14 +228,14 @@ mapbox://styles/bobbysud/cigtw1pzy0000aam2346f7ex0 strokeColor, // optional. string. Only for type=polygon or type=polyline. CSS color (#rrggbb). Controls line color. strokeWidth, // optional. number. Only for type=polygon or type=polyline. Controls line width. id, // required. string. Unique identifier used for adding or selecting an annotation. - annotationImage, { // optional. Marker image for type=point + annotationImage: { // optional. Marker image for type=point source: { uri // required. string. Either remote image URL or the name (without extension) of a bundled image }, height, // required. number. Image height width, // required. number. Image width }, - rightCalloutAccessory, { // optional. iOS only. Clickable image that appears when type=point marker pressed + rightCalloutAccessory: { // optional. iOS only. Clickable image that appears when type=point marker pressed source: { uri // required. string. Either remote image URL or the name (without extension) of a bundled image }, From d6330156028c2c20d97e16148f23175f1b0cd0d9 Mon Sep 17 00:00:00 2001 From: Marc Rooding Date: Fri, 9 Sep 2016 08:39:08 +0200 Subject: [PATCH 5/7] Changed all static properties to class methods with constructor this binding --- index.js | 64 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 25c6888..7169dd2 100644 --- a/index.js +++ b/index.js @@ -160,6 +160,22 @@ function addOfflineErrorListener(handler) { } class MapView extends Component { + constructor(props) { + super(props); + + this._onRegionDidChange = this._onRegionDidChange.bind(this); + this._onRegionWillChange = this._onRegionWillChange.bind(this); + this._onOpenAnnotation = this._onOpenAnnotation.bind(this); + this._onRightAnnotationTapped = this._onRightAnnotationTapped.bind(this); + this._onChangeUserTrackingMode = this._onChangeUserTrackingMode.bind(this); + this._onUpdateUserLocation = this._onUpdateUserLocation.bind(this); + this._onLongPress = this._onLongPress.bind(this); + this._onTap = this._onTap.bind(this); + this._onFinishLoadingMap = this._onFinishLoadingMap.bind(this); + this._onStartLoadingMap = this._onStartLoadingMap.bind(this); + this._onLocateUserFailed = this._onLocateUserFailed.bind(this); + this._onNativeComponentMount = this._onNativeComponentMount.bind(this); + } // Viewport setters setDirection(direction, animated = true, callback) { @@ -214,39 +230,39 @@ class MapView extends Component { } // Events - _onRegionDidChange = (event: Event) => { + _onRegionDidChange(event: Event) { if (this.props.onRegionDidChange) this.props.onRegionDidChange(event.nativeEvent.src); - }; - _onRegionWillChange = (event: Event) => { + } + _onRegionWillChange(event: Event) { if (this.props.onRegionWillChange) this.props.onRegionWillChange(event.nativeEvent.src); - }; - _onOpenAnnotation = (event: Event) => { + } + _onOpenAnnotation(event: Event) { if (this.props.onOpenAnnotation) this.props.onOpenAnnotation(event.nativeEvent.src); - }; - _onRightAnnotationTapped = (event: Event) => { + } + _onRightAnnotationTapped(event: Event) { if (this.props.onRightAnnotationTapped) this.props.onRightAnnotationTapped(event.nativeEvent.src); - }; - _onChangeUserTrackingMode = (event: Event) => { + } + _onChangeUserTrackingMode(event: Event) { if (this.props.onChangeUserTrackingMode) this.props.onChangeUserTrackingMode(event.nativeEvent.src); - }; - _onUpdateUserLocation = (event: Event) => { + } + _onUpdateUserLocation(event: Event) { if (this.props.onUpdateUserLocation) this.props.onUpdateUserLocation(event.nativeEvent.src); - }; - _onLongPress = (event: Event) => { + } + _onLongPress(event: Event) { if (this.props.onLongPress) this.props.onLongPress(event.nativeEvent.src); - }; - _onTap = (event: Event) => { + } + _onTap(event: Event) { if (this.props.onTap) this.props.onTap(event.nativeEvent.src); - }; - _onFinishLoadingMap = (event: Event) => { + } + _onFinishLoadingMap(event: Event) { if (this.props.onFinishLoadingMap) this.props.onFinishLoadingMap(event.nativeEvent.src); - }; - _onStartLoadingMap = (event: Event) => { + } + _onStartLoadingMap(event: Event) { if (this.props.onStartLoadingMap) this.props.onStartLoadingMap(event.nativeEvent.src); - }; - _onLocateUserFailed = (event: Event) => { + } + _onLocateUserFailed(event: Event) { if (this.props.onLocateUserFailed) this.props.onLocateUserFailed(event.nativeEvent.src); - }; + } static propTypes = { ...View.propTypes, @@ -363,7 +379,7 @@ class MapView extends Component { _native = null; - _onNativeComponentMount = (ref) => { + _onNativeComponentMount(ref) { if (this._native === ref) { return; } this._native = ref; @@ -375,7 +391,7 @@ class MapView extends Component { acc[annotation.id] = isImmutable ? annotation : cloneDeep(annotation); return acc; }, {}); - }; + } setNativeProps(nativeProps) { this._native && this._native.setNativeProps(nativeProps); From 353063eefce8b7529daab0b29a56884d940aef36 Mon Sep 17 00:00:00 2001 From: Carl Craig Date: Tue, 6 Sep 2016 14:15:44 +0100 Subject: [PATCH 6/7] fix large polyline annotations on android --- .../RNMGLAnnotationOptionsFactory.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java index f3cdc7a..efd98ed 100644 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java +++ b/android/src/main/java/com/mapbox/reactnativemapboxgl/RNMGLAnnotationOptionsFactory.java @@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.ReadableArray; import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.Icon; import com.mapbox.mapboxsdk.annotations.IconFactory; @@ -172,11 +173,19 @@ public class RNMGLAnnotationOptionsFactory { static RNMGLAnnotationOptions polylineOptionsFromJS(ReadableMap annotation) { PolylineOptions polyline = new PolylineOptions(); - int coordSize = annotation.getArray("coordinates").size(); - for (int p = 0; p < coordSize; p++) { - double latitude = annotation.getArray("coordinates").getArray(p).getDouble(0); - double longitude = annotation.getArray("coordinates").getArray(p).getDouble(1); - polyline.add(new LatLng(latitude, longitude)); + ReadableArray coordinates = annotation.getArray("coordinates"); + int coordinatesSize = coordinates.size(); + if (coordinatesSize > 0) { + LatLng[] points = new LatLng[coordinatesSize]; + ReadableArray coordinate; + for (int p = 0; p < coordinatesSize; p++) { + coordinate = coordinates.getArray(p); + points[p] = new LatLng( + coordinate.getDouble(0), + coordinate.getDouble(1) + ); + } + polyline.add(points); } if (annotation.hasKey("alpha")) { From 949f965ec733f94601f5ee6db6a1b395f395c85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 20 Sep 2016 13:39:17 -0700 Subject: [PATCH 7/7] Typos --- ios/install-cocoapods.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/install-cocoapods.md b/ios/install-cocoapods.md index 995475d..b699d0e 100644 --- a/ios/install-cocoapods.md +++ b/ios/install-cocoapods.md @@ -7,12 +7,12 @@ project, you can also add the react-native-mapbox-gl project to your Podfile. 2. In your `podfile`, make sure that `platform :ios, '8.0'` is set to `8.0` 3. Add `pod 'RCTMapboxGL', :path => 'node_modules/react-native-mapbox-gl/ios'` to your `Podfile` file. - (The path dependence on your Podfile location.) + (The path depends on your Podfile location.) 4. Open your Xcode project and ensure that the "Build Settings" parameter "Other linker flags" (`OTHER_LDFLAGS`) contains the CocoaPods generated linker options! * If you have used `react-native init` to setup your project you can just - remove this parameter. Just select the line and press the backspace key. + remove this parameter. Just select the line and press the Delete key. * Alternative, if you setup your Xcode project yourself, ensure that the parent configuration was included with a `$(inherited)` variable. 5. Install the new CocoaPods dependency with `pod install`.