diff --git a/.gitignore b/.gitignore index 28f1a21..190604a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,30 +30,7 @@ node_modules/ npm-debug.log # project specific -libMapboxGL.a -MapboxGL.bundle/ -MapboxGL.h -MGLAnnotation.h -MGLMapboxEvents.h -MGLMapView+IBAdditions.h -MGLMapView.h -MGLMetricsLocationManager.h -MGLTypes.h -MGLUserLocation.h -MGLAccountManager.h -MGLMapView_Private.h -ios/RCTMapboxGL/MGLAnnotationImage.h -ios/RCTMapboxGL/MGLGeometry.h -ios/RCTMapboxGL/MGLMapCamera.h -ios/RCTMapboxGL/MGLMultiPoint.h -ios/RCTMapboxGL/MGLOverlay.h -ios/RCTMapboxGL/MGLPointAnnotation.h -ios/RCTMapboxGL/MGLPolygon.h -ios/RCTMapboxGL/MGLPolyline.h -ios/RCTMapboxGL/MGLShape.h -ios/RCTMapboxGL/Mapbox.bundle/ -ios/RCTMapboxGL/Mapbox.h -ios/RCTMapboxGL/libMapbox.a +ios/Mapbox.framework android/build/ android/.gradle/ android/.idea/ diff --git a/index.ios.js b/index.ios.js index c3bb130..3111038 100644 --- a/index.ios.js +++ b/index.ios.js @@ -128,7 +128,8 @@ var MapView = React.createClass({ onFinishLoadingMap: React.PropTypes.func, onStartLoadingMap: React.PropTypes.func, onLocateUserFailed: React.PropTypes.func, - onLongPress: React.PropTypes.func + onLongPress: React.PropTypes.func, + contentInset: React.PropTypes.array }, getDefaultProps() { return { diff --git a/ios/API.md b/ios/API.md index 1a27833..00a39c2 100644 --- a/ios/API.md +++ b/ios/API.md @@ -20,6 +20,7 @@ | `attributionButtonIsHidden` | `bool` | Optional | `false` | Whether attribution button is visible in lower right corner. *If true you must still attribute OpenStreetMap in your app. [Ref](https://www.mapbox.com/about/maps/)* | | `logoIsHidden` | `bool` | Optional | `false` | Whether logo is visible in lower left corner. | | `compassIsHidden` | `bool` | Optional | `false` | Whether compass is visible when map is rotated. | +| `contentInset` | `array` | Optional | `[0, 0, 0, 0]` | Change the center point of the map. Offset is in pixels. `[top, right, bottom, left]` ## Event listeners diff --git a/ios/RCTMapboxGL.xcodeproj/project.pbxproj b/ios/RCTMapboxGL.xcodeproj/project.pbxproj index 6125d09..480068c 100644 --- a/ios/RCTMapboxGL.xcodeproj/project.pbxproj +++ b/ios/RCTMapboxGL.xcodeproj/project.pbxproj @@ -7,12 +7,11 @@ objects = { /* Begin PBXBuildFile section */ + C5AF3B8C1C5A8C3D0003BF64 /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5AF3B8B1C5A8C3D0003BF64 /* Mapbox.framework */; }; C5DBB3441AF2EF2B00E611A9 /* RCTMapboxGL.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */; }; C5DBB3461AF2EF2B00E611A9 /* RCTMapboxGL.m in Sources */ = {isa = PBXBuildFile; fileRef = C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */; }; C5DBB34C1AF2EF2B00E611A9 /* libRCTMapboxGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */; }; C5DBB3661AF2EFB500E611A9 /* RCTMapboxGLManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C5DBB3651AF2EFB500E611A9 /* RCTMapboxGLManager.m */; }; - C5DBB3961AF3361700E611A9 /* libMapbox.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C5DBB38C1AF3361700E611A9 /* libMapbox.a */; }; - C5DBB3A61AF338ED00E611A9 /* Mapbox.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = C5DBB38D1AF3361700E611A9 /* Mapbox.bundle */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -32,7 +31,6 @@ dstPath = "include/$(PRODUCT_NAME)"; dstSubfolderSpec = 16; files = ( - C5DBB3A61AF338ED00E611A9 /* Mapbox.bundle in CopyFiles */, C5DBB3441AF2EF2B00E611A9 /* RCTMapboxGL.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; @@ -40,6 +38,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + C5AF3B8B1C5A8C3D0003BF64 /* Mapbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Mapbox.framework; sourceTree = ""; }; C5DBB3401AF2EF2B00E611A9 /* libRCTMapboxGL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTMapboxGL.a; sourceTree = BUILT_PRODUCTS_DIR; }; C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTMapboxGL.h; sourceTree = ""; }; C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxGL.m; sourceTree = ""; }; @@ -47,14 +46,6 @@ C5DBB3511AF2EF2B00E611A9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C5DBB3641AF2EFB500E611A9 /* RCTMapboxGLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMapboxGLManager.h; sourceTree = ""; }; C5DBB3651AF2EFB500E611A9 /* RCTMapboxGLManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMapboxGLManager.m; sourceTree = ""; }; - C5DBB38C1AF3361700E611A9 /* libMapbox.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libMapbox.a; sourceTree = ""; }; - C5DBB38D1AF3361700E611A9 /* Mapbox.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Mapbox.bundle; sourceTree = ""; }; - C5DBB38E1AF3361700E611A9 /* Mapbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mapbox.h; sourceTree = ""; }; - C5DBB38F1AF3361700E611A9 /* MGLAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotation.h; sourceTree = ""; }; - C5DBB3911AF3361700E611A9 /* MGLMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView.h; sourceTree = ""; }; - C5DBB3921AF3361700E611A9 /* MGLMapView+IBAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MGLMapView+IBAdditions.h"; sourceTree = ""; }; - C5DBB3941AF3361700E611A9 /* MGLTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLTypes.h; sourceTree = ""; }; - C5DBB3951AF3361700E611A9 /* MGLUserLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocation.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,7 +53,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C5DBB3961AF3361700E611A9 /* libMapbox.a in Frameworks */, + C5AF3B8C1C5A8C3D0003BF64 /* Mapbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -80,6 +71,7 @@ C5DBB3371AF2EF2B00E611A9 = { isa = PBXGroup; children = ( + C5AF3B8B1C5A8C3D0003BF64 /* Mapbox.framework */, C5DBB3421AF2EF2B00E611A9 /* RCTMapboxGL */, C5DBB34F1AF2EF2B00E611A9 /* RCTMapboxGLTests */, C5DBB3411AF2EF2B00E611A9 /* Products */, @@ -98,14 +90,6 @@ C5DBB3421AF2EF2B00E611A9 /* RCTMapboxGL */ = { isa = PBXGroup; children = ( - C5DBB38C1AF3361700E611A9 /* libMapbox.a */, - C5DBB38D1AF3361700E611A9 /* Mapbox.bundle */, - C5DBB38E1AF3361700E611A9 /* Mapbox.h */, - C5DBB38F1AF3361700E611A9 /* MGLAnnotation.h */, - C5DBB3911AF3361700E611A9 /* MGLMapView.h */, - C5DBB3921AF3361700E611A9 /* MGLMapView+IBAdditions.h */, - C5DBB3941AF3361700E611A9 /* MGLTypes.h */, - C5DBB3951AF3361700E611A9 /* MGLUserLocation.h */, C5DBB3431AF2EF2B00E611A9 /* RCTMapboxGL.h */, C5DBB3451AF2EF2B00E611A9 /* RCTMapboxGL.m */, C5DBB3641AF2EFB500E611A9 /* RCTMapboxGLManager.h */, @@ -277,7 +261,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -314,7 +298,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -325,6 +309,10 @@ isa = XCBuildConfiguration; buildSettings = { ENABLE_BITCODE = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); HEADER_SEARCH_PATHS = ( /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", @@ -346,6 +334,10 @@ isa = XCBuildConfiguration; buildSettings = { ENABLE_BITCODE = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); HEADER_SEARCH_PATHS = ( /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(SRCROOT)/../node_modules/react-native/React/**", diff --git a/ios/RCTMapboxGL/RCTMapboxGL.h b/ios/RCTMapboxGL/RCTMapboxGL.h index 231750c..75d01c1 100644 --- a/ios/RCTMapboxGL/RCTMapboxGL.h +++ b/ios/RCTMapboxGL/RCTMapboxGL.h @@ -6,8 +6,7 @@ // Copyright (c) 2015 Mapbox. All rights reserved. // -#import "Mapbox.h" -#import "MGLMapView.h" +#import #import "RCTView.h" #import "RCTEventDispatcher.h" #import "RCTBridgeModule.h" @@ -44,6 +43,7 @@ - (double)zoomLevel; - (double)direction; - (CLLocationCoordinate2D)centerCoordinate; +- (void)setContentInset:(UIEdgeInsets)inset; @end diff --git a/ios/RCTMapboxGL/RCTMapboxGL.m b/ios/RCTMapboxGL/RCTMapboxGL.m index 9f79ef0..281197b 100644 --- a/ios/RCTMapboxGL/RCTMapboxGL.m +++ b/ios/RCTMapboxGL/RCTMapboxGL.m @@ -38,6 +38,7 @@ BOOL _attributionButton; BOOL _logo; BOOL _compass; + UIEdgeInsets _inset; } RCT_EXPORT_MODULE(); @@ -81,6 +82,7 @@ RCT_EXPORT_MODULE(); [_map.attributionButton setHidden:_attributionButton]; [_map.logoView setHidden:_logo]; [_map.compassView setHidden:_compass]; + _map.contentInset = _inset; } else { /* We need to have a height/width specified in order to render */ if (_accessToken && _styleURL && self.bounds.size.height > 0 && self.bounds.size.width > 0) { @@ -381,6 +383,12 @@ RCT_EXPORT_MODULE(); } } +- (void) setContentInset:(UIEdgeInsets)inset +{ + _inset = inset; + [self updateMap]; +} + - (void)removeAllAnnotations { NSUInteger keyCount = [_annotations count]; diff --git a/ios/RCTMapboxGL/RCTMapboxGLManager.m b/ios/RCTMapboxGL/RCTMapboxGLManager.m index d1b14cf..e036eda 100644 --- a/ios/RCTMapboxGL/RCTMapboxGLManager.m +++ b/ios/RCTMapboxGL/RCTMapboxGLManager.m @@ -8,7 +8,7 @@ #import "RCTMapboxGLManager.h" #import "RCTMapboxGL.h" -#import "Mapbox.h" +#import #import "RCTConvert+CoreLocation.h" #import "RCTConvert+MapKit.h" #import "RCTBridge.h" @@ -133,6 +133,16 @@ RCT_CUSTOM_VIEW_PROPERTY(annotations, CLLocationCoordinate2D, RCTMapboxGL) { } } +RCT_CUSTOM_VIEW_PROPERTY(contentInset, UIEdgeInsetsMake, RCTMapboxGL) +{ + int top = [json[0] intValue]; + int left = [json[3] intValue]; + int bottom = [json[2] intValue]; + int right = [json[1] intValue]; + UIEdgeInsets inset = UIEdgeInsetsMake((CGFloat)top, (CGFloat)left, (CGFloat)bottom, (CGFloat)right); + [view setContentInset:inset]; +} + RCT_CUSTOM_VIEW_PROPERTY(attributionButtonIsHidden, BOOL, RCTMapboxGL) { BOOL value = [json boolValue]; diff --git a/ios/RCTMapboxGL/Settings.bundle/Root.plist b/ios/RCTMapboxGL/Settings.bundle/Root.plist deleted file mode 100644 index 076f402..0000000 --- a/ios/RCTMapboxGL/Settings.bundle/Root.plist +++ /dev/null @@ -1,33 +0,0 @@ - - - - - PreferenceSpecifiers - - - Title - Privacy Settings - Type - PSGroupSpecifier - FooterText - This setting allows the application to share anonymized location and usage data with Mapbox. - - - DefaultValue - - Key - MGLMapboxMetricsEnabled - Title - Mapbox Metrics - Type - PSToggleSwitchSpecifier - TrueValue - - FalseValue - - - - StringsTable - Root - - diff --git a/ios/install.md b/ios/install.md index 4f096cd..ad8a8d2 100644 --- a/ios/install.md +++ b/ios/install.md @@ -1,21 +1,21 @@ # Manual installation process -1. `npm install react-native-mapbox-gl --save` -2. In the XCode's `Project navigator`, right click on project's name ➜ `Add Files to <...>` ![](https://cldup.com/k0oJwOUKPN.png) -3. Add `node_modules/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj` ![](https://cldup.com/bnJWwtaACM.png) -4. Select your project in the `Project navigator`. Click `Build Phases` then `Link Binary With Libraries`. Add `node_modules/react-native-mapbox-gl/ios/RCTMapboxGL/libRCTMapboxGL.a` ![](https://cldup.com/QWhL_SjobN.png) -5. Select your project in the `Project navigator`. Click `Build Phases` then `Copy Bundle Resources`. Click the `+` button. When the modal appears, click `Add other`. Add `node_modules/react-native-mapbox-gl/ios/RCTMapboxGL/Mapbox.bundle`. ![](https://cldup.com/Oi7uHxc1Fd.png) -6. Just like in the last step, select your project in the `Project navigator`. Click `Build Phases` then `Copy Bundle Resources`. Click the `+` button. When the modal appears, click `Add other`. Add `node_modules/react-native-mapbox-gl/ios/RCTMapboxGL/Settings.bundle`. [More information on location metrics can be found here](https://www.mapbox.com/mapbox-gl-ios/#metrics_opt_out). -7. Add the following Cocoa framework dependencies to your target's Link Binary With Libraries build phase: - * `CoreTelephony.framework` - * `GLKit.framework` - * `ImageIO.framework` - * `MobileCoreServices.framework` - * `QuartzCore.framework` - * `SystemConfiguration.framework` - * `libc++.tbd` - * `libsqlite3.tbd` - * `libz.tbd` - * ![](https://cldup.com/KuSEgMQQSy.gif) -8. Click on the `RCTMapboxGL` project. Under the `Build Settings` tab, search for `header_search_path`. Make sure `$(SRCROOT)/../../../React` and `$(SRCROOT)/../../react-native/React` are added and set to `recursive`. ![](https://cldup.com/81zUEHaKoX.png) -9. You can now `require('react-native-mapbox-gl')` and build. +_Make sure to follow these directions carefully._ + +First, +```bash +npm install react-native-mapbox-gl --save +``` + +1. In the XCode's `Project navigator`, right click on project's name ➜ `Add Files to <...>`. Add `node_modules/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj` ![](https://cldup.com/DTD2UZMYu5.png) +1. Select your project in the `Project navigator`. Click `General` tab then add `node_modules/react-native-mapbox-gl/ios/Mapbox.framework` to `Embedded Libraries`. :collision: **Important, make sure you're adding it to general -> `Embedded Libraries` :collision:** ![](https://cldup.com/s4U3JfS_-l.png) +1. In the `Build Phases` tab, click the plus sign and then `New Run Script Phase` ![](https://cldup.com/jgt8p_dHjD.png) +1. Open the newly added `Run Script` and paste (Only necessary when submitting to the app store, but a good idea to add this now): +```bash +bash + "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework/strip-frameworks.sh" +``` +![](https://cldup.com/SGt3NdX-yy.png) +1. In `Build Phases` tab, click `Link Binaries With Libraries` and add `libRCTMapboxGL.a` +![](https://cldup.com/FuOlGOwAli.png) +1. Add to project, [see example](./example.js) diff --git a/package.json b/package.json index bce8ce7..bce69d8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/mapbox/react-native-mapbox-gl" }, "scripts": { - "preinstall": "./scripts/download-mapbox-gl-native-ios.sh 3.0.0", + "preinstall": "./scripts/download-mapbox-gl-native-ios.sh 3.1.0-pre.2", "test": "npm run lint", "lint": "eslint --no-eslintrc -c .eslintrc index.ios.js index.android.js ios/example.js android/example.js", "start": "node_modules/react-native/packager/packager.sh" diff --git a/scripts/download-mapbox-gl-native-ios.sh b/scripts/download-mapbox-gl-native-ios.sh index 9a774af..928f0ec 100755 --- a/scripts/download-mapbox-gl-native-ios.sh +++ b/scripts/download-mapbox-gl-native-ios.sh @@ -8,20 +8,9 @@ cd ios/ if ! which curl > /dev/null; then echo "curl command not found. Please install curl"; exit 1; fi; if ! which unzip > /dev/null; then echo "unzip command not found. Please install unzip"; exit 1; fi; -if [ ! -d temp ]; then - mkdir temp -fi - -if [ -d ./RCTMapboxGL/Mapbox.bundle ]; then - rm -r RCTMapboxGL/Mapbox.bundle -fi - -mkdir RCTMapboxGL/Mapbox.bundle curl -sS https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-ios-sdk-$VERSION.zip > temp.zip unzip -o temp.zip -d temp -mv temp/libMapbox.a ./RCTMapboxGL -mv temp/Headers/* ./RCTMapboxGL -mv temp/Mapbox.bundle/* ./RCTMapboxGL/Mapbox.bundle +mv temp/dynamic/Mapbox.framework ./Mapbox.framework rm -r temp rm temp.zip