@maplibre/maplibre-react-native 8.6.0-beta.0 → 8.6.0-beta.1
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/CONTRIBUTING.md +28 -8
- package/README.md +6 -138
- package/RELEASE.md +1 -1
- package/android/install.md +25 -10
- package/docs/GettingStarted.md +80 -36
- package/index.d.ts +1 -1
- package/ios/install.md +1 -3
- package/package.json +1 -1
- package/plugin/install.md +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
PRs are most welcome! This doc covers some basic things you'll need to know to set up
|
|
4
|
+
your dev environment and streamline the review process.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
- In your fork, create a branch, for example: `fix/camera-update`
|
|
7
|
-
- Add your changes
|
|
8
|
-
- Push and open a PR with your branch
|
|
6
|
+
## Environment Setup
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
This project includes `.nvmrc`. You should use nvm so that you're always developing for the correct
|
|
9
|
+
version of Node.
|
|
10
|
+
|
|
11
|
+
This project uses `yarn` as a package manager. DO NOT install `yarn` using `npm` as that will install
|
|
12
|
+
the outdated 1.x branch. Full instructions are in the [yarn docs](https://yarnpkg.com/getting-started/install),
|
|
13
|
+
but here's the quick checklist at the time of this writing.
|
|
14
|
+
|
|
15
|
+
1. `corepack enable`
|
|
16
|
+
2. `corepack prepare yarn@stable --activate`
|
|
17
|
+
3. On first install, the above may change your yarn config away from `pnp`; check your git working copy for changes and revert if necessary.
|
|
18
|
+
4. `yarn install`
|
|
19
|
+
|
|
20
|
+
## Testing
|
|
11
21
|
|
|
12
22
|
The metro bundler under `/example` is set up to use the libraries files under root.
|
|
13
23
|
Which means, when you change something within `javascript/components/UserLocation.js`
|
|
14
24
|
it will be reflected in any scene in example that uses that component.
|
|
15
25
|
|
|
26
|
+
TODO: A better overview of how we use jest, detox, etc. (issue #22)
|
|
27
|
+
|
|
28
|
+
## Optional: Local development with yalc
|
|
29
|
+
|
|
30
|
+
It is often desirable to test in the context of an external project (for example,
|
|
31
|
+
if you have a complex application using a map and want to test your changes directly).
|
|
32
|
+
While it's not easy to do this out of the box with `yarn` or `npm`.
|
|
33
|
+
[`yalc`](https://www.viget.com/articles/how-to-use-local-unpublished-node-packages-as-project-dependencies/)
|
|
34
|
+
can mitigate some of the pain with this.
|
|
35
|
+
|
|
36
|
+
|
|
16
37
|
## Best practices for PRs
|
|
17
38
|
|
|
18
39
|
- If you add a feature, make sure you add it to the documentation
|
|
@@ -20,7 +41,7 @@ it will be reflected in any scene in example that uses that component.
|
|
|
20
41
|
- Make sure to use small concise commits
|
|
21
42
|
- Use meaningful commit messages
|
|
22
43
|
- Make sure to update/ add new tests for your changes
|
|
23
|
-
- If you add a new feature make sure to add a scene in `/example` for others to see/ test it
|
|
44
|
+
- If you add a new feature, make sure to add a scene in `/example` for others to see/ test it
|
|
24
45
|
|
|
25
46
|
## Documentation
|
|
26
47
|
|
|
@@ -31,4 +52,3 @@ To manually generate the changes, run `npm run generate`.
|
|
|
31
52
|
|
|
32
53
|
Notice, that changing the documentation in the individual <COMPONENT>.md within `/docs` will not suffice.
|
|
33
54
|
The correct way is the above described
|
|
34
|
-
|
package/README.md
CHANGED
|
@@ -17,9 +17,7 @@ diverged, it has become necessary to separate the projects into specific wrapper
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[](https://badge.fury.io/js/%40react-native-mapbox-gl%2Fmaps)
|
|
20
|
+
[](https://badge.fury.io/js/%40maplibre%2Fmaplibre-react-native)
|
|
23
21
|
[](https://github.com/maplibre/maplibre-react-native/actions/workflows/android-actions.yml)
|
|
24
22
|
[](https://github.com/maplibre/maplibre-react-native/actions/workflows/ios-actions.yml)
|
|
25
23
|
|
|
@@ -36,103 +34,10 @@ _TODO: update NPM badge_
|
|
|
36
34
|
height="300"
|
|
37
35
|
/>
|
|
38
36
|
|
|
39
|
-
# Quickstart for app developers
|
|
40
|
-
|
|
41
|
-
## Prerequisites
|
|
42
|
-
|
|
43
|
-
1. On Android we support from version 6 (API 23) upwards
|
|
44
|
-
2. You will need a vector tile source (such as Stadia Maps or MapTiler) for production use; a demonstration URL is used in the below example.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## Dependencies
|
|
48
|
-
|
|
49
|
-
- [node](https://nodejs.org)
|
|
50
|
-
- [npm](https://www.npmjs.com/)
|
|
51
|
-
- [React Native](https://facebook.github.io/react-native/) (0.60+)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
### Step 1 - Install Package:
|
|
57
|
-
|
|
58
|
-
```sh
|
|
59
|
-
# install with Yarn
|
|
60
|
-
yarn add @maplibre/maplibre-react-native
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# or install with NPM
|
|
64
|
-
npm install @maplibre/maplibre-react-native --save
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Step 2 - Installation Guides:
|
|
68
|
-
|
|
69
|
-
- [Android](/android/install.md)
|
|
70
|
-
- [iOS](/ios/install.md)
|
|
71
|
-
- [Expo](/plugin/install.md)
|
|
72
|
-
- [Example](/example)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Getting Started
|
|
76
|
-
For more information, check out our [Getting Started](/docs/GettingStarted.md) section
|
|
77
|
-
|
|
78
|
-
## Run Project
|
|
79
|
-
Before you run your project be sure you have completed the Installation Guides for Android or iOS.
|
|
80
|
-
|
|
81
|
-
### Run iOS Simulator
|
|
82
|
-
```sh
|
|
83
|
-
# Run with yarn
|
|
84
|
-
yarn run ios
|
|
85
|
-
|
|
86
|
-
# or Run with NPM
|
|
87
|
-
npm run ios
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Run Android Emulator
|
|
91
|
-
```sh
|
|
92
|
-
# Run with yarn
|
|
93
|
-
yarn run android
|
|
94
|
-
|
|
95
|
-
# or Run with NPM
|
|
96
|
-
npm run android
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Adding a map
|
|
100
|
-
|
|
101
|
-
```js
|
|
102
|
-
import React, {Component} from 'react';
|
|
103
|
-
import {StyleSheet, View} from 'react-native';
|
|
104
|
-
import MapboxGL from '@maplibre/maplibre-react-native';
|
|
105
|
-
|
|
106
|
-
const styles = StyleSheet.create({
|
|
107
|
-
page: {
|
|
108
|
-
flex: 1,
|
|
109
|
-
justifyContent: 'center',
|
|
110
|
-
alignItems: 'center',
|
|
111
|
-
backgroundColor: '#F5FCFF',
|
|
112
|
-
},
|
|
113
|
-
map: {
|
|
114
|
-
flex: 1,
|
|
115
|
-
alignSelf: 'stretch',
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
export default class App extends Component {
|
|
120
|
-
render() {
|
|
121
|
-
return (
|
|
122
|
-
<View style={styles.page}>
|
|
123
|
-
<MapboxGL.MapView
|
|
124
|
-
style={styles.map}
|
|
125
|
-
logoEnabled={false}
|
|
126
|
-
styleURL="https://demotiles.maplibre.org/style.json"
|
|
127
|
-
/>
|
|
128
|
-
</View>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
37
|
## Documentation
|
|
135
38
|
|
|
39
|
+
[Getting Started (start here)](/docs/GettingStarted.md)
|
|
40
|
+
|
|
136
41
|
### Components
|
|
137
42
|
|
|
138
43
|
- [MapView](/docs/MapView.md)
|
|
@@ -177,48 +82,11 @@ export default class App extends Component {
|
|
|
177
82
|
|
|
178
83
|
This package is not available in the [Expo Go](https://expo.io/client) app. Learn how you can use it with [custom dev clients](/plugin/install.md).
|
|
179
84
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## Environment Setup
|
|
183
|
-
|
|
184
|
-
This project includes `.nvmrc`. You should use nvm so that you're always developing for the correct
|
|
185
|
-
version of Node.
|
|
186
|
-
|
|
187
|
-
This project uses `yarn` as a package manager. DO NOT install `yarn` using `npm` as that will install
|
|
188
|
-
the outdated 1.x branch. Full instructions are in the [yarn docs](https://yarnpkg.com/getting-started/install),
|
|
189
|
-
but here's the quick checklist at the time of this writing.
|
|
190
|
-
|
|
191
|
-
1. `corepack enable`
|
|
192
|
-
2. `corepack prepare yarn@stable --activate`
|
|
193
|
-
3. On first install, the above may change your yarn config away from `pnp`; check your git working copy for changes and revert if necessary.
|
|
194
|
-
4. `yarn install`
|
|
195
|
-
|
|
196
|
-
### JetBrains IDE Setup
|
|
197
|
-
|
|
198
|
-
Your JetBrains IDE (such as IntelliJ) needs to be set to use yarn under Preferences > Languages & Frameworks > Node.js.
|
|
199
|
-
This may require a manual change if you did not have yarn previously installed.
|
|
200
|
-
|
|
201
|
-
## Testing with Jest
|
|
202
|
-
|
|
203
|
-
This library provides some mocks which are necessary for running tests.
|
|
204
|
-
|
|
205
|
-
Example:
|
|
206
|
-
|
|
207
|
-
```json
|
|
208
|
-
"jest": {
|
|
209
|
-
"preset": "react-native",
|
|
210
|
-
"setupFilesAfterEnv": ["@maplibre/maplibre-react-native/setup-jest"]
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
## Optional: Local development with yalc
|
|
85
|
+
## Contributing / local development
|
|
215
86
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
[`yalc`](https://www.viget.com/articles/how-to-use-local-unpublished-node-packages-as-project-dependencies/)
|
|
219
|
-
can mitigate some of the pain with this.
|
|
87
|
+
Read the [CONTRIBUTING.md](CONTRIBUTING.md) guide in order to get familiar with how we do things around here and
|
|
88
|
+
set up your local dev environment.
|
|
220
89
|
|
|
221
90
|
## Community
|
|
222
91
|
|
|
223
92
|
Join the #maplibre-native Slack channel at OSMUS: get an invite at https://slack.openstreetmap.us/
|
|
224
|
-
Read the [CONTRIBUTING.md](CONTRIBUTING.md) guide in order to get familiar with how we do things around here.
|
package/RELEASE.md
CHANGED
|
@@ -11,7 +11,7 @@ Once you verified, that `master` isn't broken, go on and increase the `version`
|
|
|
11
11
|
|
|
12
12
|
## Update the CHANGELOG accordingly
|
|
13
13
|
|
|
14
|
-
Our [`CHANGELOG.md`](https://github.com/maplibre/maplibre-react-native/blob/master/CHANGELOG.md) should be updated whenever a PR is merged/ noteworthy changes are
|
|
14
|
+
Our [`CHANGELOG.md`](https://github.com/maplibre/maplibre-react-native/blob/master/CHANGELOG.md) should be updated whenever a PR is merged/ noteworthy changes are committed to `master`.
|
|
15
15
|
Prior to a release, the changes should be documented under the `UNRELEASED` section.
|
|
16
16
|
Once it's clear, that a release is about to be published, move the items under `UNRELEASED` to _this_ releases sections.
|
|
17
17
|
Let your actions be guided by the previous release entries.
|
package/android/install.md
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
# Android Installation
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
special installation is required!
|
|
3
|
+
## Access tokens
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
most users (non-Mapbox-users). Simply add something like this near
|
|
12
|
-
the top of your `App.js`.
|
|
5
|
+
Note that the Android SDK is slightly peculiar in that it
|
|
6
|
+
_requires_ setting an access token, even though it will be `null` for
|
|
7
|
+
most users (only Mapbox authenticates this way). Even if it feels odd,
|
|
8
|
+
you have to have a line like this in your code before using the SDK.
|
|
9
|
+
You can put this near the top of your `App.js` for convenience.
|
|
13
10
|
|
|
14
11
|
```javascript
|
|
15
12
|
MapboxGL.setAccessToken(null);
|
|
16
|
-
```
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setting connection status
|
|
16
|
+
|
|
17
|
+
TODO: check if this is still an issue with MapLibre Native on Android (issue #21).
|
|
18
|
+
|
|
19
|
+
If you are hosting styles and sources on localhost, you might need to set
|
|
20
|
+
the connection status manually for the SDK to be able to use them.
|
|
21
|
+
See [mapbox/mapbox-gl-native#12819](https://github.com/mapbox/mapbox-gl-native/issues/12819).
|
|
22
|
+
|
|
23
|
+
Manually sets the connectivity state of the app, bypassing any checks to the
|
|
24
|
+
`ConnectivityManager`. Set to `true` for connected, `false` for disconnected,
|
|
25
|
+
and `null` for the normal `ConnectivityManager` behavior.
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import MapboxGL from "@maplibre/maplibre-react-native";
|
|
29
|
+
|
|
30
|
+
MapboxGL.setConnected(true);
|
|
31
|
+
```
|
package/docs/GettingStarted.md
CHANGED
|
@@ -1,72 +1,116 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
3
|
Congratulations, you successfully installed maplibre-react-native! 🎉
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
However, if you prefer an easier ramp-up, then make sure to stick around and check out the guides below.
|
|
4
|
+
This quickstart guide provides a zero-to-map intro, and from there you can check out the
|
|
5
|
+
[examples](/example) folder if you want to jump in the deep end.
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Prerequisites
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
1. On Android we support API 23 and higher
|
|
10
|
+
2. You will need a vector tile source (such as Stadia Maps or MapTiler) for production use; a demonstration URL is used in the below example.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
If you haven't created one yet, make sure to sign up for an account [here](https://www.mapbox.com/signup/)
|
|
14
|
-
You can create and manage your access tokens on your [Mapbox Account page](https://www.mapbox.com/account/)
|
|
15
|
-
Once you have your accessToken, set it like this
|
|
12
|
+
## Dependencies
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
- [node](https://nodejs.org)
|
|
15
|
+
- [npm](https://www.npmjs.com/)
|
|
16
|
+
- [React Native](https://facebook.github.io/react-native/) (0.60+)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### Step 0: Set up a React Native project
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
If you don't have an existing React Native project, create one:
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
npx react-native init MyApp --version 0.68
|
|
21
26
|
```
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
TODO: See if latest version works
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
### Install Package
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
From your React Native project's root directory, add the package via
|
|
33
|
+
either `yarn` or `npm` (pick one).
|
|
28
34
|
|
|
29
|
-
```
|
|
30
|
-
|
|
35
|
+
```shell
|
|
36
|
+
# install with Yarn
|
|
37
|
+
yarn add @maplibre/maplibre-react-native
|
|
38
|
+
|
|
39
|
+
```
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
```shell
|
|
42
|
+
# install with NPM
|
|
43
|
+
npm install @maplibre/maplibre-react-native --save
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
### Review platform specific info
|
|
47
|
+
|
|
48
|
+
Check out the installation guide(s) for additional information about platform-specific setup, quirks,
|
|
49
|
+
and steps requried before running.
|
|
50
|
+
|
|
51
|
+
- [Android](/android/install.md)
|
|
52
|
+
- [iOS](/ios/install.md)
|
|
53
|
+
- [Expo](/plugin/install.md)
|
|
54
|
+
|
|
55
|
+
## Adding a map
|
|
56
|
+
|
|
57
|
+
Here is an example minimal App.js
|
|
36
58
|
|
|
37
59
|
```js
|
|
38
|
-
import React, {
|
|
39
|
-
import {
|
|
40
|
-
import MapboxGL from
|
|
60
|
+
import React, {Component} from 'react';
|
|
61
|
+
import {StyleSheet, View} from 'react-native';
|
|
62
|
+
import MapboxGL from '@maplibre/maplibre-react-native';
|
|
41
63
|
|
|
42
|
-
|
|
64
|
+
// Will be null for most users (only Mapbox authenticates this way).
|
|
65
|
+
// Required on Android. See Android installation notes.
|
|
66
|
+
MapboxGL.setAccessToken(null);
|
|
43
67
|
|
|
44
68
|
const styles = StyleSheet.create({
|
|
45
69
|
page: {
|
|
46
70
|
flex: 1,
|
|
47
|
-
justifyContent:
|
|
48
|
-
alignItems:
|
|
49
|
-
backgroundColor:
|
|
50
|
-
},
|
|
51
|
-
container: {
|
|
52
|
-
height: 300,
|
|
53
|
-
width: 300,
|
|
54
|
-
backgroundColor: "tomato"
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
backgroundColor: '#F5FCFF',
|
|
55
74
|
},
|
|
56
75
|
map: {
|
|
57
|
-
flex: 1
|
|
58
|
-
|
|
76
|
+
flex: 1,
|
|
77
|
+
alignSelf: 'stretch',
|
|
78
|
+
},
|
|
59
79
|
});
|
|
60
80
|
|
|
61
81
|
export default class App extends Component {
|
|
62
82
|
render() {
|
|
63
83
|
return (
|
|
64
84
|
<View style={styles.page}>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
<MapboxGL.MapView
|
|
86
|
+
style={styles.map}
|
|
87
|
+
logoEnabled={false}
|
|
88
|
+
styleURL="https://demotiles.maplibre.org/style.json"
|
|
89
|
+
/>
|
|
68
90
|
</View>
|
|
69
91
|
);
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
```
|
|
95
|
+
|
|
96
|
+
## Run it!
|
|
97
|
+
|
|
98
|
+
### iOS
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
# Run with yarn
|
|
102
|
+
yarn run ios
|
|
103
|
+
|
|
104
|
+
# or Run with NPM
|
|
105
|
+
npm run ios
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Android
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
# Run with yarn
|
|
112
|
+
yarn run android
|
|
113
|
+
|
|
114
|
+
# or Run with NPM
|
|
115
|
+
npm run android
|
|
116
|
+
```
|
package/index.d.ts
CHANGED
package/ios/install.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# iOS Installation
|
|
2
2
|
|
|
3
3
|
The following assumes, that you're using autolinking and installed
|
|
4
|
-
|
|
5
|
-
|
|
6
4
|
`@maplibre/maplibre-react-native` via `npm` or `yarn`.
|
|
7
5
|
|
|
8
6
|
Add the following to your `ios/Podfile`:
|
|
@@ -17,7 +15,7 @@ Add the following to your `ios/Podfile`:
|
|
|
17
15
|
Running `pod install` will add version `5.12.2` of the MapLibre SDK.
|
|
18
16
|
|
|
19
17
|
```sh
|
|
20
|
-
# Go to the ios
|
|
18
|
+
# Go to the ios directory
|
|
21
19
|
cd ios
|
|
22
20
|
|
|
23
21
|
# Run Pod Install
|
package/package.json
CHANGED
package/plugin/install.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/).
|
|
4
4
|
|
|
5
|
-
First install the package with yarn
|
|
5
|
+
First install the package with `yarn`, `npm`, or [`expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install).
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
expo install @maplibre/maplibre-react-native
|