├── ios
├── .framework_version
├── RCTMGL
│ ├── RCTMGL.m
│ ├── RCTMGLHeatmapLayerManager.h
│ ├── RCTMGL.h
│ ├── RCTMGLLightManager.h
│ ├── RCTMGLCameraManager.h
│ ├── RCTMGLCalloutManager.h
│ ├── RCTMGLFillLayerManager.h
│ ├── RCTMGLHeatmapLayer.h
│ ├── RCTMGLLineLayerManager.h
│ ├── RCTMGLCircleLayerManager.h
│ ├── RCTMGLImageSourceManager.h
│ ├── RCTMGLRasterLayer.h
│ ├── RCTMGLRasterLayerManager.h
│ ├── RCTMGLShapeSourceManager.h
│ ├── RCTMGLSymbolLayerManager.h
│ ├── RCTMGLVectorSourceManager.h
│ ├── MGLSnapshotModule.h
│ ├── RCTMGLRasterSourceManager.h
│ ├── MGLModule.h
│ ├── RCTMGLBackgroundLayer.h
│ ├── RCTMGLBackgroundLayerManager.h
│ ├── FilterParser.h
│ ├── RCTMGLCallout.h
│ ├── RCTMGLPointAnnotationManager.h
│ ├── RCTMGLFillExtrusionLayerManager.h
│ ├── RCTMGLCircleLayer.h
│ ├── RCTMGLLineLayer.h
│ ├── RCTMGLVectorSource.h
│ ├── RCTConvert+Mapbox.h
│ ├── RCTMGLUserLocation.h
│ ├── RCTMGLFillLayer.h
│ ├── MGLUserLocationHeadingIndicator.h
│ ├── RCTMGLEventProtocol.h
│ ├── RCTMGLLight.h
│ ├── ViewManager.h
│ ├── CameraMode.m
│ ├── RCTMGLLocationModule.h
│ ├── RNMBImageUtils.h
│ ├── RCTMGLFillExtrusionLayer.h
│ ├── RCTMGLImageSource.h
│ ├── CameraMode.h
│ ├── RCTMGLCalloutManager.m
│ ├── RCTMGLVectorSource.m
│ ├── RCTMGLMapViewManager.h
│ ├── MGLUserLocationHeadingArrowLayer.h
│ ├── RCTMGLLightManager.m
│ ├── MGLUserLocationHeadingBeamLayer.h
│ ├── RCTMGLLocation.h
│ ├── CameraUpdateItem.h
│ ├── MGLOfflineModule.h
│ ├── FilterParser.m
│ ├── RCTMGLLocationManagerDelegate.h
│ ├── RCTMGLSymbolLayer.h
│ ├── CameraUpdateQueue.h
│ ├── RCTMGLImageQueue.h
│ ├── RCTMGLImageQueueOperation.h
│ ├── RCTMGLImageSourceManager.m
│ ├── RCTMGLRasterSource.h
│ ├── RCTMGLEvent.h
│ ├── RCTMGLBackgroundLayer.m
│ ├── RCTMGLVectorSourceManager.m
│ ├── RCTMGLStyleValue.h
│ ├── MGLFaux3DUserLocationAnnotationView.h
│ ├── RCTMGLMapTouchEvent.h
│ ├── RCTMGLLocationManager.h
│ ├── RCTMGLRasterSourceManager.m
│ ├── RCTMGLRasterLayer.m
│ ├── RCTMGLLight.m
│ ├── RCTMGLUserLocation.m
│ ├── RCTConvert+Mapbox.m
│ ├── CameraStop.h
│ ├── RCTMGLRasterLayerManager.m
│ ├── RCTMGLLocation.m
│ ├── RCTMGLBackgroundLayerManager.m
│ ├── RCTMGLPointAnnotationManager.m
│ ├── RNMBImageUtils.m
│ ├── RCTMGLEvent.m
│ ├── RCTMGLFillLayerManager.m
│ ├── RCTMGLHeatmapLayerManager.m
│ ├── RCTMGLSource.h
│ ├── RCTMGLLineLayerManager.m
│ ├── RCTMGLCircleLayerManager.m
│ ├── RCTMGLSymbolLayerManager.m
│ ├── RCTMGLFillExtrusionLayerManager.m
│ ├── RCTMGLPointAnnotation.h
│ ├── RCTMGLShapeSource.h
│ ├── RCTMGLUtils.h
│ ├── RCTMGLCamera.h
│ ├── RCTMGLShapeSourceManager.m
│ ├── RCTMGLCameraManager.m
│ ├── RCTMGLRasterSource.m
│ ├── RCTMGLHeatmapLayer.m
│ ├── RCTMGLImageQueueOperation.m
│ ├── RCTMGLImageQueue.m
│ ├── CameraUpdateQueue.m
│ ├── RCTMGLLayer.h
│ ├── RCTMGLFillLayer.m
│ ├── RCTMGLLineLayer.m
│ ├── ViewManager.m
│ ├── RCTMGLCircleLayer.m
│ ├── RCTMGLFillExtrusionLayer.m
│ ├── RCTMGLImageSource.m
│ ├── RCTMGLEventTypes.h
│ ├── MGLUserLocationHeadingArrowLayer.m
│ ├── RCTMGLMapTouchEvent.m
│ ├── RCTMGLEventTypes.m
│ ├── RCTMGLLocationModule.m
│ ├── CameraStop.m
│ └── RCTMGLCallout.m
└── RCTMGL.xcodeproj
│ └── xcuserdata
│ └── reyhane.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── android
├── settings.gradle
└── rctmgl
│ ├── .settings
│ └── org.eclipse.buildship.core.prefs
│ ├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ └── strings.xml
│ │ ├── drawable
│ │ │ ├── empty_drawable.png
│ │ │ └── empty.xml
│ │ └── layout
│ │ │ └── annotation.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── mapbox
│ │ └── rctmgl
│ │ ├── utils
│ │ ├── ImageEntry.java
│ │ ├── SimpleEventCallback.java
│ │ ├── ResourceUtils.java
│ │ └── GeoViewport.java
│ │ ├── location
│ │ ├── UserLocationVerticalAlignment.java
│ │ ├── UserLocationLayerConstants.java
│ │ ├── UserTrackingState.java
│ │ └── UserLocation.java
│ │ ├── events
│ │ ├── IEvent.java
│ │ ├── OfflineEvent.java
│ │ ├── AndroidCallbackEvent.java
│ │ ├── MapChangeEvent.java
│ │ ├── PointAnnotationClickEvent.java
│ │ ├── MapUserTrackingModeEvent.java
│ │ ├── constants
│ │ │ ├── EventKeys.java
│ │ │ └── EventTypes.java
│ │ ├── AbstractEvent.java
│ │ ├── MapClickEvent.java
│ │ ├── FeatureClickEvent.java
│ │ └── EventEmitter.java
│ │ └── components
│ │ ├── annotation
│ │ ├── RCTMGLCallout.java
│ │ ├── RCTMGLCalloutManager.java
│ │ └── RCTMGLCalloutAdapter.java
│ │ ├── AbstractMapFeature.java
│ │ ├── camera
│ │ ├── constants
│ │ │ └── CameraMode.java
│ │ └── CameraUpdateQueue.java
│ │ ├── mapview
│ │ ├── RCTMGLAndroidTextureMapView.java
│ │ ├── helpers
│ │ │ └── CameraChangeTracker.java
│ │ └── RCTMGLAndroidTextureMapViewManager.java
│ │ ├── styles
│ │ ├── layers
│ │ │ ├── RCTMGLRasterLayer.java
│ │ │ ├── RCTMGLBackgroundLayer.java
│ │ │ ├── RCTMGLFillLayer.java
│ │ │ ├── RCTMGLLineLayer.java
│ │ │ ├── RCTMGLCircleLayer.java
│ │ │ ├── RCTMGLSymbolLayer.java
│ │ │ ├── RCTMGLHeatmapLayer.java
│ │ │ ├── RCTMGLFillExtrusionLayer.java
│ │ │ ├── RCTMGLRasterLayerManager.java
│ │ │ └── RCTMGLBackgroundLayerManager.java
│ │ ├── light
│ │ │ ├── RCTMGLLightManager.java
│ │ │ └── RCTMGLLight.java
│ │ └── sources
│ │ │ ├── RCTMGLVectorSource.java
│ │ │ ├── RCTMGLImageSource.java
│ │ │ ├── RCTMGLImageSourceManager.java
│ │ │ └── RCTMGLRasterSource.java
│ │ └── AbstractEvent.java
│ ├── proguard-rules.pro
│ └── build.gradle
├── assets
└── mapbox_logo.png
├── circle.yml
├── javascript
├── utils
│ ├── filterUtils.js
│ ├── geoUtils.js
│ └── BridgeValue.js
├── components
│ ├── AbstractSource.js
│ ├── Light.js
│ ├── Images.js
│ ├── NativeBridgeComponent.js
│ ├── AbstractLayer.js
│ ├── ImageSource.js
│ └── VectorSource.js
└── modules
│ ├── offline
│ ├── index.d.ts
│ ├── OfflinePack.js
│ └── OfflineCreatePackOptions.js
│ └── snapshot
│ ├── SnapshotOptions.js
│ └── snapshotManager.js
├── scripts
├── download-style-spec.sh
├── download-mapbox-gl-native-ios-if-on-mac.js
├── autogenHelpers
│ └── MarkdownBuilder.js
├── templates
│ ├── RCTMGLStyle.h.ejs
│ └── index.d.ts.ejs
└── download-mapbox-gl-native-ios.sh
├── babel.config.js
├── docs
├── Images.md
├── ImageSource.md
├── Callout.md
├── VectorSource.md
├── UserLocation.md
├── PointAnnotation.md
├── snapshotManager.md
├── RasterSource.md
└── Light.md
├── react-native-mapbox-gl.podspec
├── CONTRIBUTING.md
├── LICENSE
├── .gitignore
└── README.md
/ios/.framework_version:
--------------------------------------------------------------------------------
1 | 2.2.1
2 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':rctmgl'
2 |
--------------------------------------------------------------------------------
/assets/mapbox_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/map-ir/mapir-mapbox/HEAD/assets/mapbox_logo.png
--------------------------------------------------------------------------------
/android/rctmgl/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RCTMGL
3 |
4 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 8
4 | environment:
5 | PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
6 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/res/drawable/empty_drawable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/map-ir/mapir-mapbox/HEAD/android/rctmgl/src/main/res/drawable/empty_drawable.png
--------------------------------------------------------------------------------
/javascript/utils/filterUtils.js:
--------------------------------------------------------------------------------
1 | export function getFilter(filter) {
2 | if (!Array.isArray(filter) || filter.length === 0) {
3 | return [];
4 | }
5 |
6 | return filter;
7 | }
8 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGL.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGL.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGL.h"
10 |
11 | @implementation RCTMGL
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLHeatmapLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLHeatmapLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Dheeraj Yalamanchili on 6/8/19.
6 | //
7 |
8 | #import "ViewManager.h"
9 |
10 | @interface RCTMGLHeatmapLayerManager : ViewManager
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGL.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGL.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RCTMGL : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLightManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLightManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/26/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLLightManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/res/drawable/empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCameraManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCameraManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/22/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLCameraManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCalloutManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCalloutViewManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/13/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLCalloutManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLFillLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLHeatmapLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLHeatmapLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Dheeraj Yalamanchili on 6/8/19.
6 | //
7 |
8 | #import "RCTMGLLayer.h"
9 |
10 | @interface RCTMGLHeatmapLayer : RCTMGLLayer
11 |
12 | @property (nonatomic, copy) NSString *sourceLayerID;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLineLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLineLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLLineLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCircleLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCircleLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLCircleLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageSourceManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageSourceManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 11/29/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLImageSourceManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLRasterLayer : RCTMGLLayer
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLRasterLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLShapeSourceManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLShapeSourceManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLShapeSourceManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLSymbolLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLSymbolLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLSymbolLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLVectorSourceManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLVectorSourceManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLVectorSourceManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/javascript/components/AbstractSource.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | class AbstractSource extends React.PureComponent {
4 | setNativeProps(props) {
5 | if (this.refs.nativeSource) {
6 | this.refs.nativeSource.setNativeProps(props);
7 | }
8 | }
9 | }
10 |
11 | export default AbstractSource;
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLSnapshotModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // MGLSnapshotModule.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 12/1/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MGLSnapshotModule : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterSourceManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterSourceManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLRasterSourceManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ImageEntry.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.utils;
2 |
3 | public class ImageEntry {
4 | public String uri;
5 | public double scale = 1.0;
6 |
7 | public ImageEntry(String _uri, double _scale) {
8 | uri = _uri;
9 | scale = _scale;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // MGLModule.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface MGLModule : NSObject
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLBackgroundLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLBackgroundLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLBackgroundLayer : RCTMGLLayer
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLBackgroundLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLBackgroundLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLBackgroundLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/FilterParser.h:
--------------------------------------------------------------------------------
1 | //
2 | // FilterParser.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/3/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 | #import
9 |
10 | @interface FilterParser : NSObject
11 |
12 | + (NSPredicate*)parse:(NSArray *)filter;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCallout.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCalloutView.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/13/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @import Mapbox;
12 |
13 | @interface RCTMGLCallout : RCTView
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLPointAnnotationManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLPointAnnotationManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/12/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLPointAnnotationManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillExtrusionLayerManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillExtrusionLayerManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/15/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @interface RCTMGLFillExtrusionLayerManager : ViewManager
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCircleLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCircleLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 |
11 | @interface RCTMGLCircleLayer : RCTMGLLayer
12 |
13 | @property (nonatomic, copy) NSString *sourceLayerID;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLineLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLineLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLLineLayer : RCTMGLLayer
13 |
14 | @property (nonatomic, copy) NSString *sourceLayerID;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLVectorSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLVectorSource.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLSource.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLVectorSource : RCTMGLSource
13 |
14 | @property (nonatomic, copy) NSString *url;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserLocationVerticalAlignment.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.location;
2 |
3 | /**
4 | * Created by nickitaliano on 12/13/17.
5 | */
6 |
7 | public class UserLocationVerticalAlignment {
8 | public static final int CENTER = 0;
9 | public static final int TOP = 1;
10 | public static final int BOTTOM = 2;
11 | }
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTConvert+Mapbox.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTConvert+Mapbox.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RCTConvert (Mapbox)
13 |
14 | + (CLLocationCoordinate2D)GeoJSONPoint:(id)json;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLUserLocation.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLUserLocation.h
3 | // RCTMGL
4 |
5 | #import
6 | #import
7 | #import
8 |
9 | @interface RCTMGLUserLocation : NSObject
10 |
11 | + (id)sharedInstance;
12 |
13 | - (MGLUserLocationAnnotationView*)builtinUserAnnotation;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLFillLayer : RCTMGLLayer
13 |
14 | @property (nonatomic, copy) NSString *sourceLayerID;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLUserLocationHeadingIndicator.h:
--------------------------------------------------------------------------------
1 | #import
2 | @import Mapbox;
3 |
4 | @protocol MGLUserLocationHeadingIndicator
5 |
6 | - (instancetype)initWithUserLocationAnnotationView:(MGLUserLocationAnnotationView *)userLocationView;
7 | - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy;
8 | - (void)updateTintColor:(CGColorRef)color;
9 |
10 | @end
11 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLEventProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLEvent.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | @protocol RCTMGLEventProtocol
10 |
11 | @property (nonatomic, copy) NSString *type;
12 | @property (nonatomic, strong) NSDictionary *payload;
13 |
14 | - (NSDictionary*)toJSON;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/javascript/modules/offline/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'mapbox__react-native-mapbox-gl/javascript/modules/offline'
2 |
3 | declare class OfflinePack {
4 | constructor(pack: any);
5 |
6 | name(): string;
7 | bounds(): Array;
8 | metadata(): any;
9 | status(): Promise;
10 | resume(): Promise;
11 | pause(): Promise;
12 | }
13 |
14 | export { OfflinePack };
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLight.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLight.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/26/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | @import Mapbox;
11 |
12 | @interface RCTMGLLight : UIView
13 |
14 | @property (nonatomic, strong) MGLMapView *map;
15 | @property (nonatomic, strong) NSDictionary *reactStyle;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ios/RCTMGL/ViewManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/31/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLEvent.h"
11 |
12 | @interface ViewManager : RCTViewManager
13 |
14 | -(void)fireEvent:(RCTMGLEvent*)event withCallback:(RCTBubblingEventBlock)callback;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraMode.m:
--------------------------------------------------------------------------------
1 | //
2 | // CameraMode.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/6/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "CameraMode.h"
10 |
11 | @implementation CameraMode
12 |
13 | int const RCT_MAPBOX_CAMERA_MODE_FLIGHT = 1;
14 | int const RCT_MAPBOX_CAMERA_MODE_EASE = 2;
15 | int const RCT_MAPBOX_CAMERA_MODE_NONE = 3;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocationModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocationManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @interface RCTMGLLocationModule : RCTEventEmitter
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RNMBImageUtils.h:
--------------------------------------------------------------------------------
1 | //
2 | // RNMBImageUtils.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 1/18/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RNMBImageUtils : NSObject
13 |
14 | +(NSString *)createTempFile:(UIImage *)image;
15 | +(NSString *)createBase64:(UIImage *)image;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillExtrusionLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillExtrusionLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/15/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLayer.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLFillExtrusionLayer : RCTMGLLayer
13 |
14 | @property (nonatomic, copy) NSString *sourceLayerID;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageSource.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 11/29/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLSource.h"
10 |
11 | @interface RCTMGLImageSource : RCTMGLSource
12 |
13 | @property (nonatomic, copy) NSString *url;
14 | @property (nonatomic, copy) NSArray *> *coordinates;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraMode.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraMode.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/6/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CameraMode : NSObject
12 |
13 | extern int const RCT_MAPBOX_CAMERA_MODE_FLIGHT;
14 | extern int const RCT_MAPBOX_CAMERA_MODE_EASE;
15 | extern int const RCT_MAPBOX_CAMERA_MODE_NONE;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/scripts/download-style-spec.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Downloading MapboxGL Style Spec"
4 | cd style-spec/
5 |
6 | FILENAME=v8.json
7 |
8 | if [ -e "./${FILENAME}" ]; then
9 | echo "Removing old style spec ${FILENAME}"
10 | rm "./${FILENAME}"
11 | fi
12 |
13 | echo "Fetching new style spec ${FILENAME}"
14 | curl -sS https://raw.githubusercontent.com/mapbox/mapbox-gl-js/master/src/style-spec/reference/${FILENAME} -o ${FILENAME}
15 | cd ..
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCalloutManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCalloutViewManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/13/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLCalloutManager.h"
10 | #import "RCTMGLCallout.h"
11 |
12 | @implementation RCTMGLCalloutManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | - (UIView *)view
17 | {
18 | return [[RCTMGLCallout alloc] init];
19 | }
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLVectorSource.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLVectorSource.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLVectorSource.h"
10 |
11 | @implementation RCTMGLVectorSource
12 |
13 | - (MGLSource*)makeSource
14 | {
15 | return [[MGLVectorTileSource alloc] initWithIdentifier:self.id configurationURL:[NSURL URLWithString:_url]];
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLMapViewManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLMapViewManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLMapViewManager : ViewManager
13 |
14 | - (void)didTapMap:(UITapGestureRecognizer *)recognizer;
15 | - (void)didLongPressMap:(UILongPressGestureRecognizer *)recognizer;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/IEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import com.facebook.react.bridge.WritableMap;
4 |
5 | /**
6 | * Created by nickitaliano on 8/23/17.
7 | */
8 |
9 | public interface IEvent {
10 | int getID();
11 | String getKey();
12 | String getType();
13 | long getTimestamp();
14 | boolean equals(IEvent event);
15 | WritableMap getPayload();
16 | WritableMap toJSON();
17 | }
18 |
--------------------------------------------------------------------------------
/ios/RCTMGL.xcodeproj/xcuserdata/reyhane.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | RCTMGL.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLUserLocationHeadingArrowLayer.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "MGLUserLocationHeadingIndicator.h"
3 | @import Mapbox;
4 |
5 | @interface MGLUserLocationHeadingArrowLayer : CAShapeLayer
6 |
7 | - (instancetype)initWithUserLocationAnnotationView:(MGLUserLocationAnnotationView *)userLocationView;
8 | - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy;
9 | - (void)updateTintColor:(CGColorRef)color;
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLightManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLightManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/26/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLightManager.h"
10 | #import "RCTMGLLight.h"
11 |
12 | @implementation RCTMGLLightManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
17 |
18 | - (UIView*)view
19 | {
20 | return [RCTMGLLight new];
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLUserLocationHeadingBeamLayer.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "MGLUserLocationHeadingIndicator.h"
3 | @import Mapbox;
4 |
5 | @interface MGLUserLocationHeadingBeamLayer : CALayer
6 |
7 | - (MGLUserLocationHeadingBeamLayer *)initWithUserLocationAnnotationView:(MGLUserLocationAnnotationView *)userLocationView;
8 | - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy;
9 | - (void)updateTintColor:(CGColorRef)color;
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocation.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocation.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RCTMGLLocation : NSObject
13 |
14 | @property (nonatomic, strong) CLLocation *location;
15 | @property (nonatomic, strong) CLHeading *heading;
16 |
17 | - (NSDictionary *)toJSON;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | plugins: [
4 | // Use @babel/preset-flow when
5 | // https://github.com/babel/babel/issues/7233 is fixed
6 | '@babel/plugin-transform-flow-strip-types',
7 | ['@babel/plugin-proposal-class-properties', {loose: true}],
8 | '@babel/plugin-transform-exponentiation-operator',
9 | ],
10 | env: {
11 | production: {
12 | plugins: ['transform-remove-console'],
13 | },
14 | },
15 | };
16 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraUpdateItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraUpdateItem.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/6/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "CameraStop.h"
10 | #import "RCTMGLMapView.h"
11 |
12 | @interface CameraUpdateItem : NSObject
13 |
14 | @property (nonatomic, strong) CameraStop* _Nonnull cameraStop;
15 |
16 | - (void)execute:(RCTMGLMapView* _Nonnull)mapView withCompletionHandler:(nullable void (^)(void))completionHandler;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLOfflineModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // MGLOfflineModule.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @import Mapbox;
13 |
14 | @interface MGLOfflineModule : RCTEventEmitter
15 |
16 | extern NSString *const RCT_MAPBOX_OFFLINE_CALLBACK_PROGRESS;
17 | extern NSString *const RCT_MAPBOX_OFFLINE_CALLBACK_ERROR;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ios/RCTMGL/FilterParser.m:
--------------------------------------------------------------------------------
1 | //
2 | // FilterParser.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/3/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "FilterParser.h"
10 | #import
11 |
12 | @implementation FilterParser
13 |
14 | + (NSPredicate*)parse:(NSArray *)filterList
15 | {
16 | if (filterList == nil || filterList.count < 1) {
17 | return nil;
18 | }
19 | return [NSPredicate predicateWithMGLJSONObject:filterList];
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/docs/Images.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### Images defines the images used in Symbol etc layers
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | images | `object` | `none` | `false` | Specifies the external images in key-value pairs required for the shape source.
If you have an asset under Image.xcassets on iOS and the drawables directory on android
you can specify an array of string names with assets as the key `{ assets: ['pin'] }`. |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocationManagerDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocationManagerDelegate.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RCTMGLLocation.h"
12 |
13 | @class RCTMGLLocationManager;
14 |
15 | @protocol RCTMGLLocationManagerDelegate
16 |
17 | - (void)locationManager:(RCTMGLLocationManager *)locationManager didUpdateLocation:(RCTMGLLocation *)location;
18 |
19 | @end
20 |
21 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLSymbolLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLSymbolLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLLayer.h"
11 |
12 | @interface RCTMGLSymbolLayer : RCTMGLLayer
13 |
14 | @property (nonatomic, strong) NSMutableArray> *reactSubviews;
15 |
16 | @property (nonatomic, assign) BOOL snapshot;
17 | @property (nonatomic, copy) NSString *sourceLayerID;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraUpdateQueue.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraUpdateQueue.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/6/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "CameraStop.h"
10 | #import "CameraUpdateItem.h"
11 | #import "RCTMGLMapView.h"
12 |
13 | @interface CameraUpdateQueue : NSObject
14 |
15 | - (void)enqueue:(CameraStop* _Nonnull)cameraUpdateItem;
16 | - (CameraStop* _Nonnull)dequeue;
17 | - (void)flush;
18 | - (BOOL)isEmpty;
19 | - (void)execute:(RCTMGLMapView* _Nonnull)mapView;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageQueue.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageQueue.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface RCTMGLImageQueue : NSObject
13 |
14 | + (instancetype)sharedInstance;
15 |
16 | - (void)cancelAllOperations;
17 | - (void)addImage:(NSString *)imageURL scale:(double)scale bridge:(RCTBridge *)bridge completionHandler:(RCTImageLoaderCompletionBlock)handler;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageQueueOperation.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageQueueOperation.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 2/28/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 | #import
9 |
10 | @interface RCTMGLImageQueueOperation : NSBlockOperation
11 |
12 | @property (nonatomic, weak) RCTBridge *bridge;
13 | @property (nonatomic, copy) RCTImageLoaderCompletionBlock completionHandler;
14 | @property (nonatomic, copy) NSURLRequest *urlRequest;
15 | @property (nonatomic) double scale;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/scripts/download-mapbox-gl-native-ios-if-on-mac.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var version = process.argv[2];
4 | var path = require('path');
5 |
6 | // only download iOS SDK if on Mac OS
7 | if (process.platform === 'darwin') {
8 | var exec = require('child_process').exec;
9 | var cmd = `"${path.join(__dirname, 'download-mapbox-gl-native-ios.sh')}" ${version}`;
10 | exec(cmd, function(error, stdout, stderr) {
11 | if (error) {
12 | console.error(error);
13 | return;
14 | }
15 | console.log(stdout);
16 | console.log(stderr);
17 | });
18 | }
19 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageSourceManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageSourceManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 11/29/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLImageSourceManager.h"
10 | #import "RCTMGLImageSource.h"
11 |
12 | @implementation RCTMGLImageSourceManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(id, NSString)
17 | RCT_EXPORT_VIEW_PROPERTY(url, NSString)
18 | RCT_EXPORT_VIEW_PROPERTY(coordinates, NSArray)
19 |
20 | - (UIView*)view
21 | {
22 | return [RCTMGLImageSource new];
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLCallout.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.annotation;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.views.view.ReactViewGroup;
6 |
7 | /**
8 | * Created by nickitaliano on 10/11/17.
9 | */
10 |
11 | public class RCTMGLCallout extends ReactViewGroup {
12 | public RCTMGLCallout(Context context) {
13 | super(context);
14 | }
15 |
16 | @Override
17 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
18 | setMeasuredDimension(getWidth(), getHeight());
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractMapFeature.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.views.view.ReactViewGroup;
6 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
7 |
8 | /**
9 | * Created by nickitaliano on 9/6/17.
10 | */
11 |
12 | public abstract class AbstractMapFeature extends ReactViewGroup {
13 | public AbstractMapFeature(Context context) {
14 | super(context);
15 | }
16 |
17 | public abstract void addToMap(RCTMGLMapView mapView);
18 | public abstract void removeFromMap(RCTMGLMapView mapView);
19 | }
20 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/constants/CameraMode.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.camera.constants;
2 |
3 | import android.support.annotation.IntDef;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | /**
9 | * Created by nickitaliano on 9/6/17.
10 | */
11 |
12 | public class CameraMode {
13 |
14 | @IntDef({ FLIGHT, EASE, NONE })
15 | @Retention(RetentionPolicy.SOURCE)
16 | public @interface Mode {}
17 |
18 | public static final int FLIGHT = 1;
19 | public static final int EASE = 2;
20 | public static final int NONE = 3;
21 | }
22 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterSource.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLSource.h"
10 | @import Mapbox;
11 |
12 | @interface RCTMGLRasterSource : RCTMGLSource
13 |
14 | @property (nonatomic, copy) NSString *url;
15 | @property (nonatomic, copy) NSString *attribution;
16 |
17 | @property (nonatomic, strong) NSNumber *tileSize;
18 | @property (nonatomic, strong) NSNumber *minZoomLevel;
19 | @property (nonatomic, strong) NSNumber *maxZoomLevel;
20 |
21 | @property (nonatomic, assign) BOOL tms;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLEvent.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLEvent.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLEventProtocol.h"
11 |
12 | @interface RCTMGLEvent : NSObject
13 |
14 | @property (nonatomic, copy) NSString *type;
15 | @property (nonatomic, strong) NSDictionary *payload;
16 | @property (nonatomic, readonly) NSTimeInterval timestamp;
17 |
18 | + (RCTMGLEvent*)makeEvent:(NSString*)eventType;
19 | + (RCTMGLEvent*)makeEvent:(NSString*)eventType withPayload:(NSDictionary*)payload;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserLocationLayerConstants.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.location;
2 |
3 | /**
4 | * Created by nickitaliano on 1/8/18.
5 | */
6 |
7 | public class UserLocationLayerConstants {
8 | public static final String BACKGROUND_LAYER_ID = "mapbox-location-stroke-layer";
9 | public static final String FOREGROUND_LAYER_ID = "mapbox-location-layer";
10 | public static final String ACCURACY_LAYER_ID = "mapbox-location-accuracy-layer";
11 | public static final String BEARING_LAYER_ID = "mapbox-location-bearing-layer";
12 | public static final String NAVIGATION_LAYER_ID = "mapbox-location-navigation-layer";
13 | }
14 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserTrackingState.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.location;
2 |
3 | /**
4 | * Created by nickitaliano on 12/13/17.
5 | */
6 |
7 | public class UserTrackingState {
8 | // The map view not yet tracked the user location
9 | public static final int POSSIBLE = 0;
10 |
11 | // The map view has begun to move to the first user location
12 | public static final int BEGAN = 1;
13 |
14 | // The map views begins a significant transition
15 | public static final int SIGNIFICANT_TRANSITION = 2;
16 |
17 | // The map view has finished moving to the user location
18 | public static final int CHANGED = 3;
19 | }
20 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLAndroidTextureMapView.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.mapview;
2 |
3 | import android.content.Context;
4 | import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
5 | /**
6 | * Created by hernanmateo on 12/11/18.
7 | */
8 |
9 | @SuppressWarnings({"MissingPermission"})
10 | public class RCTMGLAndroidTextureMapView extends RCTMGLMapView {
11 | public static final String LOG_TAG = RCTMGLAndroidTextureMapView.class.getSimpleName();
12 |
13 | public RCTMGLAndroidTextureMapView(Context context, RCTMGLAndroidTextureMapViewManager manager, MapboxMapOptions options) {
14 | super(context, manager, options);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/res/layout/annotation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/react-native-mapbox-gl.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = "react-native-mapbox-gl"
7 | s.summary = "React Native Component for Mapbox GL"
8 | s.version = package['version']
9 | s.authors = { "Nick Italiano" => "ni6@njit.edu" }
10 | s.homepage = "https://github.com/@react-native-mapbox-gl/maps#readme"
11 | s.license = "MIT"
12 | s.platform = :ios, "8.0"
13 | s.source = { :git => "https://github.com/@react-native-mapbox-gl/maps.git" }
14 | s.source_files = "ios/RCTMGL/**/*.{h,m}"
15 |
16 | s.vendored_frameworks = 'ios/Mapbox.framework'
17 | s.dependency 'React'
18 | end
19 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLBackgroundLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLBackgroundLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLBackgroundLayer.h"
10 | #import "RCTMGLStyle.h"
11 |
12 | @implementation RCTMGLBackgroundLayer
13 |
14 | - (MGLStyleLayer*)makeLayer:(MGLStyle*)style
15 | {
16 | return [[MGLBackgroundStyleLayer alloc] initWithIdentifier:self.id];
17 | }
18 |
19 | - (void)addStyles
20 | {
21 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
22 | style.bridge = self.bridge;
23 | [style backgroundLayer:(MGLBackgroundStyleLayer*)self.styleLayer withReactStyle:self.reactStyle];
24 | }
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/docs/ImageSource.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
The georeferenced image scales and rotates as the user zooms and rotates the map
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | id | `string` | `none` | `false` | A string that uniquely identifies the source. |
8 | | url | `union` | `none` | `false` | An HTTP(S) URL, absolute file URL, or local file URL to the source image.
Gifs are currently not supported. |
9 | | coordinates | `arrayOf` | `none` | `true` | The top left, top right, bottom right, and bottom left coordinates for the image. |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLVectorSourceManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLVectorSourceManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLVectorSourceManager.h"
10 | #import "RCTMGLVectorSource.h"
11 |
12 | @implementation RCTMGLVectorSourceManager
13 |
14 | RCT_EXPORT_MODULE();
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
17 |
18 | - (UIView*)view
19 | {
20 | return [RCTMGLVectorSource new];
21 | }
22 |
23 | RCT_EXPORT_VIEW_PROPERTY(url, NSString);
24 | RCT_EXPORT_VIEW_PROPERTY(hasPressListener, BOOL)
25 | RCT_REMAP_VIEW_PROPERTY(onMapboxVectorSourcePress, onPress, RCTBubblingEventBlock)
26 | RCT_EXPORT_VIEW_PROPERTY(hitbox, NSDictionary)
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLStyleValue.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLStyleValue.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/11/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | @import Mapbox;
11 |
12 | @interface RCTMGLStyleValue : NSObject
13 |
14 | @property (nonatomic, strong) NSString *styleType;
15 | @property (nonatomic, strong) NSDictionary *rawStyleValue;
16 | @property (nonatomic, readonly) NSExpression *mglStyleValue;
17 |
18 | - (BOOL)shouldAddImage;
19 | - (NSString *)getImageURI;
20 | - (double)getImageScale;
21 | - (MGLTransition)getTransition;
22 | - (NSExpression *)getSphericalPosition;
23 | - (BOOL)isVisible;
24 |
25 | + (RCTMGLStyleValue*)make:(NSString*)expressionJSONStr;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLCalloutManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.annotation;
2 |
3 | import com.facebook.react.uimanager.ThemedReactContext;
4 | import com.facebook.react.uimanager.ViewGroupManager;
5 |
6 | /**
7 | * Created by nickitaliano on 10/11/17.
8 | */
9 |
10 | public class RCTMGLCalloutManager extends ViewGroupManager {
11 | public static final String REACT_CLASS = RCTMGLCallout.class.getSimpleName();
12 |
13 | @Override
14 | public String getName() {
15 | return REACT_CLASS;
16 | }
17 |
18 | @Override
19 | protected RCTMGLCallout createViewInstance(ThemedReactContext reactContext) {
20 | return new RCTMGLCallout(reactContext);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLFaux3DUserLocationAnnotationView.h:
--------------------------------------------------------------------------------
1 | //
2 | // MGLFaux3DUserLocationAnnotationView.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 12/20/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | @import Mapbox;
11 |
12 | extern const CGFloat MGLUserLocationAnnotationDotSize;
13 | extern const CGFloat MGLUserLocationAnnotationHaloSize;
14 |
15 | extern const CGFloat MGLUserLocationAnnotationPuckSize;
16 | extern const CGFloat MGLUserLocationAnnotationArrowSize;
17 |
18 | // Threshold in radians between heading indicator rotation updates.
19 | extern const CGFloat MGLUserLocationHeadingUpdateThreshold;
20 |
21 | @interface MGLFaux3DUserLocationAnnotationView : MGLUserLocationAnnotationView
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLMapTouchEvent.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLTouchEvent.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLEvent.h"
11 | #import "RCTMGLPointAnnotation.h"
12 | @import Mapbox;
13 |
14 | @interface RCTMGLMapTouchEvent : RCTMGLEvent
15 |
16 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
17 | @property (nonatomic, assign) CGPoint screenPoint;
18 |
19 | + (RCTMGLMapTouchEvent*)makeTapEvent:(MGLMapView*)mapView withPoint:(CGPoint)point;
20 | + (RCTMGLMapTouchEvent*)makeLongPressEvent:(MGLMapView*)mapView withPoint:(CGPoint)point;
21 | + (RCTMGLMapTouchEvent *)makeAnnotationTapEvent:(RCTMGLPointAnnotation *)pointAnnotation;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocationManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocationManager.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RCTMGLLocation.h"
12 | #import "RCTMGLLocationManagerDelegate.h"
13 |
14 | typedef void (^RCTMGLLocationBlock)(RCTMGLLocation *location);
15 |
16 | @interface RCTMGLLocationManager : NSObject
17 |
18 | @property (nonatomic, strong) id delegate;
19 |
20 | + (id)sharedInstance;
21 |
22 | - (void)start;
23 | - (void)stop;
24 | - (BOOL)isEnabled;
25 | - (RCTMGLLocation *)getLastKnownLocation;
26 | - (void)addListener:(RCTMGLLocationBlock)listener;
27 | - (void)removeListener:(RCTMGLLocationBlock)listener;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/OfflineEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import com.facebook.react.bridge.ReadableMap;
4 | import com.facebook.react.bridge.WritableMap;
5 |
6 | /**
7 | * Created by nickitaliano on 10/24/17.
8 | */
9 |
10 | public class OfflineEvent extends AbstractEvent {
11 | private String mEventKey;
12 | private WritableMap mPayload;
13 |
14 | public OfflineEvent(String eventKey, String eventType, WritableMap payload) {
15 | super(eventType);
16 | mEventKey = eventKey;
17 | mPayload = payload;
18 | }
19 |
20 | @Override
21 | public String getKey() {
22 | return mEventKey;
23 | }
24 |
25 | @Override
26 | public WritableMap getPayload() {
27 | return mPayload;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterSourceManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterSourceManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLRasterSourceManager.h"
10 | #import "RCTMGLRasterSource.h"
11 |
12 | @implementation RCTMGLRasterSourceManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(id, NSString)
17 | RCT_EXPORT_VIEW_PROPERTY(url, NSString)
18 | RCT_EXPORT_VIEW_PROPERTY(attribution, NSString)
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(tileSize, NSNumber)
21 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber)
22 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber)
23 |
24 | RCT_EXPORT_VIEW_PROPERTY(tms, BOOL)
25 |
26 | - (UIView*)view
27 | {
28 | return [RCTMGLRasterSource new];
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLRasterLayer.h"
10 | #import "RCTMGLStyle.h"
11 |
12 | @implementation RCTMGLRasterLayer
13 |
14 | - (MGLStyleLayer*)makeLayer:(MGLStyle*)style
15 | {
16 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
17 | MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithIdentifier:self.id source:source];
18 | return layer;
19 | }
20 |
21 | - (void)addStyles
22 | {
23 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
24 | style.bridge = self.bridge;
25 | [style rasterLayer:(MGLRasterStyleLayer*)self.styleLayer withReactStyle:self.reactStyle];
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLight.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLight.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/26/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLight.h"
10 | #import "RCTMGLStyle.h"
11 |
12 | @implementation RCTMGLLight
13 | {
14 | MGLLight *internalLight;
15 | }
16 |
17 | - (void)setReactStyle:(NSDictionary *)reactStyle
18 | {
19 | _reactStyle = reactStyle;
20 |
21 | if (_map != nil) {
22 | [self addStyles];
23 | }
24 | }
25 |
26 | - (void)setMap:(MGLMapView *)map
27 | {
28 | _map = map;
29 | [self addStyles];
30 | }
31 |
32 | - (void)addStyles
33 | {
34 | MGLLight *light = [[MGLLight alloc] init];
35 | RCTMGLStyle *style = [[RCTMGLStyle alloc] init];
36 | [style lightLayer:light withReactStyle:_reactStyle];
37 | _map.style.light = light;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/docs/Callout.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### Callout that displays information about a selected annotation near the annotation.
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | title | `string` | `none` | `false` | String that get's displayed in the default callout. |
8 | | style | `any` | `none` | `false` | Style property for the Animated.View wrapper, apply animations to this |
9 | | containerStyle | `any` | `none` | `false` | Style property for the native RCTMGLCallout container, set at your own risk. |
10 | | contentStyle | `any` | `none` | `false` | Style property for the content bubble. |
11 | | tipStyle | `any` | `none` | `false` | Style property for the triangle tip under the content. |
12 | | textStyle | `any` | `none` | `false` | Style property for the title in the content bubble. |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLUserLocation.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLUserLocation.m
3 | // RCTMGL
4 | //
5 |
6 | #import "RCTMGLUserLocation.h"
7 | #import
8 |
9 | @interface HiddenUserLocationAnnotationView : MGLUserLocationAnnotationView
10 |
11 | @end
12 |
13 | @implementation HiddenUserLocationAnnotationView
14 |
15 |
16 | - (void)update {
17 | self.frame = CGRectNull;
18 | }
19 |
20 | @end
21 |
22 |
23 | @implementation RCTMGLUserLocation : NSObject
24 |
25 | + (id)sharedInstance
26 | {
27 | static RCTMGLUserLocation *userLocation = nil;
28 | static dispatch_once_t onceToken;
29 | dispatch_once(&onceToken, ^{ userLocation = [[self alloc] init]; });
30 | return userLocation;
31 | }
32 |
33 | - (MGLUserLocationAnnotationView*)builtinUserAnnotation
34 | {
35 | return [[HiddenUserLocationAnnotationView alloc] init];
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/SimpleEventCallback.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.utils;
2 |
3 | import com.mapbox.mapboxsdk.maps.MapboxMap;
4 |
5 | import com.mapbox.rctmgl.components.AbstractEventEmitter;
6 | import com.mapbox.rctmgl.events.IEvent;
7 |
8 | /**
9 | * Created by nickitaliano on 8/31/17.
10 | */
11 |
12 | public class SimpleEventCallback implements MapboxMap.CancelableCallback {
13 | private AbstractEventEmitter mEventEmitter;
14 | private IEvent mEvent;
15 |
16 | public SimpleEventCallback(AbstractEventEmitter eventEmitter, IEvent event) {
17 | mEventEmitter = eventEmitter;
18 | mEvent = event;
19 | }
20 |
21 | @Override
22 | public void onCancel() {
23 | mEventEmitter.handleEvent(mEvent);
24 | }
25 |
26 | @Override
27 | public void onFinish() {
28 | mEventEmitter.handleEvent(mEvent);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.layers.RasterLayer;
6 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
7 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
8 |
9 | /**
10 | * Created by nickitaliano on 9/25/17.
11 | */
12 |
13 | public class RCTMGLRasterLayer extends RCTLayer {
14 | public RCTMGLRasterLayer(Context context) {
15 | super(context);
16 | }
17 |
18 | @Override
19 | public RasterLayer makeLayer() {
20 | return new RasterLayer(mID, mSourceID);
21 | }
22 |
23 | @Override
24 | public void addStyles() {
25 | RCTMGLStyleFactory.setRasterLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
6 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
7 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
8 |
9 | /**
10 | * Created by nickitaliano on 9/25/17.
11 | */
12 |
13 | public class RCTMGLBackgroundLayer extends RCTLayer {
14 | public RCTMGLBackgroundLayer(Context context) {
15 | super(context);
16 | }
17 |
18 | @Override
19 | public BackgroundLayer makeLayer() {
20 | return new BackgroundLayer(mID);
21 | }
22 |
23 | @Override
24 | public void addStyles() {
25 | RCTMGLStyleFactory.setBackgroundLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ## Setup for creating pull requests
4 |
5 | 1. You'll first need to go through a normal [react-native setup](https://facebook.github.io/react-native/docs/getting-started.html#content)
6 | 1. Create a new react-native project with `react-native init `
7 | 1. `cd` into your project
8 | 1. You have 2 options for linking `react-native-mapbox-gl`
9 | * Use `react-native link`
10 | * Clone `@react-native-mapbox-gl/maps` into the `node_modules` folder
11 | 1. Go through a normal install process for your platform
12 |
13 | Once installed, you can edit any file in `@react-native-mapbox-gl/maps`,
14 | commit the changes and push them to a fork for creating a pull request.
15 |
16 | ## Best practices for PR's
17 |
18 | 1. If you add a feature, make sure you add it to the documentation
19 | 1. If you add an objective-c or java method, make sure you update the declaration file: `index.d.ts`.
20 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTConvert+Mapbox.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTConvert+Mapbox.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTConvert+Mapbox.h"
10 |
11 | @implementation RCTConvert (Mapbox)
12 |
13 | + (CLLocationCoordinate2D)GeoJSONPoint:(id)json
14 | {
15 | NSDictionary *point = [self NSDictionary:json];
16 |
17 | if (![[point objectForKey:@"type"] isEqual: @"Point"]) {
18 | return CLLocationCoordinate2DMake(0, 0);
19 | }
20 |
21 | NSArray *coords = (NSArray*)[point objectForKey:@"coordinates"];
22 | if (coords == nil || coords.count < 2) {
23 | return CLLocationCoordinate2DMake(0, 0);
24 | }
25 |
26 | double lat = [[coords objectAtIndex:1] doubleValue];
27 | double lng = [[coords objectAtIndex:0] doubleValue];
28 |
29 | return CLLocationCoordinate2DMake(lat, lng);
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/javascript/modules/offline/OfflinePack.js:
--------------------------------------------------------------------------------
1 | import {NativeModules} from 'react-native';
2 |
3 | const MapboxGLOfflineManager = NativeModules.MGLOfflineModule;
4 |
5 | class OfflinePack {
6 | constructor(pack) {
7 | this.pack = pack;
8 | this._metadata = null;
9 | }
10 |
11 | get name() {
12 | const {metadata} = this;
13 | return metadata.name;
14 | }
15 |
16 | get bounds() {
17 | return this.pack.bounds;
18 | }
19 |
20 | get metadata() {
21 | if (!this._metadata) {
22 | this._metadata = JSON.parse(this.pack.metadata);
23 | }
24 | return this._metadata;
25 | }
26 |
27 | status() {
28 | return MapboxGLOfflineManager.getPackStatus(this.name);
29 | }
30 |
31 | resume() {
32 | return MapboxGLOfflineManager.resumePackDownload(this.name);
33 | }
34 |
35 | pause() {
36 | return MapboxGLOfflineManager.pausePackDownload(this.name);
37 | }
38 | }
39 |
40 | export default OfflinePack;
41 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components;
2 |
3 | import com.facebook.react.bridge.WritableMap;
4 | import com.facebook.react.uimanager.events.Event;
5 | import com.facebook.react.uimanager.events.RCTEventEmitter;
6 |
7 | import javax.annotation.Nullable;
8 |
9 | public class AbstractEvent extends Event {
10 | private String mEventName;
11 | private WritableMap mEvent;
12 |
13 | public AbstractEvent(int viewId, String eventName, @Nullable WritableMap event) {
14 | super(viewId);
15 | mEventName = eventName;
16 | mEvent = event;
17 | }
18 |
19 | @Override
20 | public String getEventName() {
21 | return mEventName;
22 | }
23 |
24 | @Override
25 | public void dispatch(RCTEventEmitter rctEventEmitter) {
26 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), mEvent);
27 | }
28 | }
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/AndroidCallbackEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.react.bridge.WritableArray;
6 | import com.facebook.react.bridge.WritableMap;
7 | import com.mapbox.rctmgl.events.constants.EventKeys;
8 |
9 | /**
10 | * Created by nickitaliano on 10/3/17.
11 | */
12 |
13 | public class AndroidCallbackEvent extends AbstractEvent {
14 | private String mKey;
15 | private WritableMap mPayload;
16 |
17 | public AndroidCallbackEvent(View view, String callbackID, String key) {
18 | super(view, callbackID);
19 | mKey = key;
20 | }
21 |
22 | public void setPayload(WritableMap payload) {
23 | mPayload = payload;
24 | }
25 |
26 | @Override
27 | public String getKey() {
28 | return mKey;
29 | }
30 |
31 | @Override
32 | public WritableMap getPayload() {
33 | return mPayload;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraStop.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraStop.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/5/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | @import Mapbox;
10 | #import "RCTMGLCamera.h"
11 |
12 | @interface CameraStop : NSObject
13 |
14 | @property (nonatomic, strong) NSNumber *pitch;
15 | @property (nonatomic, strong) NSNumber *heading;
16 | @property (nonatomic, strong) NSNumber *zoom;
17 | @property (nonatomic, strong) NSNumber *boundsPaddingLeft;
18 | @property (nonatomic, strong) NSNumber *boundsPaddingRight;
19 | @property (nonatomic, strong) NSNumber *boundsPaddingTop;
20 | @property (nonatomic, strong) NSNumber *boundsPaddingBottom;
21 | @property (nonatomic, strong) NSNumber *mode;
22 | @property (nonatomic, assign) NSTimeInterval duration;
23 |
24 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
25 | @property (nonatomic, assign) MGLCoordinateBounds bounds;
26 |
27 | + (CameraStop*)fromDictionary:(NSDictionary*)args;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLRasterLayerManager.h"
10 | #import "RCTMGLRasterLayer.h"
11 |
12 | @implementation RCTMGLRasterLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // standard layer props
17 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
18 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
23 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
24 |
25 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
26 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
27 |
28 | - (UIView*)view
29 | {
30 | RCTMGLRasterLayer *layer = [[RCTMGLRasterLayer alloc] init];
31 | layer.bridge = self.bridge;
32 | return layer;
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ResourceUtils.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.v4.content.ContextCompat;
7 |
8 | /**
9 | * Created by nickitaliano on 10/19/17.
10 | */
11 |
12 | public class ResourceUtils {
13 | public static Drawable getDrawableByName(Context context, String resourceName) {
14 | if (context == null || resourceName == null || resourceName.isEmpty()) {
15 | return null;
16 | }
17 |
18 | Resources resources = context.getResources();
19 | if (resources == null) {
20 | return null;
21 | }
22 |
23 | final int resID = resources.getIdentifier(resourceName, "drawable", context.getPackageName());
24 | if (resID == 0) {
25 | return null;
26 | }
27 |
28 | return ContextCompat.getDrawable(context, resID);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocation.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocation.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLocation.h"
10 |
11 | @implementation RCTMGLLocation
12 |
13 | - (NSDictionary *)toJSON
14 | {
15 | NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
16 |
17 | NSMutableDictionary *coords = [[NSMutableDictionary alloc] init];
18 | coords[@"longitude"] = @(_location.coordinate.longitude);
19 | coords[@"latitude"] = @(_location.coordinate.latitude);
20 | coords[@"altitude"] = @(_location.altitude);
21 | coords[@"accuracy"] = @(_location.horizontalAccuracy);
22 | coords[@"heading"] = @(_heading.trueHeading);
23 | coords[@"speed"] = @(_location.speed);
24 |
25 | json[@"coords"] = coords;
26 | json[@"timestamp"] = @([_location.timestamp timeIntervalSince1970]);
27 |
28 | return json;
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/docs/VectorSource.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
8 | | url | `string` | `none` | `false` | A URL to a TileJSON configuration file describing the source’s contents and other metadata. |
9 | | onPress | `func` | `none` | `false` | Source press listener, gets called when a user presses one of the children layers only
if that layer has a higher z-index than another source layers |
10 | | hitbox | `shape` | `none` | `false` | Overrides the default touch hitbox(44x44 pixels) for the source layers |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLBackgroundLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLBackgroundLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLBackgroundLayerManager.h"
10 | #import "RCTMGLBackgroundLayer.h"
11 |
12 | @implementation RCTMGLBackgroundLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // standard layer props
17 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
18 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
23 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
24 |
25 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
26 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
27 |
28 | - (UIView*)view
29 | {
30 | RCTMGLBackgroundLayer *layer = [[RCTMGLBackgroundLayer alloc] init];
31 | layer.bridge = self.bridge;
32 | return layer;
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLPointAnnotationManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLPointAnnotationManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/12/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLPointAnnotationManager.h"
10 | #import "RCTMGLPointAnnotation.h"
11 |
12 | @implementation RCTMGLPointAnnotationManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(id, NSString)
17 | RCT_EXPORT_VIEW_PROPERTY(anchor, NSDictionary)
18 |
19 | RCT_REMAP_VIEW_PROPERTY(selected, reactSelected, BOOL)
20 | RCT_REMAP_VIEW_PROPERTY(title, reactTitle, NSString)
21 | RCT_REMAP_VIEW_PROPERTY(snippet, reactSnippet, NSString)
22 | RCT_REMAP_VIEW_PROPERTY(coordinate, reactCoordinate, NSString)
23 |
24 | RCT_REMAP_VIEW_PROPERTY(onMapboxPointAnnotationSelected, onSelected, RCTBubblingEventBlock)
25 | RCT_REMAP_VIEW_PROPERTY(onMapboxPointAnnotationDeselected, onDeselected, RCTBubblingEventBlock)
26 |
27 | - (UIView *)view
28 | {
29 | return [[RCTMGLPointAnnotation alloc] init];
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RNMBImageUtils.m:
--------------------------------------------------------------------------------
1 | //
2 | // RNMBImageUtils.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 1/18/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RNMBImageUtils.h"
10 |
11 | @implementation RNMBImageUtils
12 |
13 | + (NSString *)createTempFile:(UIImage *)image
14 | {
15 | NSString *fileID = [[NSUUID UUID] UUIDString];
16 | NSString *pathComponent = [NSString stringWithFormat:@"Documents/rctmgl-snapshot-%@.%@", fileID, @"png"];
17 | NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent: pathComponent];
18 |
19 | NSData *data = UIImagePNGRepresentation(image);
20 | [data writeToFile:filePath atomically:YES];
21 |
22 | return filePath;
23 | }
24 |
25 | + (NSString *)createBase64:(UIImage *)image
26 | {
27 | NSData *data = UIImagePNGRepresentation(image);
28 | return [NSString stringWithFormat:@"%@%@", @"data:image/png;base64,", [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]];
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/light/RCTMGLLightManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.light;
2 |
3 | import com.facebook.react.bridge.ReadableMap;
4 | import com.facebook.react.uimanager.ThemedReactContext;
5 | import com.facebook.react.uimanager.ViewGroupManager;
6 | import com.facebook.react.uimanager.annotations.ReactProp;
7 |
8 | /**
9 | * Created by nickitaliano on 9/26/17.
10 | */
11 |
12 | public class RCTMGLLightManager extends ViewGroupManager {
13 | public static final String REACT_CLASS = RCTMGLLight.class.getSimpleName();
14 |
15 | @Override
16 | public String getName() {
17 | return REACT_CLASS;
18 | }
19 |
20 | @Override
21 | protected RCTMGLLight createViewInstance(ThemedReactContext reactContext) {
22 | return new RCTMGLLight(reactContext);
23 | }
24 |
25 | @ReactProp(name="reactStyle")
26 | public void setReactStyle(RCTMGLLight light, ReadableMap reactStyle) {
27 | light.setReactStyle(reactStyle);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLEvent.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLEvent.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLEvent.h"
10 |
11 | @implementation RCTMGLEvent
12 |
13 | - (instancetype)init
14 | {
15 | if (self = [super init]) {
16 | _timestamp = [[NSDate date] timeIntervalSince1970];
17 | }
18 | return self;
19 | }
20 |
21 | - (NSDictionary*)payload
22 | {
23 | if (_payload == nil) {
24 | return @{};
25 | }
26 | return _payload;
27 | }
28 |
29 | - (NSDictionary*)toJSON
30 | {
31 | return @{ @"type": self.type, @"payload": self.payload };
32 | }
33 |
34 | + (RCTMGLEvent*)makeEvent:(NSString*)type
35 | {
36 | return [RCTMGLEvent makeEvent:type withPayload:@{}];
37 | }
38 |
39 | + (RCTMGLEvent*)makeEvent:(NSString*)type withPayload:(NSDictionary*)payload
40 | {
41 | RCTMGLEvent *event = [[RCTMGLEvent alloc] init];
42 | event.type = type;
43 | event.payload = payload;
44 | return event;
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/android/rctmgl/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/nickitaliano/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLFillLayerManager.h"
10 | #import "RCTMGLFillLayer.h"
11 |
12 | @implementation RCTMGLFillLayerManager
13 |
14 | RCT_EXPORT_MODULE();
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
17 |
18 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
19 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
20 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
21 |
22 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
23 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
24 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
25 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
26 |
27 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
28 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
29 |
30 | - (UIView*)view
31 | {
32 | RCTMGLFillLayer *layer = [RCTMGLFillLayer new];
33 | layer.bridge = self.bridge;
34 | return layer;
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLHeatmapLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLHeatmapLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Dheeraj Yalamanchili on 6/8/19.
6 | //
7 |
8 | #import "RCTMGLHeatmapLayerManager.h"
9 | #import "RCTMGLHeatmapLayer.h"
10 |
11 | @implementation RCTMGLHeatmapLayerManager
12 |
13 | RCT_EXPORT_MODULE()
14 |
15 | // Heatmap layer props
16 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
17 |
18 | // standard layer props
19 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
20 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
22 |
23 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
24 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
25 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
26 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
27 |
28 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
29 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
30 |
31 | - (UIView*)view
32 | {
33 | RCTMGLHeatmapLayer *layer = [RCTMGLHeatmapLayer new];
34 | layer.bridge = self.bridge;
35 | return layer;
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // BaseSource.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLLayer.h"
11 | #import
12 | @import Mapbox;
13 |
14 | @interface RCTMGLSource : UIView
15 |
16 | extern NSString *const DEFAULT_SOURCE_ID;
17 |
18 | @property (nonatomic, strong) NSMutableArray> *reactSubviews;
19 | @property (nonatomic, strong) NSMutableArray *layers;
20 | @property (nonatomic, strong) MGLSource *source;
21 | @property (nonatomic, strong) RCTMGLMapView *map;
22 | @property (nonatomic, strong) NSDictionary *hitbox;
23 |
24 | @property (nonatomic, copy) NSString *id;
25 | @property (nonatomic, assign) BOOL hasPressListener;
26 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
27 |
28 | - (void)addToMap;
29 | - (void)removeFromMap;
30 | - (MGLSource*)makeSource;
31 | - (NSArray *)getLayerIDs;
32 |
33 | + (BOOL)isDefaultSource:(NSString*)sourceID;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/scripts/autogenHelpers/MarkdownBuilder.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const path = require('path');
3 | const ejs = require('ejs');
4 |
5 | const TMPL_PATH = path.join(__dirname, '..', 'templates');
6 | const TMPL_FILE = fs.readFileSync(path.join(TMPL_PATH, 'component.md.ejs'), 'utf8');
7 |
8 | class MarkdownBuilder {
9 |
10 | generateComponentFile (docJSON, componentName) {
11 | const tmpl = ejs.compile(TMPL_FILE, { strict: true });
12 | const fileContents = tmpl({ component: docJSON[componentName] });
13 | fs.writeFileSync(path.join(__dirname, '..', '..', 'docs', `${componentName}.md`), fileContents);
14 | }
15 |
16 | generate () {
17 | const docJSONFile = fs.readFileSync(path.join(__dirname, '..', '..', 'docs', 'docs.json'), 'utf8');
18 | const docJSON = JSON.parse(docJSONFile);
19 | const componentPaths = Object.keys(docJSON);
20 |
21 | for (let componentPath of componentPaths) {
22 | this.generateComponentFile(docJSON, componentPath);
23 | }
24 |
25 | console.log('Markdown is finish generating');
26 | }
27 | }
28 |
29 | module.exports = MarkdownBuilder;
30 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapChangeEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.react.bridge.Arguments;
6 | import com.facebook.react.bridge.WritableMap;
7 |
8 | import com.mapbox.rctmgl.events.constants.EventKeys;
9 |
10 | /**
11 | * Created by nickitaliano on 8/27/17.
12 | */
13 |
14 | public class MapChangeEvent extends AbstractEvent {
15 | private WritableMap mPayload;
16 |
17 | public MapChangeEvent(View view, String eventType) {
18 | this(view, Arguments.createMap(), eventType);
19 | }
20 |
21 | public MapChangeEvent(View view, WritableMap payload, String eventType) {
22 | super(view, eventType);
23 | mPayload = payload;
24 | }
25 |
26 | @Override
27 | public String getKey() {
28 | return EventKeys.MAP_ONCHANGE;
29 | }
30 |
31 | @Override
32 | public WritableMap getPayload() {
33 | // FMTODO
34 | WritableMap payloadClone = Arguments.createMap();
35 | payloadClone.merge(mPayload);
36 | return payloadClone;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLineLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLineLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLineLayerManager.h"
10 | #import "RCTMGLLineLayer.h"
11 |
12 | @implementation RCTMGLLineLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // line layer props
17 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
18 |
19 | // standard layer props
20 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
23 |
24 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
25 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
26 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
27 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
28 |
29 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
30 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
31 |
32 | - (UIView*)view
33 | {
34 | RCTMGLLineLayer *layer = [RCTMGLLineLayer new];
35 | layer.bridge = self.bridge;
36 | return layer;
37 | }
38 |
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCircleLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCircleLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLCircleLayerManager.h"
10 | #import "RCTMGLCircleLayer.h"
11 |
12 | @implementation RCTMGLCircleLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // circle layer props
17 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
18 |
19 | // standard layer props
20 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
23 |
24 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
25 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
26 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
27 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
28 |
29 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
30 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
31 |
32 | - (UIView*)view
33 | {
34 | RCTMGLCircleLayer *layer = [RCTMGLCircleLayer new];
35 | layer.bridge = self.bridge;
36 | return layer;
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Shiveh Software Co.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/javascript/components/Light.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {requireNativeComponent} from 'react-native';
3 |
4 | import {viewPropTypes} from '../utils';
5 | import {LightLayerStyleProp} from '../utils/styleMap';
6 |
7 | import AbstractLayer from './AbstractLayer';
8 |
9 | export const NATIVE_MODULE_NAME = 'RCTMGLLight';
10 |
11 | /**
12 | * Light represents the light source for extruded geometries
13 | */
14 | class Light extends AbstractLayer {
15 | static propTypes = {
16 | ...viewPropTypes,
17 |
18 | /**
19 | * Customizable style attributes
20 | */
21 | style: LightLayerStyleProp,
22 | };
23 |
24 | setNativeProps(props) {
25 | if (this.refs.nativeLight) {
26 | this.refs.nativeLight.setNativeProps(props);
27 | }
28 | }
29 |
30 | render() {
31 | return (
32 |
38 | );
39 | }
40 | }
41 |
42 | const RCTMGLLight = requireNativeComponent(NATIVE_MODULE_NAME, Light, {
43 | nativeOnly: {reactStyle: true},
44 | });
45 |
46 | export default Light;
47 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLSymbolLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLSymbolLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLSymbolLayerManager.h"
10 | #import "RCTMGLSymbolLayer.h"
11 |
12 | @implementation RCTMGLSymbolLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // circle layer props
17 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
18 |
19 | // standard layer props
20 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
23 | RCT_EXPORT_VIEW_PROPERTY(snapshot, BOOL);
24 |
25 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
26 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
27 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
28 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
29 |
30 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
31 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
32 |
33 | - (UIView*)view
34 | {
35 | RCTMGLSymbolLayer *layer = [RCTMGLSymbolLayer new];
36 | layer.bridge = self.bridge;
37 | return layer;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillExtrusionLayerManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillExtrusionLayerManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/15/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLFillExtrusionLayerManager.h"
10 | #import "RCTMGLFillExtrusionLayer.h"
11 |
12 | @implementation RCTMGLFillExtrusionLayerManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | // fill extrusion layer props
17 | RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
18 |
19 | // standard layer props
20 | RCT_EXPORT_VIEW_PROPERTY(id, NSString);
21 | RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
22 | RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
23 |
24 | RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
25 | RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);
26 | RCT_EXPORT_VIEW_PROPERTY(layerIndex, NSNumber);
27 | RCT_EXPORT_VIEW_PROPERTY(reactStyle, NSDictionary);
28 |
29 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber);
30 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber);
31 |
32 | - (UIView*)view
33 | {
34 | RCTMGLFillExtrusionLayer *layer = [RCTMGLFillExtrusionLayer new];
35 | layer.bridge = self.bridge;
36 | return layer;
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLPointAnnotation.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLPointAnnotation.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/12/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import "RCTMGLCallout.h"
13 |
14 | @import Mapbox;
15 |
16 | @interface RCTMGLPointAnnotation : MGLAnnotationView
17 |
18 | @property (nonatomic, weak) MGLMapView *map;
19 | @property (nonatomic, strong) RCTMGLCallout *calloutView;
20 |
21 | @property (nonatomic, copy) NSString *id;
22 | @property (nonatomic, copy) NSString *reactTitle;
23 | @property (nonatomic, copy) NSString *reactSnippet;
24 |
25 | @property (nonatomic, copy) NSString *reactCoordinate;
26 | @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
27 |
28 | @property (nonatomic, copy) NSDictionary *anchor;
29 |
30 | @property (nonatomic, copy) RCTBubblingEventBlock onSelected;
31 | @property (nonatomic, copy) RCTBubblingEventBlock onDeselected;
32 |
33 | @property (nonatomic, assign) BOOL reactSelected;
34 |
35 | - (MGLAnnotationView *)getAnnotationView;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/scripts/templates/RCTMGLStyle.h.ejs:
--------------------------------------------------------------------------------
1 | <%
2 | const layers = locals.layers;
3 | -%>
4 | // DO NOT MODIFY
5 | // THIS FILE IS AUTOGENERATED
6 |
7 | #import "RCTMGLStyle.h"
8 | #import "RCTMGLStyleValue.h"
9 | #import
10 |
11 | @import Mapbox;
12 |
13 | @interface RCTMGLStyle : NSObject
14 |
15 | @property (nonatomic, weak) RCTBridge *bridge;
16 | @property (nonatomic, strong) MGLStyle *style;
17 |
18 | - (id)initWithMGLStyle:(MGLStyle*)mglStyle;
19 |
20 | <%_ for (const layer of layers) { _%>
21 | - (void)<%- setLayerMethodName(layer, 'ios') -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle;
22 | <%_ } _%>
23 |
24 | <%_ for (const layer of layers) { _%>
25 | <%_ for (const prop of layer.properties) { _%>
26 | - (void)set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMGLStyleValue *)styleValue;
27 | <%_ if (prop.transition) { _%>
28 | - (void)set<%- iosPropMethodName(layer, pascelCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMGLStyleValue *)styleValue;
29 | <%_ } _%>
30 | <%_ } _%>
31 | <% } %>
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLShapeSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLShapeSource.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RCTMGLSource.h"
11 |
12 | @import Mapbox;
13 |
14 | @interface RCTMGLShapeSource : RCTMGLSource
15 |
16 | @property (nonatomic, weak) RCTBridge *bridge;
17 |
18 | @property (nonatomic, copy) NSString *url;
19 | @property (nonatomic, copy) NSString *shape;
20 | @property (nonatomic, strong) NSDictionary *images;
21 | @property (nonatomic, strong) NSArray *nativeImages;
22 |
23 | @property (nonatomic, strong) NSNumber *cluster;
24 | @property (nonatomic, strong) NSNumber *clusterRadius;
25 | @property (nonatomic, strong) NSNumber *clusterMaxZoomLevel;
26 |
27 | @property (nonatomic, strong) NSNumber *maxZoomLevel;
28 | @property (nonatomic, strong) NSNumber *buffer;
29 | @property (nonatomic, strong) NSNumber *tolerence;
30 |
31 | @property (nonatomic, copy) RCTBubblingEventBlock onPress;
32 | @property (nonatomic, assign) BOOL hasPressListener;
33 |
34 | -(BOOL)addMissingImageToStyle:(NSString *)imageName;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/docs/UserLocation.md:
--------------------------------------------------------------------------------
1 | ##
2 | ###
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | animated | `bool` | `true` | `false` | FIX ME NO DESCRIPTION |
8 | | renderMode | `enum` | `'normal'` | `false` | FIX ME NO DESCRIPTION |
9 | | visible | `bool` | `true` | `false` | FIX ME NO DESCRIPTION |
10 | | onPress | `func` | `none` | `false` | FIX ME NO DESCRIPTION |
11 | | onUpdate | `func` | `none` | `false` | FIX ME NO DESCRIPTION |
12 | | children | `any` | `none` | `false` | FIX ME NO DESCRIPTION |
13 |
14 | ### methods
15 | #### setLocationManager({running})
16 |
17 |
18 |
19 | ##### arguments
20 | | Name | Type | Required | Description |
21 | | ---- | :--: | :------: | :----------: |
22 | | `{running}` | `n/a` | `Yes` | undefined |
23 |
24 |
25 | #### needsLocationManagerRunning()
26 |
27 |
28 |
29 | ##### arguments
30 | | Name | Type | Required | Description |
31 | | ---- | :--: | :------: | :----------: |
32 |
33 |
34 |
35 | #### userIconLayers()
36 |
37 |
38 |
39 | ##### arguments
40 | | Name | Type | Required | Description |
41 | | ---- | :--: | :------: | :----------: |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.sources;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.geojson.Feature;
6 | import com.mapbox.mapboxsdk.style.sources.VectorSource;
7 | import com.mapbox.rctmgl.events.FeatureClickEvent;
8 |
9 | /**
10 | * Created by nickitaliano on 9/8/17.
11 | */
12 |
13 | public class RCTMGLVectorSource extends RCTSource {
14 | private String mURL;
15 | private RCTMGLVectorSourceManager mManager;
16 |
17 | public RCTMGLVectorSource(Context context, RCTMGLVectorSourceManager manager) {
18 | super(context);
19 | mManager = manager;
20 | }
21 |
22 | public void setURL(String url) {
23 | mURL = url;
24 | }
25 |
26 | public void onPress(Feature feature) {
27 | mManager.handleEvent(FeatureClickEvent.makeVectorSourceEvent(this, feature));
28 | }
29 |
30 | @Override
31 | public VectorSource makeSource() {
32 | if (isDefaultSource(mID)) {
33 | return (VectorSource)mMap.getStyle().getSource(DEFAULT_ID);
34 | }
35 | return new VectorSource(mID, mURL);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/helpers/CameraChangeTracker.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.mapview.helpers;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by nickitaliano on 12/12/17.
7 | */
8 |
9 | public class CameraChangeTracker {
10 | public static final int USER_GESTURE = 1;
11 | public static final int DEVELOPER_ANIMATION = 2;
12 | public static final int SDK_ANIMATION = 3;
13 | public static final int EMPTY = -1;
14 |
15 | private int reason = EMPTY;
16 | private boolean isAnimating;
17 |
18 | public void setReason(int reason) {
19 | this.reason = reason;
20 | }
21 |
22 | public void setIsAnimating(boolean isAnimating) {
23 | this.isAnimating = isAnimating;
24 | }
25 |
26 | public boolean isUserInteraction() {
27 | return reason == USER_GESTURE || reason == DEVELOPER_ANIMATION;
28 | }
29 |
30 | public boolean isAnimated() {
31 | return reason == DEVELOPER_ANIMATION || reason == SDK_ANIMATION;
32 | }
33 |
34 | public boolean isAnimating() {
35 | return this.isAnimating;
36 | }
37 |
38 | public boolean isEmpty() {
39 | return reason == EMPTY;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/PointAnnotationClickEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.graphics.PointF;
4 | import android.support.annotation.NonNull;
5 | import android.view.View;
6 |
7 | import com.facebook.react.bridge.WritableMap;
8 | import com.facebook.react.bridge.WritableNativeMap;
9 | import com.mapbox.mapboxsdk.plugins.markerview.MarkerView;
10 | import com.mapbox.mapboxsdk.geometry.LatLng;
11 | import com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation;
12 | import com.mapbox.rctmgl.events.constants.EventKeys;
13 | import com.mapbox.rctmgl.events.constants.EventTypes;
14 | import com.mapbox.rctmgl.utils.ConvertUtils;
15 |
16 | /**
17 | * Created by nickitaliano on 10/11/17.
18 | */
19 |
20 | public class PointAnnotationClickEvent extends MapClickEvent {
21 | public PointAnnotationClickEvent(View view, @NonNull LatLng latLng, @NonNull PointF screenPoint, String eventType) {
22 | super(view, latLng, screenPoint, eventType);
23 | }
24 |
25 | @Override
26 | public String getKey() {
27 | return getType().equals(EventTypes.ANNOTATION_SELECTED) ? EventKeys.POINT_ANNOTATION_SELECTED : EventKeys.POINT_ANNOTATION_DESELECTED;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLUtils.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTConvert+Mapbox.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 | #import
13 |
14 | @import Mapbox;
15 |
16 | @interface RCTMGLUtils: NSObject
17 |
18 | + (CLLocationCoordinate2D)fromFeature:(NSString*)json;
19 | + (MGLShape*)shapeFromGeoJSON:(NSString*)json;
20 | + (MGLCoordinateBounds)fromFeatureCollection:(NSString*)json;
21 | + (NSArray *)fromCoordinateBounds:(MGLCoordinateBounds)bounds;
22 | + (NSTimeInterval)fromMS:(NSNumber*)number;
23 | + (NSNumber*)clamp:(NSNumber*)value min:(NSNumber*)min max:(NSNumber*)max;
24 | + (UIColor*)toColor:(id)value;
25 | + (void)fetchImage:(RCTBridge*)bridge url:(NSString*)url scale:(double)scale callback:(RCTImageLoaderCompletionBlock)callback;
26 | + (void)fetchImages:(RCTBridge *)bridge style:(MGLStyle *)style objects:(NSDictionary*)objects forceUpdate:(BOOL)forceUpdate callback:(void (^)())callback;
27 | + (CGVector)toCGVector:(NSArray*)arr;
28 | + (UIEdgeInsets)toUIEdgeInsets:(NSArray *)arr;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCamera.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCamera.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/22/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 | #import
9 | #import
10 |
11 | @class RCTMGLMapView;
12 |
13 | @interface RCTMGLCamera : UIView
14 |
15 | @property (nonatomic, strong) NSDictionary *stop;
16 | @property (nonatomic, strong) NSDictionary *defaultStop;
17 | @property (nonatomic, strong) RCTMGLMapView *map;
18 |
19 | @property (nonatomic, copy) NSNumber *animationDuration;
20 | @property (nonatomic, copy) NSString *animationMode;
21 |
22 | @property (nonatomic, assign) BOOL followUserLocation;
23 | @property (nonatomic, copy) NSString *followUserMode;
24 | @property (nonatomic, copy) NSNumber *followZoomLevel;
25 | @property (nonatomic, copy) NSNumber *followPitch;
26 | @property (nonatomic, copy) NSNumber *followHeading;
27 |
28 | @property (nonatomic, copy) NSNumber *maxZoomLevel;
29 | @property (nonatomic, copy) NSNumber *minZoomLevel;
30 |
31 | @property (nonatomic, copy) NSString *alignment;
32 | @property (nonatomic, copy, readonly) NSNumber *cameraAnimationMode;
33 |
34 | @property (nonatomic, copy) RCTBubblingEventBlock onUserTrackingModeChange;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLShapeSourceManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLShapeSourceManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/19/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLShapeSourceManager.h"
10 | #import "RCTMGLShapeSource.h"
11 |
12 | @implementation RCTMGLShapeSourceManager
13 |
14 | RCT_EXPORT_MODULE()
15 |
16 | RCT_EXPORT_VIEW_PROPERTY(id, NSString)
17 | RCT_EXPORT_VIEW_PROPERTY(url, NSString)
18 | RCT_EXPORT_VIEW_PROPERTY(shape, NSString)
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(cluster, NSNumber)
21 | RCT_EXPORT_VIEW_PROPERTY(clusterRadius, NSNumber)
22 | RCT_EXPORT_VIEW_PROPERTY(clusterMaxZoomLevel, NSNumber)
23 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber)
24 | RCT_EXPORT_VIEW_PROPERTY(buffer, NSNumber)
25 | RCT_EXPORT_VIEW_PROPERTY(tolerance, NSNumber)
26 | RCT_EXPORT_VIEW_PROPERTY(images, NSDictionary)
27 | RCT_EXPORT_VIEW_PROPERTY(nativeImages, NSArray)
28 | RCT_EXPORT_VIEW_PROPERTY(hasPressListener, BOOL)
29 | RCT_EXPORT_VIEW_PROPERTY(hitbox, NSDictionary)
30 | RCT_REMAP_VIEW_PROPERTY(onMapboxShapeSourcePress, onPress, RCTBubblingEventBlock)
31 |
32 | - (UIView*)view
33 | {
34 | RCTMGLShapeSource *source = [RCTMGLShapeSource new];
35 | source.bridge = self.bridge;
36 | return source;
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLAndroidTextureMapViewManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.mapview;
2 |
3 | import com.facebook.react.bridge.ReactApplicationContext;
4 | import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
5 | import com.facebook.react.uimanager.ThemedReactContext;
6 | import com.facebook.react.uimanager.annotations.ReactProp;
7 |
8 | /**
9 | * Created by hernanmateo on 12/11/18.
10 | */
11 |
12 | public class RCTMGLAndroidTextureMapViewManager extends RCTMGLMapViewManager {
13 | public static final String LOG_TAG = RCTMGLAndroidTextureMapViewManager.class.getSimpleName();
14 | public static final String REACT_CLASS = RCTMGLAndroidTextureMapView.class.getSimpleName();
15 |
16 | public RCTMGLAndroidTextureMapViewManager(ReactApplicationContext context) {
17 | super(context);
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return REACT_CLASS;
23 | }
24 |
25 | @Override
26 | protected RCTMGLAndroidTextureMapView createViewInstance(ThemedReactContext themedReactContext) {
27 | MapboxMapOptions options = new MapboxMapOptions();
28 | options.textureMode(true);
29 | return new RCTMGLAndroidTextureMapView(themedReactContext, this, options);
30 | }
31 | }
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapUserTrackingModeEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.react.bridge.Arguments;
6 | import com.facebook.react.bridge.WritableMap;
7 | import com.mapbox.rctmgl.events.constants.EventKeys;
8 | import com.mapbox.rctmgl.events.constants.EventTypes;
9 | import com.mapbox.rctmgl.location.UserTrackingMode;
10 |
11 | /**
12 | * Created by nickitaliano on 12/19/17.
13 | */
14 |
15 | public class MapUserTrackingModeEvent extends AbstractEvent {
16 | private int mUserTrackingMode;
17 |
18 | public MapUserTrackingModeEvent(View view, int userTrackingMode) {
19 | super(view, EventTypes.MAP_USER_TRACKING_MODE_CHANGE);
20 | mUserTrackingMode = userTrackingMode;
21 | }
22 |
23 | @Override
24 | public String getKey() {
25 | return EventKeys.MAP_USER_TRACKING_MODE_CHANGE;
26 | }
27 |
28 | @Override
29 | public WritableMap getPayload() {
30 | WritableMap payload = Arguments.createMap();
31 | payload.putBoolean("followUserLocation", mUserTrackingMode != UserTrackingMode.NONE);
32 | payload.putString("followUserMode", UserTrackingMode.toString(mUserTrackingMode));
33 |
34 | return payload;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/javascript/components/Images.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | import { viewPropTypes } from '../utils';
5 | import ShapeSource from './ShapeSource';
6 |
7 | /**
8 | * Images defines the images used in Symbol etc layers
9 | */
10 | class Images extends React.Component {
11 | static propTypes = {
12 | ...viewPropTypes,
13 |
14 | /**
15 | * Specifies the external images in key-value pairs required for the shape source.
16 | * If you have an asset under Image.xcassets on iOS and the drawables directory on android
17 | * you can specify an array of string names with assets as the key `{ assets: ['pin'] }`.
18 | */
19 | images: PropTypes.object,
20 | };
21 |
22 | _getID() {
23 | if (!this.id) {
24 | this.id = `${ShapeSource.imageSourcePrefix}-${Math.random().toString(36).substr(2,9)}`
25 | }
26 | return this.id;
27 | }
28 |
29 | render() {
30 | const id = this._getID();
31 |
32 | return (
33 |
41 | {this.props.children}
42 |
43 | );
44 | }
45 | }
46 |
47 | export default Images;
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCameraManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCameraManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/22/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLCameraManager.h"
10 | #import "RCTMGLCamera.h"
11 |
12 | @implementation RCTMGLCameraManager
13 |
14 | RCT_EXPORT_MODULE(RCTMGLCamera)
15 |
16 | #pragma - View Properties
17 |
18 | RCT_EXPORT_VIEW_PROPERTY(stop, NSDictionary)
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(animationDuration, NSNumber)
21 | RCT_EXPORT_VIEW_PROPERTY(animationMode, NSString)
22 |
23 | RCT_EXPORT_VIEW_PROPERTY(followUserLocation, BOOL)
24 | RCT_EXPORT_VIEW_PROPERTY(followUserMode, NSString)
25 | RCT_EXPORT_VIEW_PROPERTY(followZoomLevel, NSNumber)
26 | RCT_EXPORT_VIEW_PROPERTY(followPitch, NSNumber)
27 | RCT_EXPORT_VIEW_PROPERTY(followHeading, NSNumber)
28 |
29 | RCT_EXPORT_VIEW_PROPERTY(alignment, NSString)
30 |
31 | RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber)
32 | RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, NSNumber)
33 |
34 | RCT_EXPORT_VIEW_PROPERTY(onUserTrackingModeChange, RCTBubblingEventBlock)
35 |
36 | RCT_EXPORT_VIEW_PROPERTY(defaultStop, NSDictionary)
37 |
38 | #pragma Methods
39 |
40 | - (BOOL)requiresMainQueueSetup
41 | {
42 | return YES;
43 | }
44 |
45 | - (UIView *)view
46 | {
47 | return [[RCTMGLCamera alloc] init];
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/javascript/modules/offline/OfflineCreatePackOptions.js:
--------------------------------------------------------------------------------
1 | import {makeLatLngBounds} from '../../utils/geoUtils';
2 | import {toJSONString} from '../../utils';
3 |
4 | class OfflineCreatePackOptions {
5 | constructor(options = {}) {
6 | this._assert(options);
7 |
8 | this.name = options.name;
9 | this.styleURL = options.styleURL;
10 | this.bounds = this._makeLatLngBounds(options.bounds);
11 | this.minZoom = options.minZoom;
12 | this.maxZoom = options.maxZoom;
13 | this.metadata = this._makeMetadata(options.metadata);
14 | }
15 |
16 | _assert(options) {
17 | if (!options.styleURL) {
18 | throw new Error(
19 | 'Style URL must be provided for creating an offline pack',
20 | );
21 | }
22 |
23 | if (!options.name) {
24 | throw new Error('Name must be provided for creating an offline pack');
25 | }
26 |
27 | if (!options.bounds) {
28 | throw new Error('Bounds must be provided for creating an offline pack');
29 | }
30 | }
31 |
32 | _makeLatLngBounds(bounds) {
33 | const ne = bounds[0];
34 | const sw = bounds[1];
35 | return toJSONString(makeLatLngBounds(ne, sw));
36 | }
37 |
38 | _makeMetadata(metadata) {
39 | return JSON.stringify({
40 | ...metadata,
41 | name: this.name,
42 | });
43 | }
44 | }
45 |
46 | export default OfflineCreatePackOptions;
47 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLRasterSource.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLRasterSource.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLRasterSource.h"
10 |
11 | @implementation RCTMGLRasterSource
12 |
13 | - (MGLSource*)makeSource
14 | {
15 | return [[MGLRasterTileSource alloc] initWithIdentifier:self.id
16 | tileURLTemplates:@[_url]
17 | options:[self _getOptions]];
18 | }
19 |
20 | - (NSDictionary*)_getOptions
21 | {
22 | NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
23 |
24 | if (_maxZoomLevel != nil) {
25 | options[MGLTileSourceOptionMaximumZoomLevel] = _maxZoomLevel;
26 | }
27 |
28 | if (_minZoomLevel != nil) {
29 | options[MGLTileSourceOptionMinimumZoomLevel] = _minZoomLevel;
30 | }
31 |
32 | if (_tileSize != nil) {
33 | options[MGLTileSourceOptionTileSize] = _tileSize;
34 | }
35 |
36 | if (_tms) {
37 | options[MGLTileSourceOptionTileCoordinateSystem] = [NSNumber numberWithUnsignedInteger:MGLTileCoordinateSystemTMS];
38 | }
39 |
40 | if (_attribution != nil) {
41 | options[MGLTileSourceOptionAttributionHTMLString] = _attribution;
42 | }
43 |
44 | return options;
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/scripts/download-mapbox-gl-native-ios.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cd ios/
4 |
5 | VERSION=$1
6 | if type /usr/libexec/PlistBuddy &> /dev/null; then
7 | CURRENT_VERSION=$(/usr/libexec/PlistBuddy -c "Print :MGLSemanticVersionString" Mapbox.framework/Info.plist)
8 | else
9 | CURRENT_VERSION=$(cat .framework_version)
10 | fi
11 |
12 | if [ "$VERSION" == "$CURRENT_VERSION" ]; then
13 | echo "The newest version is already installed. Exiting."
14 | exit 0
15 | fi
16 |
17 | echo "Downloading Map.ir iOS $VERSION, this may take a minute."
18 |
19 | if ! which curl > /dev/null; then echo "curl command not found. Please install curl"; exit 1; fi;
20 | if ! which unzip > /dev/null; then echo "unzip command not found. Please install unzip"; exit 1; fi;
21 |
22 | if [ -d ./Mapbox.framework ]; then
23 | echo "Old Mapbox.framework found. Removing it and installing a $VERSION"
24 | rm -rf ./Mapbox.framework
25 | fi
26 |
27 | #curl -sS https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/mapbox-ios-sdk-$VERSION-dynamic.zip > temp.zip
28 | wget -O temp.zip https://map.ir/mobile/ios/mapir-ios-v$VERSION-dynamic.zip
29 |
30 | unzip -o temp.zip -d temp
31 | mv temp/dynamic/Mapbox.framework ./Mapbox.framework
32 | rm -r temp
33 | rm temp.zip
34 |
35 | if ! [ -d ./Mapbox.framework ]; then
36 | echo "Mapbox.framework not found. Please reinstall react-native-mapbox-gl"; exit 1;
37 | fi;
38 |
39 | echo "$VERSION" > .framework_version
40 |
--------------------------------------------------------------------------------
/javascript/components/NativeBridgeComponent.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {runNativeCommand, isAndroid} from '../utils';
4 |
5 | class NativeBridgeComponent extends React.Component {
6 | constructor(props) {
7 | super(props);
8 |
9 | this._onAndroidCallback = this._onAndroidCallback.bind(this);
10 | this._callbackMap = new Map();
11 | }
12 |
13 | _addAddAndroidCallback(id, callback) {
14 | this._callbackMap.set(id, callback);
15 | }
16 |
17 | _removeAndroidCallback(id) {
18 | this._callbackMap.remove(id);
19 | }
20 |
21 | _onAndroidCallback(e) {
22 | const callbackID = e.nativeEvent.type;
23 | const callback = this._callbackMap.get(callbackID);
24 |
25 | if (!callback) {
26 | return;
27 | }
28 |
29 | this._callbackMap.delete(callbackID);
30 | callback.call(null, e.nativeEvent.payload);
31 | }
32 |
33 | _runNativeCommand(nativeModuleName, nativeRef, methodName, args = []) {
34 | if (isAndroid()) {
35 | return new Promise(resolve => {
36 | const callbackID = `${Date.now()}`;
37 | this._addAddAndroidCallback(callbackID, resolve);
38 | args.unshift(callbackID);
39 | runNativeCommand(nativeModuleName, methodName, this._nativeRef, args);
40 | });
41 | }
42 |
43 | return runNativeCommand(nativeModuleName, methodName, nativeRef, args);
44 | }
45 | }
46 |
47 | export default NativeBridgeComponent;
48 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLHeatmapLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLHeatmapLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Dheeraj Yalamanchili on 6/8/2019
6 |
7 | #import "RCTMGLHeatmapLayer.h"
8 | #import "RCTMGLStyle.h"
9 |
10 | @implementation RCTMGLHeatmapLayer
11 |
12 | - (void)updateFilter:(NSPredicate *)predicate
13 | {
14 | ((MGLHeatmapStyleLayer *) self.styleLayer).predicate = predicate;
15 | }
16 |
17 | - (void)setSourceLayerID:(NSString *)sourceLayerID
18 | {
19 | _sourceLayerID = sourceLayerID;
20 |
21 | if (self.styleLayer != nil) {
22 | ((MGLHeatmapStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
23 | }
24 | }
25 |
26 | - (void)addedToMap
27 | {
28 | NSPredicate *filter = [self buildFilters];
29 | if (filter != nil) {
30 | [self updateFilter:filter];
31 | }
32 | }
33 |
34 | - (MGLHeatmapStyleLayer*)makeLayer:(MGLStyle*)style
35 | {
36 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
37 | MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:self.id source:source];
38 | layer.sourceLayerIdentifier = _sourceLayerID;
39 | return layer;
40 | }
41 |
42 | - (void)addStyles
43 | {
44 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
45 | style.bridge = self.bridge;
46 | [style heatmapLayer:(MGLHeatmapStyleLayer *)self.styleLayer withReactStyle:self.reactStyle];
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/scripts/templates/index.d.ts.ejs:
--------------------------------------------------------------------------------
1 | <%
2 | const layers = locals.layers;
3 | -%>
4 | /* eslint-disable */
5 | // DO NOT MODIFY
6 | // THIS FILE IS AUTOGENERATED
7 |
8 | export interface ConstantProps {
9 | styletype: string
10 | payload: {
11 | value: any,
12 | },
13 | };
14 |
15 | export interface StyleFunctionProps {
16 | styletype: string
17 | payload: {
18 | fn: string,
19 | attributeName: string,
20 | stops: any[],
21 | mode: any,
22 | }
23 | }
24 |
25 | export interface TransitionProps {
26 | duration: number
27 | delay: number,
28 | }
29 |
30 | export type TranslationProps = { x: number, y: number } | number[]
31 |
32 | <%_ for (let layer of layers) { _%>
33 | export interface <%- camelCase(layer.name) _%>LayerStyleProps {
34 | <%_ for (let prop of layer.properties) { %>
35 | /**
36 | * <%- prop.doc.description %>
37 | <%_ if (prop.doc.requires.length) { _%>
38 | *
39 | * @requires <%- prop.doc.requires.join(', ') %>
40 | <%_ } _%>
41 | <%_ if (prop.doc.disabledBy.length) { _%>
42 | *
43 | * @disabledBy <%- prop.doc.disabledBy.join(', ') %>
44 | <%_ } _%>
45 | */
46 | <%= prop.name %>: <%- dtsInterfaceType(prop) %>
47 | <%_ if (prop.transition) { %>
48 | /**
49 | * The transition affecting any changes to this layer’s <%= prop.name %> property.
50 | */
51 | <%= prop.name %>Transition: TransitionProps,
52 | <%_ } _%>
53 | <%_ } _%>
54 | };
55 |
56 | <%_ } _%>
57 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/GeoViewport.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.utils;
2 |
3 | import android.graphics.PointF;
4 |
5 | import com.mapbox.mapboxsdk.geometry.LatLng;
6 | import com.mapbox.mapboxsdk.geometry.LatLngBounds;
7 | import com.mapbox.mapboxsdk.geometry.VisibleRegion;
8 |
9 | /**
10 | * Created by nickitaliano on 1/5/18.
11 | * Ported from https://github.com/mapbox/geo-viewport/blob/master/index.js
12 | * This port only assumes we will have 512 vector tile sizes
13 | */
14 |
15 | public class GeoViewport {
16 | private static SphericalMercator sphericalMercator = new SphericalMercator();
17 |
18 | public static VisibleRegion getRegion(LatLng centerCoord, int zoomLevel, int viewportWidth, int viewportHeight) {
19 | PointF px = sphericalMercator.getPX(centerCoord, zoomLevel);
20 |
21 | LatLng tl = sphericalMercator.getLatLng(new PointF(
22 | px.x - (viewportWidth / 2),
23 | px.y - (viewportHeight / 2)
24 | ), zoomLevel);
25 |
26 | LatLng br = sphericalMercator.getLatLng(new PointF(
27 | px.x + (viewportWidth / 2),
28 | px.y + (viewportHeight / 2)
29 | ), zoomLevel);
30 |
31 | LatLng farLeft = tl;
32 | LatLng farRight = new LatLng(tl.getLatitude(), br.getLongitude());
33 | LatLng nearLeft = new LatLng(br.getLatitude(), tl.getLongitude());
34 | LatLng nearRight = br;
35 |
36 | return new VisibleRegion(farLeft, farRight, nearLeft, nearRight, null);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/docs/PointAnnotation.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | id | `string` | `none` | `true` | A string that uniquely identifies the annotation |
8 | | title | `string` | `none` | `false` | The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS. |
9 | | snippet | `string` | `none` | `false` | The string containing the annotation’s snippet(subtitle). Not displayed in the default callout. |
10 | | selected | `bool` | `none` | `false` | Manually selects/deselects annotation
@type {[type]} |
11 | | coordinate | `arrayOf` | `none` | `true` | The center point (specified as a map coordinate) of the annotation. |
12 | | anchor | `shape` | `{ x: 0.5, y: 0.5 }` | `false` | Specifies the anchor being set on a particular point of the annotation.
The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
Note this is only for custom annotations not the default pin view.
Defaults to the center of the view. |
13 | | onSelected | `func` | `none` | `false` | This callback is fired once this annotation is selected. Returns a Feature as the first param. |
14 | | onDeselected | `func` | `none` | `false` | This callback is fired once this annotation is deselected. |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageQueueOperation.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageQueueOperation.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 2/28/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLImageQueueOperation.h"
10 |
11 | @implementation RCTMGLImageQueueOperation
12 | {
13 | RCTImageLoaderCancellationBlock cancellationBlock;
14 | }
15 |
16 | - (void)start
17 | {
18 | if (self.isCancelled) {
19 | return;
20 | }
21 |
22 | __weak RCTMGLImageQueueOperation *weakSelf = self;
23 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
24 | cancellationBlock = [weakSelf.bridge.imageLoader loadImageWithURLRequest:weakSelf.urlRequest
25 | size:CGSizeZero
26 | scale:self.scale
27 | clipped:YES
28 | resizeMode:RCTResizeModeStretch
29 | progressBlock:nil
30 | partialLoadBlock:nil
31 | completionBlock:weakSelf.completionHandler];
32 | });
33 | }
34 |
35 | - (void)cancel
36 | {
37 | if (cancellationBlock != nil) {
38 | cancellationBlock();
39 | }
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Node template
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 | *.pid.lock
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # nyc test coverage
23 | .nyc_output
24 |
25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26 | .grunt
27 |
28 | # Bower dependency directory (https://bower.io/)
29 | bower_components
30 |
31 | # node-waf configuration
32 | .lock-wscript
33 |
34 | # Compiled binary addons (https://nodejs.org/api/addons.html)
35 | build/Release
36 |
37 | # Dependency directories
38 | node_modules/
39 | jspm_packages/
40 |
41 | # TypeScript v1 declaration files
42 | typings/
43 |
44 | # Optional npm cache directory
45 | .npm
46 |
47 | # Optional eslint cache
48 | .eslintcache
49 |
50 | # Optional REPL history
51 | .node_repl_history
52 |
53 | # Output of 'npm pack'
54 | *.tgz
55 |
56 | # Yarn Integrity file
57 | .yarn-integrity
58 |
59 | # dotenv environment variables file
60 | .env
61 |
62 | # parcel-bundler cache (https://parceljs.org/)
63 | .cache
64 |
65 | # next.js build output
66 | .next
67 |
68 | # nuxt.js build output
69 | .nuxt
70 |
71 | # vuepress build output
72 | .vuepress/dist
73 |
74 | # Serverless directories
75 | .serverless
76 |
77 | android/rctmgl/build
78 | ios/ios
79 | ios/Mapbox.framework
80 | .idea/
81 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/constants/EventKeys.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events.constants;
2 |
3 | /**
4 | * Created by nickitaliano on 8/27/17.
5 | */
6 |
7 | public class EventKeys {
8 | public static final String NAMESPACE = "rct.mapbox";
9 |
10 | // map events
11 | public static final String MAP_CLICK = ns("map.press");
12 | public static final String MAP_LONG_CLICK = ns("map.longpress");
13 | public static final String MAP_ONCHANGE = ns("map.change");
14 | public static final String MAP_ON_LOCATION_CHANGE = ns("map.location.change");
15 | public static final String MAP_ANDROID_CALLBACK = ns("map.androidcallback");
16 | public static final String MAP_USER_TRACKING_MODE_CHANGE = ns("map.usertrackingmodechange");
17 |
18 | // point annotation events
19 | public static final String POINT_ANNOTATION_SELECTED = ns("pointannotation.selected");
20 | public static final String POINT_ANNOTATION_DESELECTED = ns("pointannotation.deselected");
21 |
22 | // source events
23 | public static final String SHAPE_SOURCE_LAYER_CLICK = ns("shapesource.layer.pressed");
24 | public static final String VECTOR_SOURCE_LAYER_CLICK = ns("vectorsource.layer.pressed");
25 | public static final String RASTER_SOURCE_LAYER_CLICK = ns("rastersource.layer.pressed");
26 |
27 | // location events
28 | public static final String USER_LOCATION_UPDATE = ns("user.location.update");
29 |
30 | private static String ns(String name) {
31 | return String.format("%s.%s", NAMESPACE, name);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageQueue.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageQueue.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/23/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLImageQueue.h"
10 | #import "RCTMGLImageQueueOperation.h"
11 | #import "RCTMGLUtils.h"
12 |
13 | @implementation RCTMGLImageQueue
14 | {
15 | NSOperationQueue *imageQueue;
16 | }
17 |
18 | - (id)init
19 | {
20 | if (self = [super init]) {
21 | imageQueue = [[NSOperationQueue alloc] init];
22 | imageQueue.name = @"com.mapbox.rctmgl.DownloadImageQueue";
23 | }
24 | return self;
25 | }
26 |
27 | - (void)dealloc
28 | {
29 | [self cancelAllOperations];
30 | }
31 |
32 | + (instancetype)sharedInstance
33 | {
34 | static RCTMGLImageQueue *sharedInstance = nil;
35 | static dispatch_once_t onceToken;
36 | dispatch_once(&onceToken, ^{
37 | sharedInstance = [[RCTMGLImageQueue alloc] init];
38 | });
39 | return sharedInstance;
40 | }
41 |
42 | - (void)cancelAllOperations
43 | {
44 | [imageQueue cancelAllOperations];
45 | }
46 |
47 | - (void)addImage:(NSString *)imageURL scale:(double)scale bridge:(RCTBridge *)bridge completionHandler:(RCTImageLoaderCompletionBlock)handler
48 | {
49 | RCTMGLImageQueueOperation *operation = [[RCTMGLImageQueueOperation alloc] init];
50 | operation.bridge = bridge;
51 | operation.urlRequest = [RCTConvert NSURLRequest:imageURL];
52 | operation.completionHandler = handler;
53 | operation.scale = scale;
54 | [imageQueue addOperation:operation];
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLCalloutAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.annotation;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.annotation.Nullable;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.mapbox.mapboxsdk.annotations.Marker;
9 | import com.mapbox.mapboxsdk.maps.MapboxMap;
10 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
11 |
12 | /**
13 | * Created by nickitaliano on 10/11/17.
14 | */
15 |
16 | public class RCTMGLCalloutAdapter implements MapboxMap.InfoWindowAdapter {
17 | private RCTMGLMapView mMapView;
18 |
19 | public RCTMGLCalloutAdapter(RCTMGLMapView mapView) {
20 | mMapView = mapView;
21 | }
22 |
23 | @Nullable
24 | @Override
25 | public View getInfoWindow(@NonNull Marker marker) {
26 | if (mMapView == null) {
27 | return null;
28 | }
29 |
30 | RCTMGLPointAnnotation annotation = mMapView.getPointAnnotationByMarkerID(marker.getId());
31 | if (annotation == null) {
32 | return null;
33 | }
34 |
35 | RCTMGLCallout calloutView = annotation.getCalloutView();
36 | if (calloutView == null) {
37 | return null;
38 | }
39 |
40 | if (calloutView.getLayoutParams() == null) {
41 | calloutView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
42 | ViewGroup.LayoutParams.WRAP_CONTENT));
43 | }
44 |
45 | return calloutView;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraUpdateQueue.m:
--------------------------------------------------------------------------------
1 | //
2 | // CameraUpdateQueue.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/6/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "CameraUpdateQueue.h"
10 |
11 | @implementation CameraUpdateQueue
12 | {
13 | NSMutableArray *queue;
14 | }
15 |
16 | - (instancetype)init
17 | {
18 | if (self = [super init]) {
19 | queue = [[NSMutableArray alloc] init];
20 | }
21 |
22 | return self;
23 | }
24 |
25 | - (void)enqueue:(CameraStop*)cameraUpdateItem
26 | {
27 | [queue addObject:cameraUpdateItem];
28 | }
29 |
30 | - (CameraStop*)dequeue
31 | {
32 | if ([self isEmpty]) {
33 | return nil;
34 | }
35 | CameraStop *stop = queue.firstObject;
36 | [queue removeObjectAtIndex:0];
37 | return stop;
38 | }
39 |
40 | - (void)flush
41 | {
42 | [queue removeAllObjects];
43 | }
44 |
45 | - (BOOL)isEmpty
46 | {
47 | return queue.count == 0;
48 | }
49 |
50 | - (void)execute:(RCTMGLMapView*)mapView
51 | {
52 | if (mapView == nil) {
53 | return;
54 | }
55 |
56 | if ([self isEmpty]) {
57 | return;
58 | }
59 |
60 | CameraStop *stop = [self dequeue];
61 | if (stop == nil) {
62 | return;
63 | }
64 |
65 | CameraUpdateItem *item = [[CameraUpdateItem alloc] init];
66 | item.cameraStop = stop;
67 |
68 | __weak CameraUpdateQueue *weakSelf = self;
69 | __weak RCTMGLMapView *weakMap = mapView;
70 |
71 | [item execute:mapView withCompletionHandler:^{ [weakSelf execute:weakMap]; }];
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // BaseLayer.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 |
13 | @class RCTMGLMapView;
14 |
15 | @import Mapbox;
16 |
17 | @interface RCTMGLLayer : UIView
18 |
19 | @property (nonatomic, weak) RCTBridge *bridge;
20 |
21 | @property (nonatomic, strong) MGLStyleLayer *styleLayer;
22 | @property (nonatomic, strong) MGLStyle *style;
23 | @property (nonatomic, weak) RCTMGLMapView* map;
24 | @property (nonatomic, strong) NSDictionary *reactStyle;
25 | @property (nonatomic, strong) NSArray *> *filter;
26 |
27 | @property (nonatomic, copy) NSString *id;
28 | @property (nonatomic, copy) NSString *sourceID;
29 |
30 | @property (nonatomic, copy) NSString *aboveLayerID;
31 | @property (nonatomic, copy) NSString *belowLayerID;
32 | @property (nonatomic, copy) NSNumber *layerIndex;
33 |
34 | @property (nonatomic, copy) NSNumber *maxZoomLevel;
35 | @property (nonatomic, copy) NSNumber *minZoomLevel;
36 |
37 | - (void)addToMap:(RCTMGLMapView*)map style:(MGLStyle*)style;
38 | - (void)addedToMap;
39 | - (void)removeFromMap:(MGLStyle*)style;
40 | - (T)makeLayer:(MGLStyle*)style;
41 | - (void)addStyles;
42 | - (void)insertAbove:(NSString*)layer;
43 | - (void)insertBelow:(NSString*)layer;
44 | - (void)insertAtIndex:(NSUInteger)index;
45 | - (void)insertLayer;
46 | - (void)setZoomBounds;
47 | - (void)addImage:(NSString*)url;
48 | - (NSPredicate*)buildFilters;
49 | - (void)updateFilter:(NSPredicate *)predicate;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/AbstractEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.react.bridge.Arguments;
6 | import com.facebook.react.bridge.WritableMap;
7 |
8 | /**
9 | * Created by nickitaliano on 8/27/17.
10 | */
11 |
12 | abstract public class AbstractEvent implements IEvent {
13 | private int mTagID;
14 | private String mEventType;
15 | private long mTimestamp;
16 |
17 | public AbstractEvent(String eventType) {
18 | this(null, eventType);
19 | }
20 |
21 | public AbstractEvent(View view, String eventType) {
22 | mEventType = eventType;
23 |
24 | if (view != null) {
25 | mTagID = view.getId();
26 | }
27 |
28 | mTimestamp = System.currentTimeMillis();
29 | }
30 |
31 | public int getID() {
32 | return mTagID;
33 | }
34 |
35 | public String getType() {
36 | return mEventType;
37 | }
38 |
39 | public boolean equals(IEvent event) {
40 | return getKey().equals(event.getKey()) && mEventType.equals(event.getType());
41 | }
42 |
43 | public WritableMap getPayload() {
44 | return Arguments.createMap();
45 | }
46 |
47 | public long getTimestamp() {
48 | return mTimestamp;
49 | }
50 |
51 | public WritableMap toJSON() {
52 | WritableMap map = Arguments.createMap();
53 | map.putString("type", getType());
54 |
55 | WritableMap payloadClone = Arguments.createMap();
56 | payloadClone.merge(getPayload());
57 | map.putMap("payload", payloadClone);
58 | return map;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/docs/snapshotManager.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### The snapshotManager generates static raster images of the map.
Each snapshot image depicts a portion of a map defined by an SnapshotOptions object you provide.
The snapshotter generates the snapshot asynchronous.
3 |
4 |
5 | ### methods
6 | #### takeSnap(options)
7 |
8 | Takes a snapshot of the base map using the provided Snapshot options. NOTE pitch, heading, zoomLevel only works when centerCoordinate is set!
9 |
10 | ##### arguments
11 | | Name | Type | Required | Description |
12 | | ---- | :--: | :------: | :----------: |
13 | | `options` | `SnapshotOptions` | `Yes` | Snapshot options for create a static image of the base map |
14 |
15 |
16 |
17 | ```javascript
18 | // creates a temp file png of base map
19 | const uri = await MapboxGL.snapshotManager.takeSnap({
20 | centerCoordinate: [-74.126410, 40.797968],
21 | width: width,
22 | height: height,
23 | zoomLevel: 12,
24 | pitch: 30,
25 | heading: 20,
26 | styleURL: MapboxGL.StyleURL.Dark,
27 | writeToDisk: true, // creates a temp file
28 | });
29 |
30 | // creates base64 png of base map
31 | const uri = await MapboxGL.snapshotManager.takeSnap({
32 | centerCoordinate: [-74.126410, 40.797968],
33 | width: width,
34 | height: height,
35 | zoomLevel: 12,
36 | pitch: 30,
37 | heading: 20,
38 | styleURL: MapboxGL.StyleURL.Dark,
39 | });
40 |
41 | // creates snapshot with bounds
42 | const uri = await MapboxGL.snapshotManager.takeSnap({
43 | bounds: [[-74.126410, 40.797968], [-74.143727, 40.772177]],
44 | width: width,
45 | height: height,
46 | styleURL: MapboxGL.StyleURL.Dark,
47 | });
48 | ```
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/8/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLFillLayer.h"
10 | #import "RCTMGLStyle.h"
11 | #import
12 |
13 | @implementation RCTMGLFillLayer
14 |
15 | - (void)updateFilter:(NSPredicate *)predicate
16 | {
17 | @try {
18 | ((MGLFillStyleLayer *) self.styleLayer).predicate = predicate;
19 | }
20 | @catch (NSException* exception) {
21 | RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
22 | }
23 | }
24 |
25 | - (void)setSourceLayerID:(NSString *)sourceLayerID
26 | {
27 | _sourceLayerID = sourceLayerID;
28 |
29 | if (self.styleLayer != nil) {
30 | ((MGLFillStyleLayer *) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
31 | }
32 | }
33 |
34 | - (void)addedToMap
35 | {
36 | NSPredicate *filter = [self buildFilters];
37 | if (filter != nil) {
38 | [self updateFilter:filter];
39 | }
40 | }
41 |
42 | - (MGLStyleLayer*)makeLayer:(MGLStyle*)style
43 | {
44 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
45 | MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:self.id source:source];
46 | layer.sourceLayerIdentifier = _sourceLayerID;
47 | return layer;
48 | }
49 |
50 | - (void)addStyles
51 | {
52 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
53 | style.bridge = self.bridge;
54 | [style fillLayer:(MGLFillStyleLayer*)self.styleLayer withReactStyle:self.reactStyle];
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLineLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLineLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLLineLayer.h"
10 | #import "RCTMGLStyle.h"
11 | #import
12 |
13 | @implementation RCTMGLLineLayer
14 |
15 | - (void)updateFilter:(NSPredicate *)predicate
16 | {
17 | @try {
18 | ((MGLLineStyleLayer *) self.styleLayer).predicate = predicate;
19 | }
20 | @catch (NSException* exception) {
21 | RCTLogError(@"Invalid predicate: %@ on layer %@ - Name: %@ reason: %@", predicate, self, exception.name, exception.reason);
22 | }
23 | }
24 |
25 | - (void)setSourceLayerID:(NSString *)sourceLayerID
26 | {
27 | _sourceLayerID = sourceLayerID;
28 |
29 | if (self.styleLayer != nil) {
30 | ((MGLLineStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
31 | }
32 | }
33 |
34 | - (void)addedToMap
35 | {
36 | NSPredicate *filter = [self buildFilters];
37 | if (filter != nil) {
38 | [self updateFilter:filter];
39 | }
40 | }
41 |
42 | - (MGLLineStyleLayer*)makeLayer:(MGLStyle*)style
43 | {
44 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
45 | MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:self.id source:source];
46 | layer.sourceLayerIdentifier = _sourceLayerID;
47 | return layer;
48 | }
49 |
50 | - (void)addStyles
51 | {
52 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
53 | style.bridge = self.bridge;
54 | [style lineLayer:(MGLLineStyleLayer *)self.styleLayer withReactStyle:self.reactStyle];
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ios/RCTMGL/ViewManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/31/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "ViewManager.h"
10 |
11 | @implementation ViewManager
12 | {
13 | NSMutableDictionary *eventTimestampCache;
14 | }
15 |
16 | + (BOOL)requiresMainQueueSetup
17 | {
18 | return YES;
19 | }
20 |
21 | + (NSString *)moduleName
22 | {
23 | // Hack, to prevent JS from throwing a useless warning
24 | return @"RCTViewManager";
25 | }
26 |
27 | static NSTimeInterval EVENT_THROTTLE_S = 0.01;
28 |
29 | - (instancetype)init
30 | {
31 | if (self = [super init]) {
32 | eventTimestampCache = [[NSMutableDictionary alloc] init];
33 | }
34 |
35 | return self;
36 | }
37 |
38 | - (void)fireEvent:(RCTMGLEvent*)event withCallback:(RCTBubblingEventBlock)callback
39 | {
40 | if (![self _shouldDropEvent:event]) {
41 | NSString *cacheKey = [self _getCacheKey:event];
42 | NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
43 | [eventTimestampCache setObject:[NSNumber numberWithDouble:now] forKey:cacheKey];
44 |
45 | if (callback != nil) {
46 | callback([event toJSON]);
47 | }
48 | }
49 | }
50 |
51 | - (BOOL)_shouldDropEvent:(RCTMGLEvent *)event
52 | {
53 | NSString *cacheKey = [self _getCacheKey:event];
54 | NSNumber *lastTimestamp = [eventTimestampCache objectForKey:cacheKey];
55 | return lastTimestamp != nil && (event.timestamp - [lastTimestamp doubleValue]) <= EVENT_THROTTLE_S;
56 | }
57 |
58 | - (NSString*)_getCacheKey:(RCTMGLEvent*)event
59 | {
60 | return event.type;
61 | }
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.FillLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by nickitaliano on 9/8/17.
13 | */
14 |
15 | public class RCTMGLFillLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLFillLayer(Context context) {
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public FillLayer makeLayer() {
34 | FillLayer layer = new FillLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setFillLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(mSourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.LineLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by nickitaliano on 9/18/17.
13 | */
14 |
15 | public class RCTMGLLineLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLLineLayer(Context context) {
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public LineLayer makeLayer() {
34 | LineLayer layer = new LineLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setLineLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(mSourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCircleLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCircleLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/18/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLCircleLayer.h"
10 | #import "RCTMGLStyle.h"
11 |
12 | #import
13 |
14 | @implementation RCTMGLCircleLayer
15 |
16 | - (void)updateFilter:(NSPredicate *)predicate
17 | {
18 | @try {
19 | ((MGLCircleStyleLayer *) self.styleLayer).predicate = predicate;
20 | }
21 | @catch (NSException* exception) {
22 | RCTLogError(@"Invalid predicate: %@ on layer %@ - %@ reason: %@", predicate, self, exception.name, exception.reason);
23 | }
24 | }
25 |
26 | - (void)setSourceLayerID:(NSString *)sourceLayerID
27 | {
28 | _sourceLayerID = sourceLayerID;
29 |
30 | if (self.styleLayer != nil) {
31 | ((MGLCircleStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
32 | }
33 | }
34 |
35 | - (void)addedToMap
36 | {
37 | NSPredicate *filter = [self buildFilters];
38 | if (filter != nil) {
39 | [self updateFilter:filter];
40 | }
41 | }
42 |
43 | - (MGLCircleStyleLayer*)makeLayer:(MGLStyle*)style
44 | {
45 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
46 | MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:self.id source:source];
47 | layer.sourceLayerIdentifier = _sourceLayerID;
48 | return layer;
49 | }
50 |
51 | - (void)addStyles
52 | {
53 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
54 | style.bridge = self.bridge;
55 | [style circleLayer:(MGLCircleStyleLayer*)self.styleLayer withReactStyle:self.reactStyle];
56 | }
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.CircleLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by nickitaliano on 9/18/17.
13 | */
14 |
15 | public class RCTMGLCircleLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLCircleLayer(Context context) {
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public CircleLayer makeLayer() {
34 | CircleLayer layer = new CircleLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setCircleLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(sourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by nickitaliano on 9/19/17.
13 | */
14 |
15 | public class RCTMGLSymbolLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLSymbolLayer(Context context) {
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public SymbolLayer makeLayer() {
34 | SymbolLayer layer = new SymbolLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setSymbolLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(sourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by dhee9000 on 6/8/2019
13 | */
14 |
15 | public class RCTMGLHeatmapLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLHeatmapLayer(Context context){
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public HeatmapLayer makeLayer() {
34 | HeatmapLayer layer = new HeatmapLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setHeatmapLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(sourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/docs/RasterSource.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### RasterSource is a map content source that supplies raster image tiles to be shown on the map.
The location of and metadata about the tiles are defined either by an option dictionary
or by an external file that conforms to the TileJSON specification.
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
8 | | url | `string` | `none` | `false` | A URL to a TileJSON configuration file describing the source’s contents and other metadata. |
9 | | minZoomLevel | `number` | `none` | `false` | An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
The value should be between 0 and 22, inclusive, and less than
maxZoomLevel, if specified. The default value for this option is 0. |
10 | | maxZoomLevel | `number` | `none` | `false` | An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
The value should be between 0 and 22, inclusive, and less than
minZoomLevel, if specified. The default value for this option is 22. |
11 | | tileSize | `number` | `none` | `false` | Size of the map tiles.
Mapbox urls default to 256, all others default to 512. |
12 | | tms | `bool` | `none` | `false` | Influences the y direction of the tile coordinates. (tms inverts y axis) |
13 | | attribution | `string` | `none` | `false` | An HTML or literal text string defining the buttons to be displayed in an action sheet when the
source is part of a map view’s style and the map view’s attribution button is pressed. |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.mapboxsdk.style.expressions.Expression;
6 | import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
7 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10 |
11 | /**
12 | * Created by nickitaliano on 9/15/17.
13 | */
14 |
15 | public class RCTMGLFillExtrusionLayer extends RCTLayer {
16 | private String mSourceLayerID;
17 |
18 | public RCTMGLFillExtrusionLayer(Context context) {
19 | super(context);
20 | }
21 |
22 | @Override
23 | protected void updateFilter(Expression expression) {
24 | mLayer.setFilter(expression);
25 | }
26 |
27 | @Override
28 | public void addToMap(RCTMGLMapView mapView) {
29 | super.addToMap(mapView);
30 | }
31 |
32 | @Override
33 | public FillExtrusionLayer makeLayer() {
34 | FillExtrusionLayer layer = new FillExtrusionLayer(mID, mSourceID);
35 |
36 | if (mSourceLayerID != null) {
37 | layer.setSourceLayer(mSourceLayerID);
38 | }
39 |
40 | return layer;
41 | }
42 |
43 | @Override
44 | public void addStyles() {
45 | RCTMGLStyleFactory.setFillExtrusionLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
46 | }
47 |
48 | public void setSourceLayerID(String sourceLayerID) {
49 | mSourceLayerID = sourceLayerID;
50 |
51 | if (mLayer != null) {
52 | mLayer.setSourceLayer(mSourceLayerID);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLFillExtrusionLayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLFillExtrusionLayer.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/15/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLFillExtrusionLayer.h"
10 | #import "RCTMGLStyle.h"
11 | #import
12 |
13 | @implementation RCTMGLFillExtrusionLayer
14 |
15 | - (void)updateFilter:(NSPredicate *)predicate
16 | {
17 | @try {
18 | ((MGLFillExtrusionStyleLayer *) self.styleLayer).predicate = predicate;
19 | }
20 | @catch (NSException* exception) {
21 | RCTLogError(@"Invalid predicate: %@ on layer %@ - Name: %@ reason: %@", predicate, self, exception.name, exception.reason);
22 | }
23 | }
24 |
25 | - (void)setSourceLayerID:(NSString *)sourceLayerID
26 | {
27 | _sourceLayerID = sourceLayerID;
28 |
29 | if (self.styleLayer != nil) {
30 | ((MGLFillExtrusionStyleLayer*) self.styleLayer).sourceLayerIdentifier = _sourceLayerID;
31 | }
32 | }
33 |
34 | - (void)addedToMap
35 | {
36 | NSPredicate *filter = [self buildFilters];
37 | if (filter != nil) {
38 | [self updateFilter:filter];
39 | }
40 | }
41 |
42 | - (MGLFillExtrusionStyleLayer*)makeLayer:(MGLStyle*)style
43 | {
44 | MGLSource *source = [style sourceWithIdentifier:self.sourceID];
45 | MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:self.id source:source];
46 | layer.sourceLayerIdentifier = _sourceLayerID;
47 | return layer;
48 | }
49 |
50 | - (void)addStyles
51 | {
52 | RCTMGLStyle *style = [[RCTMGLStyle alloc] initWithMGLStyle:self.style];
53 | style.bridge = self.bridge;
54 | [style fillExtrusionLayer:(MGLFillExtrusionStyleLayer*)self.styleLayer withReactStyle:self.reactStyle];
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/MapClickEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.graphics.PointF;
4 | import android.support.annotation.NonNull;
5 | import android.view.View;
6 |
7 | import com.facebook.react.bridge.WritableMap;
8 | import com.facebook.react.bridge.WritableNativeMap;
9 | import com.mapbox.mapboxsdk.geometry.LatLng;
10 |
11 | import com.mapbox.rctmgl.events.constants.EventKeys;
12 | import com.mapbox.rctmgl.events.constants.EventTypes;
13 | import com.mapbox.rctmgl.utils.GeoJSONUtils;
14 |
15 | /**
16 | * Created by nickitaliano on 8/23/17.
17 | */
18 |
19 | public class MapClickEvent extends AbstractEvent {
20 | private LatLng mTouchedLatLng;
21 | private PointF mScreenPoint;
22 |
23 | public MapClickEvent(View view, @NonNull LatLng latLng, @NonNull PointF screenPoint) {
24 | this(view, latLng, screenPoint, EventTypes.MAP_CLICK);
25 | }
26 |
27 | public MapClickEvent(View view, @NonNull LatLng latLng, @NonNull PointF screenPoint, String eventType) {
28 | super(view, eventType);
29 | mTouchedLatLng = latLng;
30 | mScreenPoint = screenPoint;
31 | }
32 |
33 | @Override
34 | public String getKey() {
35 | String eventType = getType();
36 |
37 | if (eventType.equals(EventTypes.MAP_LONG_CLICK)) {
38 | return EventKeys.MAP_LONG_CLICK;
39 | }
40 |
41 | return EventKeys.MAP_CLICK;
42 | }
43 |
44 | @Override
45 | public WritableMap getPayload() {
46 | WritableMap properties = new WritableNativeMap();
47 | properties.putDouble("screenPointX", mScreenPoint.x);
48 | properties.putDouble("screenPointY", mScreenPoint.y);
49 | return GeoJSONUtils.toPointFeature(mTouchedLatLng, properties);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLImageSource.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLImageSource.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 11/29/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLImageSource.h"
10 | @import Mapbox;
11 |
12 | @implementation RCTMGLImageSource
13 |
14 | - (void)setUrl:(NSString *)url
15 | {
16 | _url = url;
17 |
18 | if (self.source != nil) {
19 | MGLImageSource *source = (MGLImageSource *)self.source;
20 | source.URL = [NSURL URLWithString:_url];
21 | }
22 | }
23 |
24 | - (MGLSource *)makeSource
25 | {
26 | NSURL *myURL;
27 |
28 | if ([[_url substringToIndex:4] isEqualToString:@"http"]) {
29 | myURL = [NSURL URLWithString:_url];
30 | }
31 | else
32 | {
33 | //Default consider it file url path
34 | myURL = [NSURL fileURLWithPath:_url];
35 | }
36 |
37 | return [[MGLImageSource alloc] initWithIdentifier:self.id
38 | coordinateQuad:[self _makeCoordQuad]
39 | URL:myURL];
40 | }
41 |
42 | - (MGLCoordinateQuad)_makeCoordQuad
43 | {
44 | CLLocationCoordinate2D topLeft = CLLocationCoordinate2DMake([self.coordinates[0][1] floatValue], [self.coordinates[0][0] floatValue]);
45 | CLLocationCoordinate2D topRight = CLLocationCoordinate2DMake([self.coordinates[1][1] floatValue], [self.coordinates[1][0] floatValue]);
46 | CLLocationCoordinate2D bottomRight = CLLocationCoordinate2DMake([self.coordinates[2][1] floatValue], [self.coordinates[2][0] floatValue]);
47 | CLLocationCoordinate2D bottomLeft = CLLocationCoordinate2DMake([self.coordinates[3][1] floatValue], [self.coordinates[3][0] floatValue]);
48 | return MGLCoordinateQuadMake(topLeft, bottomLeft, bottomRight, topRight);
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLEventTypes.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLEventTypes.h
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/27/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RCTMGLEventTypes : NSObject
12 |
13 | extern NSString *const RCT_MAPBOX_EVENT_TAP;
14 | extern NSString *const RCT_MAPBOX_EVENT_LONGPRESS;
15 |
16 | extern NSString *const RCT_MAPBOX_USER_LOCATION_UPDATE;
17 | extern NSString *const RCT_MAPBOX_USER_TRACKING_MODE_CHANGE;
18 |
19 | extern NSString *const RCT_MAPBOX_REGION_WILL_CHANGE_EVENT;
20 | extern NSString *const RCT_MAPBOX_REGION_IS_CHANGING;
21 | extern NSString *const RCT_MAPBOX_REGION_DID_CHANGE;
22 |
23 | extern NSString *const RCT_MAPBOX_WILL_START_LOADING_MAP;
24 | extern NSString *const RCT_MAPBOX_DID_FINISH_LOADING_MAP;
25 | extern NSString *const RCT_MAPBOX_DID_FAIL_LOADING_MAP;
26 |
27 | extern NSString *const RCT_MAPBOX_WILL_START_RENDERING_FRAME;
28 | extern NSString *const RCT_MAPBOX_DID_FINSIH_RENDERING_FRAME;
29 | extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_FRAME_FULLY;
30 |
31 | extern NSString *const RCT_MAPBOX_WILL_START_RENDERING_MAP;
32 | extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP;
33 | extern NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP_FULLY;
34 |
35 | extern NSString *const RCT_MAPBOX_DID_FINISH_LOADING_STYLE;
36 |
37 | extern NSString *const RCT_MAPBOX_ANNOTATION_TAP;
38 |
39 | extern NSString *const RCT_MAPBOX_OFFLINE_PROGRESS;
40 | extern NSString *const RCT_MAPBOX_OFFLINE_ERROR;
41 | extern NSString *const RCT_MAPBOX_OFFLINE_TILE_LIMIT;
42 |
43 | extern NSString *const RCT_MAPBOX_SHAPE_SOURCE_LAYER_PRESS;
44 | extern NSString *const RCT_MAPBOX_VECTOR_SOURCE_LAYER_PRESS;
45 |
46 | extern NSString *const RCT_MAPBOX_USER_LOCATION_UPDATE;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/FeatureClickEvent.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.react.bridge.WritableMap;
6 | import com.mapbox.geojson.Feature;
7 | import com.mapbox.rctmgl.events.constants.EventKeys;
8 | import com.mapbox.rctmgl.events.constants.EventTypes;
9 | import com.mapbox.rctmgl.utils.GeoJSONUtils;
10 |
11 | /**
12 | * Created by nickitaliano on 11/7/17.
13 | */
14 |
15 | public class FeatureClickEvent extends AbstractEvent {
16 | private String mEventKey;
17 | private Feature mFeature;
18 |
19 | public FeatureClickEvent(View view, String eventKey, String eventType, Feature feature) {
20 | super(view, eventType);
21 | mFeature = feature;
22 | mEventKey = eventKey;
23 | }
24 |
25 | @Override
26 | public String getKey() {
27 | return mEventKey;
28 | }
29 |
30 | @Override
31 | public WritableMap getPayload() {
32 | return GeoJSONUtils.fromFeature(mFeature);
33 | }
34 |
35 | public static FeatureClickEvent makeShapeSourceEvent(View view, Feature feature) {
36 | return new FeatureClickEvent(view, EventKeys.SHAPE_SOURCE_LAYER_CLICK,
37 | EventTypes.SHAPE_SOURCE_LAYER_CLICK, feature);
38 | }
39 |
40 | public static FeatureClickEvent makeVectorSourceEvent(View view, Feature feature) {
41 | return new FeatureClickEvent(view, EventKeys.VECTOR_SOURCE_LAYER_CLICK,
42 | EventTypes.VECTOR_SOURCE_LAYER_CLICK, feature);
43 | }
44 |
45 | public static FeatureClickEvent makeRasterSourceEvent(View view, Feature feature) {
46 | return new FeatureClickEvent(view, EventKeys.RASTER_SOURCE_LAYER_CLICK,
47 | EventTypes.RASTER_SOURCE_LAYER_CLICK, feature);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/UserLocation.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.location;
2 |
3 | import android.location.Location;
4 |
5 | import com.mapbox.mapboxsdk.geometry.LatLng;
6 |
7 | /**
8 | * Created by nickitaliano on 12/13/17.
9 | */
10 |
11 | public class UserLocation {
12 | private Location currentLocation;
13 | private Location previousLocation;
14 |
15 | private int userTrackingMode = UserTrackingMode.NONE;
16 |
17 | public UserLocation() {
18 | this(null);
19 | }
20 |
21 | public UserLocation(Location currentLocation) {
22 | this.currentLocation = currentLocation;
23 | }
24 |
25 | public Location getCurrentLocation() {
26 | return currentLocation;
27 | }
28 |
29 | public double getBearing() {
30 | if (currentLocation == null) {
31 | return 0.0;
32 | }
33 | return currentLocation.getBearing();
34 | }
35 |
36 | public LatLng getCoordinate() {
37 | if (currentLocation == null) {
38 | return null;
39 | }
40 |
41 | return new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
42 | }
43 |
44 | public void setCurrentLocation(Location currentLocation) {
45 | this.previousLocation = this.currentLocation;
46 | this.currentLocation = currentLocation;
47 | }
48 |
49 | public void setTrackingMode(int userTrackingMode) {
50 | this.userTrackingMode = userTrackingMode;
51 | }
52 |
53 | public int getTrackingMode() {
54 | return userTrackingMode;
55 | }
56 |
57 | public float getDistance(Location location) {
58 | if (currentLocation == null) {
59 | return 0.0f;
60 | }
61 | return currentLocation.distanceTo(location);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/android/rctmgl/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | def safeExtGet(prop, fallback) {
4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5 | }
6 |
7 | android {
8 | compileSdkVersion safeExtGet("compileSdkVersion", 28)
9 | buildToolsVersion safeExtGet("buildToolsVersion", '28.0.3')
10 |
11 | defaultConfig {
12 | minSdkVersion safeExtGet('minSdkVersion', 16)
13 | targetSdkVersion safeExtGet('targetSdkVersion', 26)
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 |
29 | // React Native
30 | compileOnly "com.facebook.react:react-native:+"
31 |
32 | // Mapbox SDK
33 |
34 | implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.8.0'
35 | implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.0.0'
36 |
37 | // Dependencies
38 | implementation "com.android.support:support-vector-drawable:${safeExtGet('supportLibVersion', '28.0.0')}"
39 | implementation "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '28.0.0')}"
40 | implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
41 | implementation "com.squareup.okhttp3:okhttp:${safeExtGet('okhttpVersion', '3.12.1')}"
42 |
43 | // Mapbox plugins
44 | implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:0.9.0'
45 | implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v7:0.2.0'
46 | implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
47 | }
48 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/EventEmitter.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events;
2 |
3 | import android.util.Log;
4 |
5 | import com.facebook.react.ReactApplication;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.bridge.ReactContext;
9 | import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
10 | import com.facebook.react.uimanager.events.RCTEventEmitter;
11 |
12 |
13 | public class EventEmitter {
14 | public static final String LOG_TAG = EventEmitter.class.getSimpleName();
15 |
16 |
17 | private static ReactContext getCurrentReactContext(ReactApplicationContext reactApplicationContext) {
18 | if (reactApplicationContext.getApplicationContext() instanceof ReactApplication) {
19 | ReactApplication reactApplication = ((ReactApplication) reactApplicationContext
20 | .getApplicationContext());
21 |
22 | return reactApplication
23 | .getReactNativeHost()
24 | .getReactInstanceManager()
25 | .getCurrentReactContext();
26 | } else {
27 | Log.d(LOG_TAG, "getApplicationContext() application doesn't implement ReactApplication");
28 | return reactApplicationContext;
29 | }
30 | }
31 |
32 |
33 | public static RCTNativeAppEventEmitter getModuleEmitter(ReactApplicationContext reactApplicationContext) {
34 | RCTNativeAppEventEmitter emitter = null;
35 |
36 | try {
37 | emitter = getCurrentReactContext(reactApplicationContext)
38 | .getJSModule(RCTNativeAppEventEmitter.class);
39 | } catch (NullPointerException e) {
40 | Log.d(LOG_TAG, e.getLocalizedMessage());
41 | }
42 |
43 | return emitter;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.camera;
2 |
3 | import com.mapbox.mapboxsdk.maps.MapboxMap;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Iterator;
7 | import java.util.LinkedList;
8 | import java.util.List;
9 | import java.util.Queue;
10 | import java.util.concurrent.ExecutorService;
11 | import java.util.concurrent.Executors;
12 | import java.util.concurrent.FutureTask;
13 |
14 | /**
15 | * Created by nickitaliano on 9/5/17.
16 | */
17 |
18 | public class CameraUpdateQueue {
19 | private Queue mQueue;
20 |
21 | private OnCompleteAllListener mCompleteListener;
22 |
23 | public interface OnCompleteAllListener {
24 | void onCompleteAll();
25 | }
26 |
27 | public CameraUpdateQueue() {
28 | mQueue = new LinkedList<>();
29 | }
30 |
31 | public void offer(CameraStop item) {
32 | mQueue.offer(item);
33 | }
34 |
35 | public int size() {
36 | return mQueue.size();
37 | }
38 |
39 | public boolean isEmpty() {
40 | return mQueue.isEmpty();
41 | }
42 |
43 | public void flush() {
44 | while (mQueue.size() > 0) {
45 | mQueue.remove();
46 | }
47 | mQueue = new LinkedList<>();
48 | }
49 |
50 | public void setOnCompleteAllListener(OnCompleteAllListener listener) {
51 | mCompleteListener = listener;
52 | }
53 |
54 | public void execute(MapboxMap map) {
55 | if (mQueue.isEmpty()) {
56 | if (mCompleteListener != null) {
57 | mCompleteListener.onCompleteAll();
58 | }
59 | return;
60 | }
61 |
62 | final CameraStop stop = mQueue.poll();
63 | if (stop == null) {
64 | return;
65 | }
66 |
67 | CameraUpdateItem item = stop.toCameraUpdate(map);
68 | item.run();
69 | execute(map);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/javascript/modules/snapshot/SnapshotOptions.js:
--------------------------------------------------------------------------------
1 | import {NativeModules} from 'react-native';
2 |
3 | import {toJSONString} from '../../utils';
4 | import {makePoint, makeFeatureCollection} from '../../utils/geoUtils';
5 |
6 | const MapboxGL = NativeModules.MGLModule;
7 |
8 | class SnapshotOptions {
9 | constructor(options = {}) {
10 | if (!options.centerCoordinate && !options.bounds) {
11 | throw new Error(
12 | 'Center coordinate or bounds must be supplied in order to take a snapshot',
13 | );
14 | }
15 |
16 | this.styleURL = options.styleURL || MapboxGL.StyleURL.Street;
17 | this.heading = options.heading || 0.0;
18 | this.pitch = options.pitch || 0.0;
19 | this.zoomLevel = options.zoomLevel || 16.0;
20 | this.width = options.width || 50.0;
21 | this.height = options.height || 50.0;
22 | this.writeToDisk = options.writeToDisk || false;
23 |
24 | if (options.centerCoordinate) {
25 | this.centerCoordinate = this._createCenterCoordPoint(
26 | options.centerCoordinate,
27 | );
28 | }
29 |
30 | if (options.bounds) {
31 | this.bounds = this._createBoundsCollection(options.bounds);
32 | }
33 | }
34 |
35 | toJSON() {
36 | return {
37 | styleURL: this.styleURL,
38 | heading: this.heading,
39 | pitch: this.pitch,
40 | zoomLevel: this.zoomLevel,
41 | width: this.width,
42 | height: this.height,
43 | writeToDisk: this.writeToDisk,
44 | centerCoordinate: this.centerCoordinate,
45 | bounds: this.bounds,
46 | };
47 | }
48 |
49 | _createCenterCoordPoint(centerCoordinate) {
50 | const point = makePoint(centerCoordinate);
51 | return toJSONString(point);
52 | }
53 |
54 | _createBoundsCollection(bounds) {
55 | const features = [];
56 |
57 | for (const bound of bounds) {
58 | features.push(makePoint(bound));
59 | }
60 |
61 | return toJSONString(makeFeatureCollection(features));
62 | }
63 | }
64 |
65 | export default SnapshotOptions;
66 |
--------------------------------------------------------------------------------
/ios/RCTMGL/MGLUserLocationHeadingArrowLayer.m:
--------------------------------------------------------------------------------
1 | #import "MGLUserLocationHeadingArrowLayer.h"
2 | #import "MGLFaux3DUserLocationAnnotationView.h"
3 |
4 | const CGFloat MGLUserLocationHeadingArrowSize = 6;
5 |
6 | @implementation MGLUserLocationHeadingArrowLayer
7 |
8 | - (instancetype)initWithUserLocationAnnotationView:(MGLUserLocationAnnotationView *)userLocationView
9 | {
10 | CGFloat size = userLocationView.bounds.size.width + MGLUserLocationHeadingArrowSize;
11 |
12 | self = [super init];
13 | self.bounds = CGRectMake(0, 0, size, size);
14 | self.position = CGPointMake(CGRectGetMidX(userLocationView.bounds), CGRectGetMidY(userLocationView.bounds));
15 | self.path = [self arrowPath];
16 | self.fillColor = userLocationView.tintColor.CGColor;
17 | self.shouldRasterize = YES;
18 | self.rasterizationScale = UIScreen.mainScreen.scale;
19 | self.drawsAsynchronously = YES;
20 |
21 | self.strokeColor = UIColor.whiteColor.CGColor;
22 | self.lineWidth = 1.0;
23 | self.lineJoin = kCALineJoinRound;
24 |
25 | return self;
26 | }
27 |
28 | - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy
29 | {
30 | // unimplemented
31 | }
32 |
33 | - (void)updateTintColor:(CGColorRef)color
34 | {
35 | self.fillColor = color;
36 | }
37 |
38 | - (CGPathRef)arrowPath {
39 | CGFloat center = roundf(CGRectGetMidX(self.bounds));
40 | CGFloat size = MGLUserLocationHeadingArrowSize;
41 |
42 | CGPoint top = CGPointMake(center, 0);
43 | CGPoint left = CGPointMake(center - size, size);
44 | CGPoint right = CGPointMake(center + size, size);
45 | CGPoint middle = CGPointMake(center, size / M_PI);
46 |
47 | UIBezierPath *bezierPath = [UIBezierPath bezierPath];
48 | [bezierPath moveToPoint:top];
49 | [bezierPath addLineToPoint:left];
50 | [bezierPath addQuadCurveToPoint:right controlPoint:middle];
51 | [bezierPath addLineToPoint:top];
52 | [bezierPath closePath];
53 |
54 | return bezierPath.CGPath;
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLMapTouchEvent.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLTouchEvent.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/25/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLMapTouchEvent.h"
10 | #import "RCTMGLEventTypes.h"
11 | #import "RCTMGLPointAnnotation.h"
12 | @import Mapbox;
13 |
14 | @implementation RCTMGLMapTouchEvent
15 |
16 | - (NSDictionary*)payload
17 | {
18 | MGLPointFeature *feature = [[MGLPointFeature alloc] init];
19 | feature.coordinate = _coordinate;
20 | feature.attributes = @{
21 | @"screenPointX": [NSNumber numberWithDouble:_screenPoint.x],
22 | @"screenPointY":[NSNumber numberWithDouble:_screenPoint.y]
23 | };
24 | return [feature geoJSONDictionary];
25 | }
26 |
27 | + (RCTMGLMapTouchEvent*)makeTapEvent:(MGLMapView*)mapView withPoint:(CGPoint)point
28 | {
29 | return [RCTMGLMapTouchEvent _fromPoint:point withMapView:mapView andEventType:RCT_MAPBOX_EVENT_TAP];
30 | }
31 |
32 | + (RCTMGLMapTouchEvent*)makeLongPressEvent:(MGLMapView*)mapView withPoint:(CGPoint)point
33 | {
34 | return [RCTMGLMapTouchEvent _fromPoint:point withMapView:mapView andEventType:RCT_MAPBOX_EVENT_LONGPRESS];
35 | }
36 |
37 | + (RCTMGLMapTouchEvent *)makeAnnotationTapEvent:(RCTMGLPointAnnotation *)pointAnnotation
38 | {
39 | RCTMGLMapTouchEvent *event = [[RCTMGLMapTouchEvent alloc] init];
40 | event.type = RCT_MAPBOX_ANNOTATION_TAP;
41 | event.coordinate = pointAnnotation.coordinate;
42 | event.screenPoint = [pointAnnotation.superview convertPoint:pointAnnotation.frame.origin toView:nil];
43 | return event;
44 | }
45 |
46 | + (RCTMGLMapTouchEvent*)_fromPoint:(CGPoint)point withMapView:(MGLMapView *)mapView andEventType:(NSString*)eventType
47 | {
48 | RCTMGLMapTouchEvent *event = [[RCTMGLMapTouchEvent alloc] init];
49 | event.type = eventType;
50 | event.coordinate =[mapView convertPoint:point toCoordinateFromView:mapView];
51 | event.screenPoint = point;
52 | return event;
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/light/RCTMGLLight.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.light;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.bridge.ReadableMap;
6 | import com.mapbox.mapboxsdk.maps.MapboxMap;
7 | import com.mapbox.mapboxsdk.maps.Style;
8 | import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
9 | import com.mapbox.mapboxsdk.style.light.Light;
10 | import com.mapbox.mapboxsdk.style.light.Position;
11 | import com.mapbox.rctmgl.components.AbstractMapFeature;
12 | import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
13 | import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
14 | import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | /**
20 | * Created by nickitaliano on 9/26/17.
21 | */
22 |
23 | public class RCTMGLLight extends AbstractMapFeature {
24 | private MapboxMap mMap;
25 | private ReadableMap mReactStyle;
26 |
27 | public RCTMGLLight(Context context) {
28 | super(context);
29 | }
30 |
31 | @Override
32 | public void addToMap(RCTMGLMapView mapView) {
33 | mMap = mapView.getMapboxMap();
34 | setLight();
35 | }
36 |
37 | @Override
38 | public void removeFromMap(RCTMGLMapView mapView) {
39 | // ignore there's nothing to remove just update the light style
40 | }
41 |
42 | public void setReactStyle(ReadableMap reactStyle) {
43 | mReactStyle = reactStyle;
44 |
45 | setLight();
46 | }
47 |
48 | private void setLight(Light light) {
49 | RCTMGLStyleFactory.setLightLayerStyle(light, new RCTMGLStyle(getContext(), mReactStyle, mMap));
50 | }
51 |
52 | private void setLight() {
53 | Style style = getStyle();
54 | if (style != null) {
55 | setLight(style.getLight());
56 | }
57 | }
58 |
59 | private Style getStyle() {
60 | if (mMap == null) {
61 | return null;
62 | }
63 | return mMap.getStyle();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLEventTypes.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLEventTypes.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 8/27/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLEventTypes.h"
10 |
11 | @implementation RCTMGLEventTypes
12 |
13 | NSString *const RCT_MAPBOX_EVENT_TAP = @"press";
14 | NSString *const RCT_MAPBOX_EVENT_LONGPRESS = @"longpress";
15 |
16 | NSString *const RCT_MAPBOX_USER_TRACKING_MODE_CHANGE = @"usertrackingmodechange";
17 |
18 | NSString *const RCT_MAPBOX_REGION_WILL_CHANGE_EVENT = @"regionwillchange";
19 | NSString *const RCT_MAPBOX_REGION_IS_CHANGING = @"regionischanging";
20 | NSString *const RCT_MAPBOX_REGION_DID_CHANGE = @"regiondidchange";
21 |
22 | NSString *const RCT_MAPBOX_WILL_START_LOADING_MAP = @"willstartloadingmap";
23 | NSString *const RCT_MAPBOX_DID_FINISH_LOADING_MAP = @"didfinishloadingmap";
24 | NSString *const RCT_MAPBOX_DID_FAIL_LOADING_MAP = @"didfailoadingmap";
25 |
26 | NSString *const RCT_MAPBOX_WILL_START_RENDERING_FRAME = @"willstartrenderingframe";
27 | NSString *const RCT_MAPBOX_DID_FINSIH_RENDERING_FRAME = @"didfinishrenderingframe";
28 | NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_FRAME_FULLY = @"didfinishrenderingframefully";
29 |
30 | NSString *const RCT_MAPBOX_WILL_START_RENDERING_MAP = @"willstartrenderingmap";
31 | NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP = @"didfinishrenderingmap";
32 | NSString *const RCT_MAPBOX_DID_FINISH_RENDERING_MAP_FULLY = @"didfinishrenderingmapfully";
33 |
34 | NSString *const RCT_MAPBOX_DID_FINISH_LOADING_STYLE = @"didfinishloadingstyle";
35 |
36 | NSString *const RCT_MAPBOX_ANNOTATION_TAP = @"annotationtap";
37 |
38 | NSString *const RCT_MAPBOX_OFFLINE_PROGRESS = @"offlinestatus";
39 | NSString *const RCT_MAPBOX_OFFLINE_ERROR = @"offlineerror";
40 | NSString *const RCT_MAPBOX_OFFLINE_TILE_LIMIT = @"offlinetilelimit";
41 |
42 | NSString *const RCT_MAPBOX_SHAPE_SOURCE_LAYER_PRESS = @"shapesourcelayerpress";
43 | NSString *const RCT_MAPBOX_VECTOR_SOURCE_LAYER_PRESS = @"vectorsourcelayerpress";
44 |
45 | NSString *const RCT_MAPBOX_USER_LOCATION_UPDATE = @"MapboxUserLocationUpdate";
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/javascript/components/AbstractLayer.js:
--------------------------------------------------------------------------------
1 | /* eslint react/prop-types:0 */
2 | import React from 'react';
3 | import {processColor} from 'react-native';
4 | import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
5 |
6 | import {getFilter} from '../utils/filterUtils';
7 | import {getStyleType} from '../utils/styleMap';
8 | import BridgeValue from '../utils/BridgeValue';
9 |
10 | class AbstractLayer extends React.PureComponent {
11 | get baseProps() {
12 | return {
13 | ...this.props,
14 | id: this.props.id,
15 | sourceID: this.props.sourceID,
16 | reactStyle: this.getStyle(),
17 | minZoomLevel: this.props.minZoomLevel,
18 | maxZoomLevel: this.props.maxZoomLevel,
19 | aboveLayerID: this.props.aboveLayerID,
20 | belowLayerID: this.props.belowLayerID,
21 | layerIndex: this.props.layerIndex,
22 | filter: getFilter(this.props.filter),
23 | style: undefined,
24 | };
25 | }
26 |
27 | getStyleTypeFormatter(styleType) {
28 | if (styleType === 'color') {
29 | return processColor;
30 | }
31 | }
32 |
33 | getStyle() {
34 | if (!this.props.style) {
35 | return;
36 | }
37 |
38 | const nativeStyle = {};
39 | const styleProps = Object.keys(this.props.style);
40 | for (const styleProp of styleProps) {
41 | const styleType = getStyleType(styleProp);
42 | let rawStyle = this.props.style[styleProp];
43 |
44 | if (styleType === 'color' && typeof rawStyle === 'string') {
45 | rawStyle = processColor(rawStyle);
46 | } else if (styleType === 'image' && typeof rawStyle === 'number') {
47 | rawStyle = resolveAssetSource(rawStyle) || {};
48 | }
49 |
50 | const bridgeValue = new BridgeValue(rawStyle);
51 | nativeStyle[styleProp] = {
52 | styletype: styleType,
53 | stylevalue: bridgeValue.toJSON(),
54 | };
55 | }
56 |
57 | return nativeStyle;
58 | }
59 |
60 | setNativeProps(props) {
61 | if (this.refs.nativeLayer) {
62 | this.refs.nativeLayer.setNativeProps(props);
63 | }
64 | }
65 | }
66 |
67 | export default AbstractLayer;
68 |
--------------------------------------------------------------------------------
/javascript/utils/geoUtils.js:
--------------------------------------------------------------------------------
1 | import turfHelpers from '@turf/helpers';
2 | import distance from '@turf/distance';
3 | import along from '@turf/along';
4 | import geoViewport from '@mapbox/geo-viewport';
5 |
6 | const VECTOR_TILE_SIZE = 512;
7 |
8 | export function makePoint(coordinates, properties) {
9 | return turfHelpers.point(coordinates, properties);
10 | }
11 |
12 | export function makeLineString(coordinates, properties) {
13 | return turfHelpers.lineString(coordinates, properties);
14 | }
15 |
16 | export function makeLatLngBounds(northEastCoordinates, southWestCoordinates) {
17 | return turfHelpers.featureCollection([
18 | turfHelpers.point(northEastCoordinates),
19 | turfHelpers.point(southWestCoordinates),
20 | ]);
21 | }
22 |
23 | export function makeFeature(geometry, properties) {
24 | return turfHelpers.feature(geometry, properties);
25 | }
26 |
27 | export function makeFeatureCollection(features = []) {
28 | return turfHelpers.featureCollection(features);
29 | }
30 |
31 | export function addToFeatureCollection(featureCollection, feature) {
32 | const shallowFeatureCollection = Object.assign({}, featureCollection);
33 | shallowFeatureCollection.features.push(feature);
34 | return featureCollection;
35 | }
36 |
37 | export function calculateDistance(origin, dest) {
38 | return distance(origin, dest);
39 | }
40 |
41 | export function pointAlongLine(lineString, distAlong) {
42 | return along(lineString, distAlong);
43 | }
44 |
45 | export function getOrCalculateVisibleRegion(
46 | coord,
47 | zoomLevel,
48 | width,
49 | height,
50 | nativeRegion,
51 | ) {
52 | const region = {
53 | ne: [0, 0],
54 | sw: [0, 0],
55 | };
56 |
57 | if (!nativeRegion || !Array.isArray(nativeRegion.visibleBounds)) {
58 | const bounds = geoViewport.bounds(
59 | coord,
60 | zoomLevel,
61 | [width, height],
62 | VECTOR_TILE_SIZE,
63 | );
64 | region.ne = [bounds[3], bounds[2]];
65 | region.sw = [bounds[1], bounds[0]];
66 | } else {
67 | region.ne = nativeRegion.properties.visibleBounds[0];
68 | region.sw = nativeRegion.properties.visibleBounds[1];
69 | }
70 |
71 | return region;
72 | }
73 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLLocationModule.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLLocationManager.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 6/21/18.
6 | // Copyright © 2018 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RCTMGLLocation.h"
12 | #import "RCTMGLLocationModule.h"
13 | #import "RCTMGLLocationManager.h"
14 | #import "RCTMGLLocationManagerDelegate.h"
15 | #import "RCTMGLEventTypes.h"
16 |
17 | @interface RCTMGLLocationModule()
18 | @end
19 |
20 | @implementation RCTMGLLocationModule
21 | {
22 | RCTMGLLocationManager *locationManager;
23 | BOOL hasListeners;
24 | }
25 |
26 | RCT_EXPORT_MODULE();
27 |
28 | + (BOOL)requiresMainQueueSetup
29 | {
30 | return NO;
31 | }
32 |
33 | - (instancetype)init
34 | {
35 | if (self = [super init]) {
36 | locationManager = [[RCTMGLLocationManager alloc] init];
37 | locationManager.delegate = self;
38 | }
39 | return self;
40 | }
41 |
42 | - (void)startObserving
43 | {
44 | [super startObserving];
45 | hasListeners = YES;
46 | }
47 |
48 | - (void)stopObserving
49 | {
50 | [super stopObserving];
51 | hasListeners = NO;
52 | }
53 |
54 | - (NSArray *)supportedEvents
55 | {
56 | return @[RCT_MAPBOX_USER_LOCATION_UPDATE];
57 | }
58 |
59 | RCT_EXPORT_METHOD(start)
60 | {
61 | [locationManager start];
62 | }
63 |
64 | RCT_EXPORT_METHOD(pause)
65 | {
66 | [locationManager stop];
67 | }
68 |
69 | RCT_EXPORT_METHOD(stop)
70 | {
71 | [locationManager stop];
72 | }
73 |
74 | RCT_EXPORT_METHOD(getLastKnownLocation:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
75 | {
76 | RCTMGLLocation *lastKnownLocation = [locationManager getLastKnownLocation];
77 | resolve(lastKnownLocation);
78 | }
79 |
80 | - (void)locationManager:(RCTMGLLocationManager *)locationManager didUpdateLocation:(RCTMGLLocation *)location
81 | {
82 | if (!hasListeners) {
83 | return;
84 | }
85 |
86 | if (self.bridge == nil) {
87 | return;
88 | }
89 |
90 | [self sendEventWithName:RCT_MAPBOX_USER_LOCATION_UPDATE body:[location toJSON]];
91 | }
92 |
93 | @end
94 |
--------------------------------------------------------------------------------
/docs/Light.md:
--------------------------------------------------------------------------------
1 | ##
2 | ### Light represents the light source for extruded geometries
3 |
4 | ### props
5 | | Prop | Type | Default | Required | Description |
6 | | ---- | :--: | :-----: | :------: | :----------: |
7 | | style | `custom` | `none` | `false` | Customizable style attributes |
8 |
9 |
10 | ### styles
11 |
12 | * anchor
13 | * position
14 | * color
15 | * intensity
16 |
17 | ___
18 |
19 | #### Name
20 | `anchor`
21 |
22 | #### Description
23 | Whether extruded geometries are lit relative to the map or viewport.
24 |
25 | #### Type
26 | `enum`
27 | #### Default Value
28 | `viewport`
29 |
30 | #### Supported Values
31 | **map** - The position of the light source is aligned to the rotation of the map.
32 | **viewport** - The position of the light source is aligned to the rotation of the viewport.
33 |
34 |
35 |
36 | ___
37 |
38 | #### Name
39 | `position`
40 |
41 | #### Description
42 | Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below).
43 |
44 | #### Type
45 | `array`
46 | #### Default Value
47 | `[1.15,210,30]`
48 |
49 |
50 |
51 | ___
52 |
53 | #### Name
54 | `color`
55 |
56 | #### Description
57 | Color tint for lighting extruded geometries.
58 |
59 | #### Type
60 | `color`
61 | #### Default Value
62 | `#ffffff`
63 |
64 |
65 |
66 | ___
67 |
68 | #### Name
69 | `intensity`
70 |
71 | #### Description
72 | Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.
73 |
74 | #### Type
75 | `number`
76 | #### Default Value
77 | `0.5`
78 |
79 | #### Minimum
80 | `0`
81 |
82 |
83 | #### Maximum
84 | `1`
85 |
86 |
87 |
--------------------------------------------------------------------------------
/javascript/utils/BridgeValue.js:
--------------------------------------------------------------------------------
1 | import {isBoolean, isNumber, isString} from './index';
2 |
3 | const Types = {
4 | Array: 'array',
5 | Bool: 'boolean',
6 | Number: 'number',
7 | String: 'string',
8 | HashMap: 'hashmap',
9 | };
10 |
11 | export default class BridgeValue {
12 | constructor(rawValue) {
13 | this.rawValue = rawValue;
14 | }
15 |
16 | get type() {
17 | if (Array.isArray(this.rawValue)) {
18 | return Types.Array;
19 | }
20 | if (isBoolean(this.rawValue)) {
21 | return Types.Bool;
22 | }
23 | if (isNumber(this.rawValue)) {
24 | return Types.Number;
25 | }
26 | if (isString(this.rawValue)) {
27 | return Types.String;
28 | }
29 | if (this.rawValue && typeof this.rawValue === 'object') {
30 | return Types.HashMap;
31 | }
32 | throw new Error(
33 | `[type - ${this.rawValue}] BridgeValue must be a primitive/array/object`,
34 | );
35 | }
36 |
37 | get value() {
38 | const {type} = this;
39 |
40 | let value;
41 |
42 | if (type === Types.Array) {
43 | value = [];
44 |
45 | for (const innerRawValue of this.rawValue) {
46 | const bridgeValue = new BridgeValue(innerRawValue);
47 | value.push(bridgeValue.toJSON());
48 | }
49 | } else if (type === Types.HashMap) {
50 | value = [];
51 |
52 | const stringKeys = Object.keys(this.rawValue);
53 | for (const stringKey of stringKeys) {
54 | value.push([
55 | new BridgeValue(stringKey).toJSON(),
56 | new BridgeValue(this.rawValue[stringKey]).toJSON(),
57 | ]);
58 | }
59 | } else if (
60 | type === Types.Bool ||
61 | type === Types.Number ||
62 | type === Types.String
63 | ) {
64 | value = this.rawValue;
65 | } else {
66 | throw new Error(
67 | `[value - ${
68 | this.rawValue
69 | }] BridgeValue must be a primitive/array/object`,
70 | );
71 | }
72 |
73 | return value;
74 | }
75 |
76 | toJSON(formatter) {
77 | return {
78 | type: this.type,
79 | value:
80 | typeof formatter === 'function' ? formatter(this.value) : this.value,
81 | };
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/javascript/components/ImageSource.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import {requireNativeComponent} from 'react-native';
4 |
5 | import {
6 | cloneReactChildrenWithProps,
7 | viewPropTypes,
8 | isNumber,
9 | resolveImagePath,
10 | } from '../utils';
11 |
12 | import AbstractSource from './AbstractSource';
13 |
14 | export const NATIVE_MODULE_NAME = 'RCTMGLImageSource';
15 |
16 | /**
17 | * ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
18 | * The georeferenced image scales and rotates as the user zooms and rotates the map
19 | */
20 | class ImageSource extends AbstractSource {
21 | static propTypes = {
22 | ...viewPropTypes,
23 |
24 | /**
25 | * A string that uniquely identifies the source.
26 | */
27 | id: PropTypes.string,
28 |
29 | /**
30 | * An HTTP(S) URL, absolute file URL, or local file URL to the source image.
31 | * Gifs are currently not supported.
32 | */
33 | url: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
34 |
35 | /**
36 | * The top left, top right, bottom right, and bottom left coordinates for the image.
37 | */
38 | coordinates: PropTypes.arrayOf(
39 | PropTypes.arrayOf(PropTypes.number).isRequired,
40 | ).isRequired,
41 | };
42 |
43 | _getURL() {
44 | let {url} = this.props;
45 |
46 | if (isNumber(this.props.url)) {
47 | url = resolveImagePath(this.props.url);
48 | }
49 |
50 | return url;
51 | }
52 |
53 | render() {
54 | if (
55 | !this.props.url ||
56 | !this.props.coordinates ||
57 | !this.props.coordinates.length
58 | ) {
59 | return null;
60 | }
61 |
62 | const props = {
63 | ...this.props,
64 | url: this._getURL(),
65 | };
66 |
67 | return (
68 |
69 | {cloneReactChildrenWithProps(this.props.children, {
70 | sourceID: this.props.id,
71 | })}
72 |
73 | );
74 | }
75 | }
76 |
77 | const RCTMGLImageSource = requireNativeComponent(
78 | NATIVE_MODULE_NAME,
79 | ImageSource,
80 | );
81 |
82 | export default ImageSource;
83 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.sources;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.facebook.drawee.backends.pipeline.Fresco;
7 | import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
8 | import com.mapbox.geojson.Feature;
9 | import com.mapbox.mapboxsdk.geometry.LatLngQuad;
10 | import com.mapbox.mapboxsdk.style.sources.ImageSource;
11 |
12 | import java.net.MalformedURLException;
13 | import java.net.URL;
14 |
15 | import android.net.Uri;
16 |
17 | /**
18 | * Created by nickitaliano on 11/29/17.
19 | */
20 |
21 | public class RCTMGLImageSource extends RCTSource {
22 | public static final String LOG_TAG = RCTMGLImageSource.class.getSimpleName();
23 |
24 | private URL mURL;
25 | private int mResourceId;
26 | private LatLngQuad mCoordQuad;
27 |
28 | public RCTMGLImageSource(Context context) {
29 | super(context);
30 | }
31 |
32 | @Override
33 | public ImageSource makeSource() {
34 | if (this.mURL == null) {
35 | return new ImageSource(mID, mCoordQuad, this.mResourceId);
36 | }
37 | return new ImageSource(mID, mCoordQuad, mURL);
38 | }
39 |
40 | @Override
41 | public void onPress(Feature feature) {
42 | // ignore, we cannot query raster layers
43 | }
44 |
45 | public void setURL(String url) {
46 | try {
47 | Uri uri = Uri.parse(url);
48 |
49 | if (uri.getScheme() == null) {
50 | this.mResourceId = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(this.getContext(), url);
51 |
52 | if (mSource != null) {
53 | mSource.setImage(this.mResourceId);
54 | }
55 |
56 | } else {
57 |
58 | mURL = new URL(url);
59 |
60 | if (mSource != null) {
61 | mSource.setUrl(mURL);
62 | }
63 | }
64 |
65 | } catch (MalformedURLException e) {
66 | Log.w(LOG_TAG, e.getLocalizedMessage());
67 | }
68 | }
69 |
70 |
71 | public void setCoordinates(LatLngQuad coordQuad) {
72 | mCoordQuad = coordQuad;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import com.facebook.react.bridge.ReadableMap;
4 | import com.facebook.react.uimanager.ThemedReactContext;
5 | import com.facebook.react.uimanager.ViewGroupManager;
6 | import com.facebook.react.uimanager.annotations.ReactProp;
7 |
8 | /**
9 | * Created by nickitaliano on 9/25/17.
10 | */
11 |
12 | public class RCTMGLRasterLayerManager extends ViewGroupManager {
13 | public static final String REACT_CLASS = RCTMGLRasterLayer.class.getSimpleName();
14 |
15 | @Override
16 | public String getName() {
17 | return REACT_CLASS;
18 | }
19 |
20 | @Override
21 | protected RCTMGLRasterLayer createViewInstance(ThemedReactContext reactContext) {
22 | return new RCTMGLRasterLayer(reactContext);
23 | }
24 |
25 | @ReactProp(name="id")
26 | public void setId(RCTMGLRasterLayer layer, String id) {
27 | layer.setID(id);
28 | }
29 |
30 | @ReactProp(name="sourceID")
31 | public void setSourceID(RCTMGLRasterLayer layer, String sourceID) {
32 | layer.setSourceID(sourceID);
33 | }
34 |
35 | @ReactProp(name="aboveLayerID")
36 | public void setAboveLayerID(RCTMGLRasterLayer layer, String aboveLayerID) {
37 | layer.setAboveLayerID(aboveLayerID);
38 | }
39 |
40 | @ReactProp(name="belowLayerID")
41 | public void setBelowLayerID(RCTMGLRasterLayer layer, String belowLayerID) {
42 | layer.setBelowLayerID(belowLayerID);
43 | }
44 |
45 | @ReactProp(name="layerIndex")
46 | public void setLayerIndex(RCTMGLRasterLayer layer, int layerIndex){
47 | layer.setLayerIndex(layerIndex);
48 | }
49 |
50 | @ReactProp(name="minZoomLevel")
51 | public void setMinZoomLevel(RCTMGLRasterLayer layer, double minZoomLevel) {
52 | layer.setMinZoomLevel(minZoomLevel);
53 | }
54 |
55 | @ReactProp(name="maxZoomLevel")
56 | public void setMaxZoomLevel(RCTMGLRasterLayer layer, double maxZoomLevel) {
57 | layer.setMaxZoomLevel(maxZoomLevel);
58 | }
59 |
60 | @ReactProp(name="reactStyle")
61 | public void setReactStyle(RCTMGLRasterLayer layer, ReadableMap style) {
62 | layer.setReactStyle(style);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ios/RCTMGL/CameraStop.m:
--------------------------------------------------------------------------------
1 | //
2 | // CameraStop.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 9/5/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "CameraStop.h"
10 | #import "CameraMode.h"
11 | #import "RCTMGLUtils.h"
12 | #import "RCTMGLCamera.h"
13 |
14 | @implementation CameraStop
15 |
16 | - (void)setMode:(NSNumber *)mode
17 | {
18 | int modeInt = [mode intValue];
19 |
20 | if (modeInt == RCT_MAPBOX_CAMERA_MODE_FLIGHT) {
21 | _mode = [NSNumber numberWithInt:modeInt];
22 | } else if (modeInt == RCT_MAPBOX_CAMERA_MODE_NONE) {
23 | _mode = [NSNumber numberWithInt:modeInt];
24 | } else {
25 | _mode = [NSNumber numberWithInt:RCT_MAPBOX_CAMERA_MODE_EASE];
26 | }
27 | }
28 |
29 | + (CameraStop*)fromDictionary:(NSDictionary *)args
30 | {
31 | CameraStop *stop = [[CameraStop alloc] init];
32 |
33 | if (args[@"pitch"]) {
34 | stop.pitch = args[@"pitch"];
35 | }
36 |
37 | if (args[@"heading"]) {
38 | stop.heading = args[@"heading"];
39 | }
40 |
41 | if (args[@"centerCoordinate"]) {
42 | stop.coordinate = [RCTMGLUtils fromFeature:args[@"centerCoordinate"]];
43 | }
44 |
45 | if (args[@"zoom"]) {
46 | stop.zoom = args[@"zoom"];
47 | }
48 |
49 | if (args[@"mode"]) {
50 | stop.mode = args[@"mode"];
51 | }
52 |
53 | if (args[@"bounds"]) {
54 | stop.bounds = [RCTMGLUtils fromFeatureCollection:args[@"bounds"]];
55 |
56 | if (args[@"boundsPaddingLeft"]) {
57 | stop.boundsPaddingLeft = args[@"boundsPaddingLeft"];
58 | }
59 |
60 | if (args[@"boundsPaddingRight"]) {
61 | stop.boundsPaddingRight = args[@"boundsPaddingRight"];
62 | }
63 |
64 | if (args[@"boundsPaddingTop"]) {
65 | stop.boundsPaddingTop = args[@"boundsPaddingTop"];
66 | }
67 |
68 | if (args[@"boundsPaddingBottom"]) {
69 | stop.boundsPaddingBottom = args[@"boundsPaddingBottom"];
70 | }
71 | }
72 |
73 | NSTimeInterval duration = 2.0;
74 | if (args[@"duration"]) {
75 | duration = [RCTMGLUtils fromMS:args[@"duration"]];
76 | }
77 | stop.duration = duration;
78 |
79 | return stop;
80 | }
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/javascript/modules/snapshot/snapshotManager.js:
--------------------------------------------------------------------------------
1 | import {NativeModules} from 'react-native';
2 |
3 | import SnapshotOptions from './SnapshotOptions';
4 |
5 | const MapboxGLSnapshotManger = NativeModules.MGLSnapshotModule;
6 |
7 | /**
8 | * The snapshotManager generates static raster images of the map.
9 | * Each snapshot image depicts a portion of a map defined by an SnapshotOptions object you provide.
10 | * The snapshotter generates the snapshot asynchronous.
11 | */
12 | class SnapshotManager {
13 | /**
14 | * Takes a snapshot of the base map using the provided Snapshot options. NOTE pitch, heading, zoomLevel only works when centerCoordinate is set!
15 | *
16 | * @example
17 | *
18 | * // creates a temp file png of base map
19 | * const uri = await MapboxGL.snapshotManager.takeSnap({
20 | * centerCoordinate: [-74.126410, 40.797968],
21 | * width: width,
22 | * height: height,
23 | * zoomLevel: 12,
24 | * pitch: 30,
25 | * heading: 20,
26 | * styleURL: MapboxGL.StyleURL.Dark,
27 | * writeToDisk: true, // creates a temp file
28 | * });
29 | *
30 | * // creates base64 png of base map
31 | * const uri = await MapboxGL.snapshotManager.takeSnap({
32 | * centerCoordinate: [-74.126410, 40.797968],
33 | * width: width,
34 | * height: height,
35 | * zoomLevel: 12,
36 | * pitch: 30,
37 | * heading: 20,
38 | * styleURL: MapboxGL.StyleURL.Dark,
39 | * });
40 | *
41 | * // creates snapshot with bounds
42 | * const uri = await MapboxGL.snapshotManager.takeSnap({
43 | * bounds: [[-74.126410, 40.797968], [-74.143727, 40.772177]],
44 | * width: width,
45 | * height: height,
46 | * styleURL: MapboxGL.StyleURL.Dark,
47 | * });
48 | *
49 | * @param {SnapshotOptions} options Snapshot options for create a static image of the base map
50 | * @return {Promise}
51 | */
52 | takeSnap(options = {}) {
53 | const snapshotOptions = new SnapshotOptions(options);
54 |
55 | return new Promise(async (resolve, reject) => {
56 | try {
57 | const uri = await MapboxGLSnapshotManger.takeSnap(snapshotOptions);
58 | resolve(uri);
59 | } catch (e) {
60 | reject(e);
61 | }
62 | });
63 | }
64 | }
65 |
66 | const snapshotManager = new SnapshotManager();
67 | export default snapshotManager;
68 |
--------------------------------------------------------------------------------
/ios/RCTMGL/RCTMGLCallout.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTMGLCalloutView.m
3 | // RCTMGL
4 | //
5 | // Created by Nick Italiano on 10/13/17.
6 | // Copyright © 2017 Mapbox Inc. All rights reserved.
7 | //
8 |
9 | #import "RCTMGLCallout.h"
10 | #import
11 |
12 | @implementation RCTMGLCallout
13 | {
14 | id _representedObject;
15 | __unused UIView *_leftAccessoryView;/* unused */
16 | __unused UIView *_rightAccessoryView;/* unused */
17 | __weak id _delegate;
18 | BOOL _dismissesAutomatically;
19 | BOOL _anchoredToAnnotation;
20 | }
21 |
22 | @synthesize representedObject = _representedObject;
23 | @synthesize leftAccessoryView = _leftAccessoryView;/* unused */
24 | @synthesize rightAccessoryView = _rightAccessoryView;/* unused */
25 | @synthesize delegate = _delegate;
26 | @synthesize anchoredToAnnotation = _anchoredToAnnotation;
27 | @synthesize dismissesAutomatically = _dismissesAutomatically;
28 |
29 | - (instancetype)init
30 | {
31 | if (self = [super init]) {
32 | // prevent tap from bubbling up to it's superview
33 | UITapGestureRecognizer *captureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
34 | [self addGestureRecognizer:captureTap];
35 | }
36 | return self;
37 | }
38 |
39 | // https://github.com/mapbox/mapbox-gl-native/issues/9228
40 | - (void)setCenter:(CGPoint)center {
41 | center.y = center.y - CGRectGetMidY(self.bounds);
42 | [super setCenter:center];
43 | }
44 |
45 | - (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToRect:(CGRect)constrainedRect animated:(BOOL)animated;
46 | {
47 | // we want to attach to our parents parent to be on the same zPosition stack, so the callout will appear over other custom views
48 | [view.superview addSubview:self];
49 |
50 | // adjust frame
51 | double centerX = rect.origin.x + (rect.size.width / 2);
52 | CGPoint center = CGPointMake(centerX, rect.origin.y);
53 | [self setCenter:center];
54 | }
55 |
56 | - (void)dismissCalloutAnimated:(BOOL)animated
57 | {
58 | [self removeFromSuperview];
59 | }
60 |
61 | - (BOOL)dismissesAutomatically {
62 | return NO;
63 | }
64 |
65 | - (BOOL)isAnchoredToAnnotation {
66 | return YES;
67 | }
68 |
69 | - (void)update
70 | {
71 | [self setCenter:self.center];
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.layers;
2 |
3 | import com.facebook.react.bridge.ReadableMap;
4 | import com.facebook.react.uimanager.ThemedReactContext;
5 | import com.facebook.react.uimanager.ViewGroupManager;
6 | import com.facebook.react.uimanager.annotations.ReactProp;
7 |
8 | /**
9 | * Created by nickitaliano on 9/25/17.
10 | */
11 |
12 | public class RCTMGLBackgroundLayerManager extends ViewGroupManager {
13 | public static final String REACT_CLASS = RCTMGLBackgroundLayer.class.getSimpleName();
14 |
15 | @Override
16 | public String getName() {
17 | return REACT_CLASS;
18 | }
19 |
20 | @Override
21 | protected RCTMGLBackgroundLayer createViewInstance(ThemedReactContext reactContext) {
22 | return new RCTMGLBackgroundLayer(reactContext);
23 | }
24 |
25 | @ReactProp(name="id")
26 | public void setId(RCTMGLBackgroundLayer layer, String id) {
27 | layer.setID(id);
28 | }
29 |
30 | @ReactProp(name="sourceID")
31 | public void setSourceID(RCTMGLBackgroundLayer layer, String sourceID) {
32 | layer.setSourceID(sourceID);
33 | }
34 |
35 | @ReactProp(name="aboveLayerID")
36 | public void setAboveLayerID(RCTMGLBackgroundLayer layer, String aboveLayerID) {
37 | layer.setAboveLayerID(aboveLayerID);
38 | }
39 |
40 | @ReactProp(name="belowLayerID")
41 | public void setBelowLayerID(RCTMGLBackgroundLayer layer, String belowLayerID) {
42 | layer.setBelowLayerID(belowLayerID);
43 | }
44 |
45 | @ReactProp(name="layerIndex")
46 | public void setLayerIndex(RCTMGLBackgroundLayer layer, int layerIndex){
47 | layer.setLayerIndex(layerIndex);
48 | }
49 |
50 | @ReactProp(name="minZoomLevel")
51 | public void setMinZoomLevel(RCTMGLBackgroundLayer layer, double minZoomLevel) {
52 | layer.setMinZoomLevel(minZoomLevel);
53 | }
54 |
55 | @ReactProp(name="maxZoomLevel")
56 | public void setMaxZoomLevel(RCTMGLBackgroundLayer layer, double maxZoomLevel) {
57 | layer.setMaxZoomLevel(maxZoomLevel);
58 | }
59 |
60 | @ReactProp(name="reactStyle")
61 | public void setReactStyle(RCTMGLBackgroundLayer layer, ReadableMap style) {
62 | layer.setReactStyle(style);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mapir SDK for React Native
2 |
3 | [](https://badge.fury.io/js/mapir-mapbox.svg)
4 | _A React Native library for building maps with the [Mapbox Maps SDK for iOS](https://www.mapbox.com/ios-sdk/) and [Mapbox Maps SDK for Android](https://www.mapbox.com/android-sdk/)_
5 |
6 |
7 |  React Native wrapper for mapbox-gl-js. Expose a bunch of component meant to be simple to use for React Native.
8 |
9 | ## Get API Key
10 | 🔑 You should first get api key from [Map.ir](https://corp.map.ir/registration/)
11 |
12 |
13 | ## Installation
14 |
15 | **Dependencies**
16 |
17 | * [node](https://nodejs.org)
18 | * [npm](https://www.npmjs.com/)
19 | * [React Native](https://facebook.github.io/react-native/) recommended version ^0.62.2
20 |
21 | ```
22 | npm install mapir-react-native-sdk
23 | ```
24 |
25 | ### Platform Specific Installation Guides
26 |
27 | * [Android](https://github.com/map-ir/mapir-mapbox/blob/master/android/install.md)
28 | * [iOS](https://github.com/map-ir/mapir-mapbox/blob/master/ios/install.md)
29 | * [example](https://github.com/map-ir/Mapir-react-native-example)
30 |
31 | ## Quick start
32 |
33 | ### Import module
34 |
35 | ```js
36 | import React, {Component} from 'react';
37 | import { SafeAreaView, StyleSheet, View} from 'react-native';
38 | import Mapir from 'mapir-react-native-sdk'
39 | ```
40 |
41 | ### Generate Component
42 | ```jsx
43 | export default function App() {
44 | onRegionDidChange = (e) => {
45 | console.log('onRegionDidChange', e.geometry.coordinates);
46 | };
47 | return (
48 |
49 |
50 | onRegionDidChange(e)}
53 | style={styles.container}
54 | >
55 |
59 |
60 |
61 |
62 | );
63 | }
64 |
65 | const styles = StyleSheet.create({
66 | container: {
67 | flex: 1,
68 | },
69 | });
70 | ```
71 |
72 | 📖 [English Documentation](https://github.com/map-ir/mapir-react-native-sdk/wiki/Documentation)
73 |
74 | 📖 [Persian Documentation](https://support.map.ir/developers/reactnative/)
75 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/events/constants/EventTypes.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.events.constants;
2 |
3 | /**
4 | * Created by nickitaliano on 8/24/17.
5 | */
6 |
7 | public class EventTypes {
8 | // map event types
9 | public static final String MAP_CLICK = "press";
10 | public static final String MAP_LONG_CLICK = "longpress";
11 | public static final String MAP_USER_TRACKING_MODE_CHANGE = "usertrackingmodechange";
12 |
13 | public static final String REGION_WILL_CHANGE = "regionwillchange";
14 | public static final String REGION_IS_CHANGING = "regionischanging";
15 | public static final String REGION_DID_CHANGE = "regiondidchange";
16 | public static final String USER_LOCATION_UPDATED = "userlocationdupdated";
17 |
18 | public static final String WILL_START_LOADING_MAP = "willstartloadingmap";
19 | public static final String DID_FINISH_LOADING_MAP = "didfinishloadingmap";
20 | public static final String DID_FAIL_LOADING_MAP = "didfailloadingmap";
21 |
22 | public static final String WILL_START_RENDERING_FRAME = "willstartrenderingframe";
23 | public static final String DID_FINISH_RENDERING_FRAME = "didfinishrenderingframe";
24 | public static final String DID_FINISH_RENDERING_FRAME_FULLY = "didfinishrenderingframefully";
25 |
26 | public static final String WILL_START_RENDERING_MAP = "willstartrenderingmap";
27 | public static final String DID_FINISH_RENDERING_MAP = "didfinishrenderingmap";
28 | public static final String DID_FINISH_RENDERING_MAP_FULLY = "didfinishrenderingmapfully";
29 |
30 | public static final String DID_FINISH_LOADING_STYLE = "didfinishloadingstyle";
31 |
32 | // point annotation event types
33 | public static final String ANNOTATION_SELECTED = "annotationselected";
34 | public static final String ANNOTATION_DESELECTED = "annotationdeselected";
35 |
36 | // offline event types
37 | public static final String OFFLINE_ERROR = "offlineerror";
38 | public static final String OFFLINE_TILE_LIMIT = "offlinetilelimit";
39 | public static final String OFFLINE_STATUS = "offlinestatus";
40 |
41 | // shape source event types
42 | public static final String SHAPE_SOURCE_LAYER_CLICK = "shapesourcelayerpress";
43 | public static final String VECTOR_SOURCE_LAYER_CLICK = "vectorsourcelayerpress";
44 | public static final String RASTER_SOURCE_LAYER_CLICK = "rastersourcelayerpress";
45 | }
46 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.sources;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 |
6 | import com.facebook.react.bridge.ReadableArray;
7 | import com.facebook.react.uimanager.ThemedReactContext;
8 | import com.facebook.react.uimanager.ViewGroupManager;
9 | import com.facebook.react.uimanager.annotations.ReactProp;
10 | import com.facebook.react.views.imagehelper.ImageSource;
11 | import com.mapbox.mapboxsdk.geometry.LatLngQuad;
12 | import com.mapbox.rctmgl.utils.ConvertUtils;
13 | import com.mapbox.rctmgl.utils.GeoJSONUtils;
14 |
15 | /**
16 | * Created by nickitaliano on 11/29/17.
17 | */
18 |
19 | public class RCTMGLImageSourceManager extends ViewGroupManager {
20 | final String REACT_CLASS = RCTMGLImageSource.class.getSimpleName();
21 |
22 | @Override
23 | public String getName() {
24 | return REACT_CLASS;
25 | }
26 |
27 | @Override
28 | protected RCTMGLImageSource createViewInstance(ThemedReactContext reactContext) {
29 | return new RCTMGLImageSource(reactContext);
30 | }
31 |
32 | @Override
33 | public View getChildAt(RCTMGLImageSource source, int childPosition) {
34 | return source.getLayerAt(childPosition);
35 | }
36 |
37 | @Override
38 | public int getChildCount(RCTMGLImageSource source) {
39 | return source.getLayerCount();
40 | }
41 |
42 | @Override
43 | public void addView(RCTMGLImageSource source, View childView, int childPosition) {
44 | source.addLayer(childView, childPosition);
45 | }
46 |
47 | @Override
48 | public void removeViewAt(RCTMGLImageSource source, int childPosition) {
49 | source.removeLayer(childPosition);
50 | }
51 |
52 | @ReactProp(name = "id")
53 | public void setId(RCTMGLImageSource source, String id) {
54 | source.setID(id);
55 | }
56 |
57 | @ReactProp(name = "url")
58 | public void setUrl(RCTMGLImageSource source, String url) {
59 | source .setURL(url);
60 | }
61 |
62 | @ReactProp(name = "coordinates")
63 | public void setCoordinates(RCTMGLImageSource source, ReadableArray arr) {
64 | LatLngQuad quad = GeoJSONUtils.toLatLngQuad(arr);
65 |
66 | if (quad == null) {
67 | return;
68 | }
69 |
70 | source.setCoordinates(quad);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.java:
--------------------------------------------------------------------------------
1 | package com.mapbox.rctmgl.components.styles.sources;
2 |
3 | import android.content.Context;
4 |
5 | import com.mapbox.geojson.Feature;
6 | import com.mapbox.mapboxsdk.style.sources.RasterSource;
7 | import com.mapbox.mapboxsdk.style.sources.TileSet;
8 |
9 | /**
10 | * Created by nickitaliano on 9/25/17.
11 | */
12 |
13 | public class RCTMGLRasterSource extends RCTSource {
14 | public static final String TILE_SPEC_VERSION = "2.1.0";
15 |
16 | private String mURL;
17 | private String mAttribution;
18 |
19 | private Integer mTileSize;
20 | private Integer mMinZoomLevel;
21 | private Integer mMaxZoomLevel;
22 |
23 | private boolean mIsTmsSource;
24 |
25 | public RCTMGLRasterSource(Context context) {
26 | super(context);
27 | }
28 |
29 | @Override
30 | public RasterSource makeSource() {
31 | return new RasterSource(mID, buildTileset(), mTileSize);
32 | }
33 |
34 | public void setURL(String url) {
35 | mURL = url;
36 | }
37 |
38 | public void setTileSize(int tileSize) {
39 | mTileSize = tileSize;
40 | }
41 |
42 | public void setMinZoomLevel(int minZoomLevel) {
43 | mMinZoomLevel = minZoomLevel;
44 | }
45 |
46 | public void setMaxZoomLevel(int maxZoomLevel) {
47 | mMaxZoomLevel = maxZoomLevel;
48 | }
49 |
50 | public void setTMS(boolean tms) {
51 | mIsTmsSource = tms;
52 | }
53 |
54 | public void setAttribution(String attribution) {
55 | mAttribution = attribution;
56 | }
57 |
58 | private TileSet buildTileset() {
59 | TileSet tileSet = new TileSet(TILE_SPEC_VERSION, mURL);
60 |
61 | if (mMinZoomLevel != null) {
62 | tileSet.setMinZoom(mMinZoomLevel.floatValue());
63 | }
64 |
65 | if (mMaxZoomLevel != null) {
66 | tileSet.setMaxZoom(mMaxZoomLevel.floatValue());
67 | }
68 |
69 | if (mIsTmsSource) {
70 | tileSet.setScheme("tms");
71 | }
72 |
73 | if (mAttribution != null) {
74 | tileSet.setAttribution(mAttribution);
75 | }
76 |
77 | return tileSet;
78 | }
79 |
80 | @Override
81 | public boolean hasPressListener() {
82 | return false;
83 | }
84 |
85 | @Override
86 | public void onPress(Feature feature) {
87 | // ignore, cannot query raster layers
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/javascript/components/VectorSource.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import {NativeModules, requireNativeComponent} from 'react-native';
4 |
5 | import {cloneReactChildrenWithProps, viewPropTypes, isFunction} from '../utils';
6 |
7 | import AbstractSource from './AbstractSource';
8 |
9 | const MapboxGL = NativeModules.MGLModule;
10 |
11 | export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
12 |
13 | /**
14 | * VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
15 | * The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
16 | */
17 | class VectorSource extends AbstractSource {
18 | static propTypes = {
19 | ...viewPropTypes,
20 |
21 | /**
22 | * A string that uniquely identifies the source.
23 | */
24 | id: PropTypes.string,
25 |
26 | /**
27 | * A URL to a TileJSON configuration file describing the source’s contents and other metadata.
28 | */
29 | url: PropTypes.string,
30 |
31 | /**
32 | * Source press listener, gets called when a user presses one of the children layers only
33 | * if that layer has a higher z-index than another source layers
34 | */
35 | onPress: PropTypes.func,
36 |
37 | /**
38 | * Overrides the default touch hitbox(44x44 pixels) for the source layers
39 | */
40 | hitbox: PropTypes.shape({
41 | width: PropTypes.number.isRequired,
42 | height: PropTypes.number.isRequired,
43 | }),
44 | };
45 |
46 | static defaultProps = {
47 | id: MapboxGL.StyleSource.DefaultSourceID,
48 | };
49 |
50 | render() {
51 | const props = {
52 | id: this.props.id,
53 | url: this.props.url,
54 | hitbox: this.props.hitbox,
55 | hasPressListener: isFunction(this.props.onPress),
56 | onMapboxVectorSourcePress: this.props.onPress,
57 | onPress: undefined,
58 | };
59 | return (
60 |
61 | {cloneReactChildrenWithProps(this.props.children, {
62 | sourceID: this.props.id,
63 | })}
64 |
65 | );
66 | }
67 | }
68 |
69 | const RCTMGLVectorSource = requireNativeComponent(
70 | NATIVE_MODULE_NAME,
71 | VectorSource,
72 | {
73 | nativeOnly: {
74 | hasPressListener: true,
75 | onMapboxVectorSourcePress: true,
76 | },
77 | },
78 | );
79 |
80 | export default VectorSource;
81 |
--------------------------------------------------------------------------------