@rnmapbox/maps 10.0.0-beta.31 → 10.0.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -2
- package/.github/ISSUE_TEMPLATE/bug_report.yml +112 -0
- package/.husky/pre-commit +5 -0
- package/.nvmrc +1 -1
- package/README-v10.md +1 -1
- package/README.md +28 -23
- package/android/install.md +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +27 -31
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +53 -48
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +5 -5
- package/docs/Annotation.md +8 -8
- package/docs/Annotations.md +14 -12
- package/docs/Atmosphere.md +76 -76
- package/docs/BackgroundLayer.md +44 -44
- package/docs/Callout.md +4 -4
- package/docs/Camera.md +124 -6
- package/docs/CircleLayer.md +129 -129
- package/docs/CustomHttpHeaders.md +15 -13
- package/docs/FillExtrusionLayer.md +120 -120
- package/docs/FillLayer.md +83 -83
- package/docs/HeadingIndicator.md +3 -3
- package/docs/HeatmapLayer.md +58 -58
- package/docs/ImageSource.md +4 -3
- package/docs/Images.md +3 -3
- package/docs/Light.md +45 -45
- package/docs/LineLayer.md +166 -166
- package/docs/Logger.md +8 -9
- package/docs/MapView.md +32 -32
- package/docs/MapboxGL.md +26 -27
- package/docs/MarkerView.md +11 -6
- package/docs/NativeUserLocation.md +3 -3
- package/docs/OfflineManager.md +35 -33
- package/docs/PointAnnotation.md +12 -6
- package/docs/RasterDemSource.md +3 -3
- package/docs/RasterLayer.md +99 -99
- package/docs/RasterSource.md +5 -3
- package/docs/ShapeSource.md +17 -16
- package/docs/SkyLayer.md +69 -69
- package/docs/Style.md +5 -3
- package/docs/StyleSheet.md +74 -278
- package/docs/SymbolLayer.md +454 -454
- package/docs/Terrain.md +6 -6
- package/docs/UserLocation.md +8 -8
- package/docs/VectorSource.md +9 -8
- package/docs/docs.json +196 -28
- package/docs/snapshotManager.md +7 -5
- package/index.d.ts +41 -26
- package/ios/RCTMGL-v10/CustomHttpHeaders.swift +39 -0
- package/ios/RCTMGL-v10/MGLModule.m +3 -0
- package/ios/RCTMGL-v10/MGLModule.swift +8 -0
- package/ios/RCTMGL-v10/RCTMGLCamera.swift +14 -5
- package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +28 -14
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapper.swift +24 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.m +8 -0
- package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.swift +14 -0
- package/ios/RCTMGL-v10/RCTMGLOfflineModule.swift +10 -12
- package/javascript/{utils/animated → classes}/AnimatedCoordinatesArray.js +1 -1
- package/javascript/{utils/animated → classes}/AnimatedExtractCoordinateFromArray.js +3 -1
- package/javascript/{utils/animated → classes}/AnimatedPoint.js +0 -0
- package/javascript/{utils/animated → classes}/AnimatedRouteCoordinatesArray.js +3 -1
- package/javascript/{utils/animated → classes}/AnimatedShape.js +9 -3
- package/javascript/classes/index.d.ts +5 -0
- package/javascript/classes/index.js +5 -0
- package/javascript/components/Callout.js +1 -1
- package/javascript/components/Camera.tsx +5 -1
- package/javascript/components/Images.js +1 -1
- package/javascript/components/MapView.js +3 -4
- package/javascript/components/MarkerView.tsx +125 -0
- package/javascript/components/PointAnnotation.d.ts +13 -0
- package/javascript/components/RasterDemSource.js +1 -1
- package/javascript/components/RasterSource.js +1 -1
- package/javascript/components/ShapeSource.js +4 -4
- package/javascript/components/Style.js +1 -1
- package/javascript/components/annotations/Annotation.js +3 -3
- package/javascript/index.js +27 -14
- package/javascript/types/index.ts +14 -0
- package/javascript/utils/BridgeValue.ts +89 -0
- package/javascript/utils/StyleValue.ts +22 -10
- package/javascript/utils/animated/Animated.js +0 -11
- package/javascript/utils/deprecation.js +0 -1
- package/javascript/utils/geoUtils.d.ts +10 -0
- package/javascript/utils/index.d.ts +6 -0
- package/javascript/utils/{styleMap.js → styleMap.ts} +110 -354
- package/javascript/web/MapContext.ts +6 -0
- package/javascript/web/components/Camera.tsx +39 -0
- package/javascript/web/components/MapView.tsx +51 -0
- package/package.json +21 -20
- package/plugin/build/withMapbox.js +0 -2
- package/plugin/install.md +13 -6
- package/scripts/autogenHelpers/DocJSONBuilder.js +43 -4
- package/scripts/autogenHelpers/globals.js +0 -2
- package/scripts/autogenerate.js +3 -4
- package/scripts/templates/component.md.ejs +25 -25
- package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +7 -4
- package/tsconfig.json +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -75
- package/javascript/components/MarkerView.js +0 -91
- package/javascript/utils/BridgeValue.js +0 -81
- package/javascript/utils/resolveAssetSource.d.ts +0 -5
- package/javascript/web/MapContext.js +0 -5
package/.eslintrc.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
3
|
parser: '@babel/eslint-parser',
|
|
4
|
-
plugins: ['react', 'react-native', '
|
|
4
|
+
plugins: ['react', 'react-native', 'import'],
|
|
5
5
|
env: {
|
|
6
6
|
jest: true,
|
|
7
7
|
},
|
|
@@ -38,6 +38,7 @@ module.exports = {
|
|
|
38
38
|
extends: [
|
|
39
39
|
'eslint:recommended',
|
|
40
40
|
'plugin:react/recommended',
|
|
41
|
+
'plugin:jest/recommended',
|
|
41
42
|
'@react-native-community',
|
|
42
43
|
'prettier',
|
|
43
44
|
],
|
|
@@ -76,7 +77,6 @@ module.exports = {
|
|
|
76
77
|
'no-use-before-define': ['error', { functions: false }],
|
|
77
78
|
'no-unused-expressions': ['error', { allowTaggedTemplates: true }],
|
|
78
79
|
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
|
79
|
-
'fp/no-mutating-methods': 'warn',
|
|
80
80
|
'react-native/no-inline-styles': 0,
|
|
81
81
|
},
|
|
82
82
|
ignorePatterns: ['**/rnmapbox.web.symlink'],
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: This template should be used for reporting bugs and defects.
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: 'bug :beetle:'
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for taking the time to fill out this bug report!
|
|
10
|
+
- type: dropdown
|
|
11
|
+
id: mapbox-implementation
|
|
12
|
+
attributes:
|
|
13
|
+
label: Mapbox Implementation
|
|
14
|
+
description: |-
|
|
15
|
+
Check `RNMapboxMapsImpl` in your Podfile/gradle files. Defaults to `Maplibre`.
|
|
16
|
+
options:
|
|
17
|
+
- Mapbox
|
|
18
|
+
- Mapbox GL
|
|
19
|
+
- Maplibre
|
|
20
|
+
validations:
|
|
21
|
+
required: true
|
|
22
|
+
- type: input
|
|
23
|
+
id: mapbox-version
|
|
24
|
+
attributes:
|
|
25
|
+
label: Mapbox Version
|
|
26
|
+
description: |-
|
|
27
|
+
Check `RNMapboxMapsVersion` in your Podfile/gradle files, set to `default` if you don't cusomize the version
|
|
28
|
+
placeholder: 10.7.0
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
- type: dropdown
|
|
32
|
+
id: platform
|
|
33
|
+
attributes:
|
|
34
|
+
label: Platform
|
|
35
|
+
multiple: true
|
|
36
|
+
description: |-
|
|
37
|
+
The platform where you experience the issue
|
|
38
|
+
options:
|
|
39
|
+
- iOS
|
|
40
|
+
- Android
|
|
41
|
+
validations:
|
|
42
|
+
required: true
|
|
43
|
+
- type: input
|
|
44
|
+
id: rnmapbox-version
|
|
45
|
+
attributes:
|
|
46
|
+
label: "`@rnmapbox/maps` version"
|
|
47
|
+
description: |-
|
|
48
|
+
The version of `@rnmapbox/maps`, such as `#main`, `10.0.0-beta.32`
|
|
49
|
+
value: 10.0.0-beta.11
|
|
50
|
+
validations:
|
|
51
|
+
required: true
|
|
52
|
+
- type: textarea
|
|
53
|
+
attributes:
|
|
54
|
+
label: Standalone component to reproduce
|
|
55
|
+
description: |-
|
|
56
|
+
- Use [our BugReportTemplate](https://github.com/rnmapbox/maps/blob/main/example/src/examples/BugReportExample.js) screens as a starting point.
|
|
57
|
+
- Component should be self contained - no extra libraries, external data, no parameters
|
|
58
|
+
- Do not include setAccessToken or access token istelf.
|
|
59
|
+
value: |-
|
|
60
|
+
```javascript
|
|
61
|
+
import React from 'react';
|
|
62
|
+
import {
|
|
63
|
+
MapView,
|
|
64
|
+
ShapeSource,
|
|
65
|
+
LineLayer,
|
|
66
|
+
Camera,
|
|
67
|
+
} from '@rnmapbox/maps';
|
|
68
|
+
|
|
69
|
+
const aLine = {
|
|
70
|
+
type: 'LineString',
|
|
71
|
+
coordinates: [
|
|
72
|
+
[-74.00597, 40.71427],
|
|
73
|
+
[-74.00697, 40.71527],
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
class BugReportExample extends React.Component {
|
|
78
|
+
render() {
|
|
79
|
+
return (
|
|
80
|
+
<MapView style={{flex: 1}}>
|
|
81
|
+
<Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
|
|
82
|
+
<ShapeSource id="idStreetLayer" shape={aLine}>
|
|
83
|
+
<LineLayer id="idStreetLayer" />
|
|
84
|
+
</ShapeSource>
|
|
85
|
+
</MapView>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
validations:
|
|
91
|
+
required: true
|
|
92
|
+
- type: textarea
|
|
93
|
+
attributes:
|
|
94
|
+
label: Observed behavior and steps to reproduce
|
|
95
|
+
description: |-
|
|
96
|
+
- Please include as much evidence as possible (traces, videos, screenshots etc.)
|
|
97
|
+
- type: textarea
|
|
98
|
+
attributes:
|
|
99
|
+
label: Expected behavior
|
|
100
|
+
description: |-
|
|
101
|
+
- Please include the expected behavior and any resources supporting this expected behavior.
|
|
102
|
+
- type: textarea
|
|
103
|
+
attributes:
|
|
104
|
+
label: Notes / preliminary analysis
|
|
105
|
+
description: |-
|
|
106
|
+
- include your initial analysis, if available
|
|
107
|
+
- type: textarea
|
|
108
|
+
attributes:
|
|
109
|
+
label: Additional links and references
|
|
110
|
+
description: |-
|
|
111
|
+
- Links to traces, videos et
|
|
112
|
+
|
package/.nvmrc
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
v14.
|
|
1
|
+
v14.20.0
|
|
2
2
|
|
package/README-v10.md
CHANGED
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</tr>
|
|
13
13
|
</table>
|
|
14
14
|
|
|
15
|
-
| [](https://badge.fury.io/js/%40rnmapbox%2Fmaps) | [](https://github.com/rnmapbox/maps/actions/workflows/on-push.yml?branch=main) |
|
|
16
16
|
|---|---|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -91,17 +91,25 @@ _See [iOS](ios/install.md) & [Android](android/install.md) setup guide for more
|
|
|
91
91
|
|
|
92
92
|
### Step 1 - Install Package:
|
|
93
93
|
|
|
94
|
+
#### Using `yarn`
|
|
95
|
+
Install the latest source from git:
|
|
94
96
|
```sh
|
|
95
|
-
# install with Yarn
|
|
96
|
-
# yarn add @rnmapbox/maps
|
|
97
97
|
yarn add rnmapbox/maps#main
|
|
98
|
+
```
|
|
98
99
|
|
|
100
|
+
#### Using `npm`
|
|
101
|
+
Install the latest source from git:
|
|
102
|
+
```sh
|
|
103
|
+
npm install --save rnmapbox/maps#main
|
|
104
|
+
```
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
#
|
|
102
|
-
|
|
106
|
+
#### Installing other versions
|
|
107
|
+
Replace `rnmapbox/maps#main` with the following to install other versions:
|
|
108
|
+
- `@rnmapbox/maps` installs the latest release
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
|
|
111
|
+
#### Using `expo`
|
|
112
|
+
Please follow the [Expo Guide](/plugin/install.md).
|
|
105
113
|
|
|
106
114
|
### Step 2 - Installation Guides:
|
|
107
115
|
|
|
@@ -136,42 +144,39 @@ npm run android
|
|
|
136
144
|
```
|
|
137
145
|
|
|
138
146
|
## Adding a map
|
|
139
|
-
|
|
140
147
|
```js
|
|
141
|
-
import React
|
|
148
|
+
import React from 'react';
|
|
142
149
|
import { StyleSheet, View } from 'react-native';
|
|
143
150
|
import MapboxGL from '@rnmapbox/maps';
|
|
144
151
|
|
|
145
152
|
MapboxGL.setAccessToken('<YOUR_ACCESSTOKEN>');
|
|
146
153
|
|
|
154
|
+
const App = () => {
|
|
155
|
+
return (
|
|
156
|
+
<View style={styles.page}>
|
|
157
|
+
<View style={styles.container}>
|
|
158
|
+
<MapboxGL.MapView style={styles.map} />
|
|
159
|
+
</View>
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default App;
|
|
165
|
+
|
|
147
166
|
const styles = StyleSheet.create({
|
|
148
167
|
page: {
|
|
149
168
|
flex: 1,
|
|
150
169
|
justifyContent: 'center',
|
|
151
170
|
alignItems: 'center',
|
|
152
|
-
backgroundColor: '#F5FCFF'
|
|
153
171
|
},
|
|
154
172
|
container: {
|
|
155
173
|
height: 300,
|
|
156
174
|
width: 300,
|
|
157
|
-
backgroundColor: 'tomato'
|
|
158
175
|
},
|
|
159
176
|
map: {
|
|
160
177
|
flex: 1
|
|
161
178
|
}
|
|
162
179
|
});
|
|
163
|
-
|
|
164
|
-
export default class App extends Component {
|
|
165
|
-
render() {
|
|
166
|
-
return (
|
|
167
|
-
<View style={styles.page}>
|
|
168
|
-
<View style={styles.container}>
|
|
169
|
-
<MapboxGL.MapView style={styles.map} />
|
|
170
|
-
</View>
|
|
171
|
-
</View>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
180
|
```
|
|
176
181
|
---
|
|
177
182
|
## Documentation
|
package/android/install.md
CHANGED
|
@@ -20,7 +20,7 @@ Overwrite mapbox dependencies within your `android/build.gradle > buildscript >
|
|
|
20
20
|
buildscript {
|
|
21
21
|
ext {
|
|
22
22
|
// ...
|
|
23
|
-
RNMapboxMapsImpl = "maplibre" //
|
|
23
|
+
RNMapboxMapsImpl = "maplibre" // optional - as this is the default
|
|
24
24
|
|
|
25
25
|
RNMapboxMapsLibs = { // optional - only required if you want to customize it
|
|
26
26
|
implementation ("org.maplibre.gl:android-sdk:9.5.2")
|
|
@@ -34,10 +34,10 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
34
34
|
private var mZoom: Double? = null
|
|
35
35
|
private var mLatLng: LatLng? = null
|
|
36
36
|
private var mBounds: LatLngBounds? = null
|
|
37
|
-
private var mBoundsPaddingLeft =
|
|
38
|
-
private var mBoundsPaddingRight =
|
|
39
|
-
private var mBoundsPaddingBottom =
|
|
40
|
-
private var mBoundsPaddingTop =
|
|
37
|
+
private var mBoundsPaddingLeft : Int? = null
|
|
38
|
+
private var mBoundsPaddingRight : Int? = null
|
|
39
|
+
private var mBoundsPaddingBottom : Int? = null
|
|
40
|
+
private var mBoundsPaddingTop : Int? = null
|
|
41
41
|
private var mMode = CameraMode.EASE
|
|
42
42
|
private var mDuration = 2000
|
|
43
43
|
private var mCallback: Animator.AnimatorListener? = null
|
|
@@ -67,10 +67,10 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
67
67
|
|
|
68
68
|
fun setBounds(
|
|
69
69
|
bounds: LatLngBounds?,
|
|
70
|
-
paddingLeft: Int
|
|
71
|
-
paddingRight: Int
|
|
72
|
-
paddingTop: Int
|
|
73
|
-
paddingBottom: Int
|
|
70
|
+
paddingLeft: Int?,
|
|
71
|
+
paddingRight: Int?,
|
|
72
|
+
paddingTop: Int?,
|
|
73
|
+
paddingBottom: Int?
|
|
74
74
|
) {
|
|
75
75
|
mBounds = bounds
|
|
76
76
|
mBoundsPaddingLeft = paddingLeft
|
|
@@ -95,6 +95,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
95
95
|
val builder = CameraOptions.Builder()
|
|
96
96
|
builder.center(currentCamera.center)
|
|
97
97
|
builder.bearing(currentCamera.bearing)
|
|
98
|
+
|
|
99
|
+
val currentPadding = currentCamera.padding;
|
|
100
|
+
|
|
98
101
|
builder.padding(currentCamera.padding)
|
|
99
102
|
builder.zoom(currentCamera.zoom)
|
|
100
103
|
if (mBearing != null) {
|
|
@@ -109,16 +112,11 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
109
112
|
val tilt = if (mTilt != null) mTilt!! else currentCamera.pitch
|
|
110
113
|
val bearing = if (mBearing != null) mBearing!! else currentCamera.bearing
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
val
|
|
115
|
-
val
|
|
116
|
-
|
|
117
|
-
val paddingTop = java.lang.Double.valueOf(contentInset.top + mBoundsPaddingTop).toInt()
|
|
118
|
-
val paddingRight =
|
|
119
|
-
java.lang.Double.valueOf(contentInset.right + mBoundsPaddingRight).toInt()
|
|
120
|
-
val paddingBottom =
|
|
121
|
-
java.lang.Double.valueOf(contentInset.bottom + mBoundsPaddingBottom).toInt()
|
|
115
|
+
val paddingLeft: Int = mBoundsPaddingLeft ?: currentPadding.left.toInt()
|
|
116
|
+
val paddingTop: Int = mBoundsPaddingTop ?: currentPadding.top.toInt()
|
|
117
|
+
val paddingRight: Int = mBoundsPaddingRight ?: currentPadding.right.toInt()
|
|
118
|
+
val paddingBottom: Int = mBoundsPaddingBottom ?: currentPadding.bottom.toInt()
|
|
119
|
+
|
|
122
120
|
val cameraPadding = intArrayOf(paddingLeft, paddingTop, paddingRight, paddingBottom)
|
|
123
121
|
val cameraPaddingClipped = clippedPadding(cameraPadding, mapView)
|
|
124
122
|
val boundsCamera = map.cameraForCoordinateBounds(
|
|
@@ -163,18 +161,12 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
163
161
|
stop.setDuration(readableMap.getInt("duration"))
|
|
164
162
|
}
|
|
165
163
|
if (readableMap.hasKey("bounds")) {
|
|
166
|
-
var paddingTop = getBoundsPaddingByKey(readableMap, "paddingTop")
|
|
167
|
-
var paddingRight = getBoundsPaddingByKey(readableMap, "paddingRight")
|
|
168
|
-
var paddingBottom = getBoundsPaddingByKey(readableMap, "paddingBottom")
|
|
169
|
-
var paddingLeft = getBoundsPaddingByKey(readableMap, "paddingLeft")
|
|
170
|
-
|
|
171
|
-
// scale padding by pixel ratio
|
|
172
164
|
val metrics = context.resources.displayMetrics
|
|
173
|
-
paddingTop =
|
|
174
|
-
paddingRight =
|
|
175
|
-
paddingBottom =
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
var paddingTop = getBoundsPaddingByKey(readableMap, metrics.scaledDensity, "paddingTop")
|
|
166
|
+
var paddingRight = getBoundsPaddingByKey(readableMap, metrics.scaledDensity, "paddingRight")
|
|
167
|
+
var paddingBottom = getBoundsPaddingByKey(readableMap, metrics.scaledDensity, "paddingBottom")
|
|
168
|
+
var paddingLeft = getBoundsPaddingByKey(readableMap, metrics.scaledDensity, "paddingLeft")
|
|
169
|
+
|
|
178
170
|
val collection = FeatureCollection.fromJson(readableMap.getString("bounds")!!)
|
|
179
171
|
stop.setBounds(
|
|
180
172
|
toLatLngBounds(collection), paddingLeft, paddingRight,
|
|
@@ -221,8 +213,12 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
|
|
221
213
|
return intArrayOf(resultLeft, resultTop, resultRight, resultBottom)
|
|
222
214
|
}
|
|
223
215
|
|
|
224
|
-
private fun getBoundsPaddingByKey(map: ReadableMap, key: String): Int {
|
|
225
|
-
|
|
216
|
+
private fun getBoundsPaddingByKey(map: ReadableMap, scaledDensity: Float, key: String): Int? {
|
|
217
|
+
if (map.hasKey(key)) {
|
|
218
|
+
return (map.getInt(key) * scaledDensity).toInt()
|
|
219
|
+
} else {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
226
222
|
}
|
|
227
223
|
}
|
|
228
224
|
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt
CHANGED
|
@@ -20,8 +20,10 @@ import com.mapbox.maps.extension.style.layers.Layer
|
|
|
20
20
|
import com.mapbox.maps.extension.style.layers.generated.*
|
|
21
21
|
import com.mapbox.maps.extension.style.layers.getLayer
|
|
22
22
|
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
|
|
23
|
+
import com.mapbox.maps.plugin.annotation.Annotation
|
|
23
24
|
import com.mapbox.maps.plugin.annotation.annotations
|
|
24
25
|
import com.mapbox.maps.plugin.annotation.generated.OnPointAnnotationClickListener
|
|
26
|
+
import com.mapbox.maps.plugin.annotation.generated.OnPointAnnotationDragListener
|
|
25
27
|
import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
|
|
26
28
|
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
|
|
27
29
|
import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
|
|
@@ -79,6 +81,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
79
81
|
private val mHandledMapChangedEvents: HashSet<String>? = null
|
|
80
82
|
private var mOffscreenAnnotationViewContainer: ViewGroup? = null
|
|
81
83
|
private var mAnnotationClicked = false
|
|
84
|
+
private var mAnnotationDragged = false
|
|
82
85
|
private var mLocationComponentManager: LocationComponentManager? = null
|
|
83
86
|
var tintColor: Int? = null
|
|
84
87
|
private set
|
|
@@ -89,6 +92,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
89
92
|
val _this = this
|
|
90
93
|
val gesturesPlugin: GesturesPlugin = this.gestures
|
|
91
94
|
gesturesPlugin.removeOnMapClickListener(_this)
|
|
95
|
+
gesturesPlugin.removeOnMapLongClickListener(_this)
|
|
92
96
|
|
|
93
97
|
mPointAnnotationManager = annotations.createPointAnnotationManager()
|
|
94
98
|
mPointAnnotationManager?.addClickListener(OnPointAnnotationClickListener { pointAnnotation ->
|
|
@@ -96,7 +100,47 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
96
100
|
false
|
|
97
101
|
}
|
|
98
102
|
)
|
|
103
|
+
mPointAnnotationManager?.addDragListener(object : OnPointAnnotationDragListener {
|
|
104
|
+
override fun onAnnotationDragStarted(_annotation: Annotation<*>) {
|
|
105
|
+
mAnnotationDragged = true;
|
|
106
|
+
var reactAnnotation: RCTMGLPointAnnotation? = null
|
|
107
|
+
for (key in mPointAnnotations.keys) {
|
|
108
|
+
val annotation = mPointAnnotations[key]
|
|
109
|
+
val curMarkerID = annotation?.mapboxID
|
|
110
|
+
if (_annotation.id == curMarkerID) {
|
|
111
|
+
reactAnnotation = annotation
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
reactAnnotation?.let { it.onDragStart() }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override fun onAnnotationDrag(_annotation: Annotation<*>) {
|
|
118
|
+
var reactAnnotation: RCTMGLPointAnnotation? = null
|
|
119
|
+
for (key in mPointAnnotations.keys) {
|
|
120
|
+
val annotation = mPointAnnotations[key]
|
|
121
|
+
val curMarkerID = annotation?.mapboxID
|
|
122
|
+
if (_annotation.id == curMarkerID) {
|
|
123
|
+
reactAnnotation = annotation
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
reactAnnotation?.let { it.onDrag() }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override fun onAnnotationDragFinished(_annotation: Annotation<*>) {
|
|
130
|
+
mAnnotationDragged = false;
|
|
131
|
+
var reactAnnotation: RCTMGLPointAnnotation? = null
|
|
132
|
+
for (key in mPointAnnotations.keys) {
|
|
133
|
+
val annotation = mPointAnnotations[key]
|
|
134
|
+
val curMarkerID = annotation?.mapboxID
|
|
135
|
+
if (_annotation.id == curMarkerID) {
|
|
136
|
+
reactAnnotation = annotation
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
reactAnnotation?.let { it.onDragEnd() }
|
|
140
|
+
}
|
|
141
|
+
})
|
|
99
142
|
gesturesPlugin.addOnMapClickListener(_this)
|
|
143
|
+
gesturesPlugin.addOnMapLongClickListener(_this)
|
|
100
144
|
|
|
101
145
|
}
|
|
102
146
|
return mPointAnnotationManager
|
|
@@ -106,7 +150,6 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
106
150
|
map.getStyle(object : Style.OnStyleLoaded {
|
|
107
151
|
override fun onStyleLoaded(style: Style) {
|
|
108
152
|
savedStyle = style
|
|
109
|
-
createSymbolManager(style)
|
|
110
153
|
setUpImage(style)
|
|
111
154
|
addQueuedFeatures()
|
|
112
155
|
setupLocalization(style)
|
|
@@ -426,6 +469,10 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
426
469
|
|
|
427
470
|
override fun onMapLongClick(point: Point): Boolean {
|
|
428
471
|
val _this = this
|
|
472
|
+
if (mAnnotationDragged) {
|
|
473
|
+
mAnnotationDragged = false
|
|
474
|
+
return true
|
|
475
|
+
}
|
|
429
476
|
val screenPoint = mMap?.pixelForCoordinate(point)
|
|
430
477
|
if (screenPoint != null) {
|
|
431
478
|
val event = MapClickEvent(_this, LatLng(point), screenPoint, EventTypes.MAP_LONG_CLICK)
|
|
@@ -480,7 +527,11 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
480
527
|
layerWaiters.remove(layerId)
|
|
481
528
|
}
|
|
482
529
|
|
|
483
|
-
fun waitForLayer(layerID: String
|
|
530
|
+
fun waitForLayer(layerID: String?, callback: FoundLayerCallback) {
|
|
531
|
+
if(layerID == null){
|
|
532
|
+
callback.found(null)
|
|
533
|
+
return
|
|
534
|
+
}
|
|
484
535
|
if (savedStyle != null) {
|
|
485
536
|
val layer = savedStyle?.getLayer(layerID)
|
|
486
537
|
if (layer != null) {
|
|
@@ -534,52 +585,6 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
|
|
|
534
585
|
return GeoJSONUtils.toPointFeature(latLng, properties)
|
|
535
586
|
}
|
|
536
587
|
|
|
537
|
-
fun createSymbolManager(style: Style?) {
|
|
538
|
-
/*
|
|
539
|
-
v10 TODO
|
|
540
|
-
symbolManager = new SymbolManager(this, mMap, style);
|
|
541
|
-
symbolManager.setIconAllowOverlap(true);
|
|
542
|
-
symbolManager.addClickListener(new OnSymbolClickListener() {
|
|
543
|
-
@Override
|
|
544
|
-
public void onAnnotationClick(Symbol symbol) {
|
|
545
|
-
onMarkerClick(symbol);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
symbolManager.addDragListener(new OnSymbolDragListener() {
|
|
549
|
-
@Override
|
|
550
|
-
public void onAnnotationDragStarted(Symbol symbol) {
|
|
551
|
-
mAnnotationClicked = true;
|
|
552
|
-
final long selectedMarkerID = symbol.getId();
|
|
553
|
-
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
|
|
554
|
-
if (annotation != null) {
|
|
555
|
-
annotation.onDragStart();
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
@Override
|
|
560
|
-
public void onAnnotationDrag(Symbol symbol) {
|
|
561
|
-
final long selectedMarkerID = symbol.getId();
|
|
562
|
-
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
|
|
563
|
-
if (annotation != null) {
|
|
564
|
-
annotation.onDrag();
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
@Override
|
|
569
|
-
public void onAnnotationDragFinished(Symbol symbol) {
|
|
570
|
-
mAnnotationClicked = false;
|
|
571
|
-
final long selectedMarkerID = symbol.getId();
|
|
572
|
-
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
|
|
573
|
-
if (annotation != null) {
|
|
574
|
-
annotation.onDragEnd();
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
mMap.addOnMapClickListener(this);
|
|
579
|
-
mMap.addOnMapLongClickListener(this);
|
|
580
|
-
*/
|
|
581
|
-
}
|
|
582
|
-
|
|
583
588
|
fun addQueuedFeatures() {
|
|
584
589
|
if (mQueuedFeatures != null && mQueuedFeatures!!.size > 0) {
|
|
585
590
|
for (i in mQueuedFeatures!!.indices) {
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt
CHANGED
|
@@ -49,7 +49,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
49
49
|
mSourceID = sourceID
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
fun setAboveLayerID(aboveLayerID: String) {
|
|
52
|
+
fun setAboveLayerID(aboveLayerID: String?) {
|
|
53
53
|
if (mAboveLayerID != null && mAboveLayerID == aboveLayerID) {
|
|
54
54
|
return
|
|
55
55
|
}
|
|
@@ -60,7 +60,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
fun setBelowLayerID(belowLayerID: String) {
|
|
63
|
+
fun setBelowLayerID(belowLayerID: String?) {
|
|
64
64
|
if (mBelowLayerID != null && mBelowLayerID == belowLayerID) {
|
|
65
65
|
return
|
|
66
66
|
}
|
|
@@ -147,7 +147,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
fun addAbove(aboveLayerID: String?) {
|
|
150
|
-
mMapView!!.waitForLayer(aboveLayerID
|
|
150
|
+
mMapView!!.waitForLayer(aboveLayerID, object : FoundLayerCallback {
|
|
151
151
|
override fun found(layer: Layer?) {
|
|
152
152
|
if (!hasInitialized()) {
|
|
153
153
|
return
|
|
@@ -160,7 +160,7 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
fun addBelow(belowLayerID: String?) {
|
|
163
|
-
mMapView!!.waitForLayer(belowLayerID
|
|
163
|
+
mMapView!!.waitForLayer(belowLayerID, object : FoundLayerCallback {
|
|
164
164
|
override fun found(layer: Layer?) {
|
|
165
165
|
if (!hasInitialized()) {
|
|
166
166
|
return
|
|
@@ -271,4 +271,4 @@ abstract class RCTLayer<T : Layer?>(protected var mContext: Context) : AbstractS
|
|
|
271
271
|
companion object {
|
|
272
272
|
const val LOG_TAG = "RCTLayer"
|
|
273
273
|
}
|
|
274
|
-
}
|
|
274
|
+
}
|
package/docs/Annotation.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- This file was autogenerated from Annotation.js do not modify -->
|
|
2
|
-
|
|
3
|
-
###
|
|
2
|
+
# <MapboxGL.Annotation />
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
## props
|
|
6
6
|
| Prop | Type | Default | Required | Description |
|
|
7
7
|
| ---- | :--: | :-----: | :------: | :----------: |
|
|
8
8
|
| id | `string` | `none` | `true` | FIX ME NO DESCRIPTION |
|
|
@@ -15,22 +15,22 @@
|
|
|
15
15
|
| style | `any` | `none` | `false` | FIX ME NO DESCRIPTION |
|
|
16
16
|
| icon | `union` | `none` | `false` | FIX ME NO DESCRIPTION |
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
## methods
|
|
19
|
+
### onPress()
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
#### arguments
|
|
24
24
|
| Name | Type | Required | Description |
|
|
25
25
|
| ---- | :--: | :------: | :----------: |
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### symbolStyle()
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
#### arguments
|
|
34
34
|
| Name | Type | Required | Description |
|
|
35
35
|
| ---- | :--: | :------: | :----------: |
|
|
36
36
|
|
package/docs/Annotations.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# Annotations Comparison
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|-----------------------|--------------------|--------------------------------------|-------------------------|---------------------|
|
|
5
|
-
|Can use images | ✓ | | | |
|
|
6
|
-
|RN Views as childern | iOS: static |iOS: interactive <br/> android: static|interactive | |
|
|
7
|
-
|Interactions | click |iOS: full <br/> android: click & drag & callout | supports full interactivity in the sense that inside MarkerViews one can place any RN View, which can be interacted with. Not to be misunderstood with drag n drop interactivity. | click |
|
|
8
|
-
|Control Z-index | ✓ |iOS: always on top, android: n/a |always on top | ✓ |
|
|
9
|
-
|Clustering | ✓ | | | ✓ |
|
|
10
|
-
|Style with expressions | ✓ | | | ✓ |
|
|
11
|
-
|iOS implementation | [MGLStyleSymbolLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLSymbolStyleLayer.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLCircleStyleLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLCircleStyleLayer.html) |
|
|
12
|
-
|android implementation | [SymbolLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/SymbolLayer.html)|[annotation.Symbol](https://docs.mapbox.com/android/api/plugins/annotation/0.8.0/com/mapbox/mapboxsdk/plugins/annotation/Symbol.html)|[annotation.Marker](https://docs.mapbox.com/android/api/plugins/markerview/0.4.0/com/mapbox/mapboxsdk/plugins/markerview/MarkerView.html) |[CircleLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/CircleLayer.html)|
|
|
3
|
+
Comparsion of various annotations available in React native mapbox:
|
|
13
4
|
|
|
5
|
+
| *Feature* | *SymbolLayer* | *PointAnnotation* |*MarkerView* |*CircleLayer* |
|
|
6
|
+
|------------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|---------------------|
|
|
7
|
+
| Can use images | ✓ | | | |
|
|
8
|
+
| RN Views as children | iOS: static | iOS: interactive <br/> Android: static |interactive | |
|
|
9
|
+
| Interactions | click | iOS: full <br/> Android: click & drag & callout | supports full interactivity in the sense that inside MarkerViews one can place any RN View, which can be interacted with. Not to be misunderstood with drag n drop interactivity. | click |
|
|
10
|
+
| Control Z-index | ✓ | iOS: always on top, Android: n/a |always on top | ✓ |
|
|
11
|
+
| Clustering | ✓ | | | ✓ |
|
|
12
|
+
| Style with expressions | ✓ | | | ✓ |
|
|
13
|
+
| iOS implementation | [MGLStyleSymbolLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLSymbolStyleLayer.html) | [MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLAnnotationView](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLAnnotationView.html) |[MGLCircleStyleLayer](https://docs.mapbox.com/ios/api/maps/5.8.0/Classes/MGLCircleStyleLayer.html) |
|
|
14
|
+
| Android implementation | [SymbolLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/SymbolLayer.html)| [annotation.Symbol](https://docs.mapbox.com/android/api/plugins/annotation/0.8.0/com/mapbox/mapboxsdk/plugins/annotation/Symbol.html) |[annotation.Marker](https://docs.mapbox.com/android/api/plugins/markerview/0.4.0/com/mapbox/mapboxsdk/plugins/markerview/MarkerView.html) |[CircleLayer](https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/style/layers/CircleLayer.html)|
|
|
14
15
|
|
|
15
16
|
Related links:
|
|
17
|
+
|
|
16
18
|
* iOS [markers and annotations](https://docs.mapbox.com/ios/maps/overview/markers-and-annotations/)
|
|
17
|
-
*
|
|
19
|
+
* Android [annotation plugin](https://docs.mapbox.com/android/plugins/overview/annotation/)
|