@ohos-ports/mapbox-gl-directions 0.0.0-stage → 4.3.3-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.
Files changed (50) hide show
  1. package/.babelrc +6 -0
  2. package/.claude/settings.local.json +26 -0
  3. package/.eslintrc +30 -0
  4. package/.github/workflows/ci.yml +73 -0
  5. package/.nvmrc +1 -0
  6. package/API.md +276 -0
  7. package/CHANGELOG.md +128 -0
  8. package/CONTRIBUTING.md +25 -0
  9. package/LICENSE +15 -0
  10. package/README.md +56 -2
  11. package/dist/mapbox-gl-directions.css +503 -0
  12. package/dist/mapbox-gl-directions.js +8899 -0
  13. package/example/index.js +51 -0
  14. package/package.json +79 -4
  15. package/src/actions/index.js +369 -0
  16. package/src/constants/action_types.js +17 -0
  17. package/src/controls/geocoder.js +279 -0
  18. package/src/controls/inputs.js +150 -0
  19. package/src/controls/instructions.js +95 -0
  20. package/src/directions.js +614 -0
  21. package/src/directions_style.js +177 -0
  22. package/src/icons/arrive.svg +1 -0
  23. package/src/icons/bear-left.svg +1 -0
  24. package/src/icons/bear-right.svg +1 -0
  25. package/src/icons/continue.svg +1 -0
  26. package/src/icons/depart.svg +1 -0
  27. package/src/icons/enter-roundabout.svg +1 -0
  28. package/src/icons/error.svg +1 -0
  29. package/src/icons/reverse.svg +1 -0
  30. package/src/icons/sharp-left.svg +1 -0
  31. package/src/icons/sharp-right.svg +1 -0
  32. package/src/icons/turn-left.svg +1 -0
  33. package/src/icons/turn-right.svg +1 -0
  34. package/src/icons/u-turn.svg +1 -0
  35. package/src/icons/waypoint.svg +1 -0
  36. package/src/index.js +3 -0
  37. package/src/mapbox-gl-directions.css +503 -0
  38. package/src/reducers/index.js +152 -0
  39. package/src/templates/error.html +5 -0
  40. package/src/templates/inputs.html +58 -0
  41. package/src/templates/instructions.html +52 -0
  42. package/src/utils.js +82 -0
  43. package/test/index.js +28 -0
  44. package/test/test.directions.js +96 -0
  45. package/test/test.geocoder.js +74 -0
  46. package/test/test.inputs.js +34 -0
  47. package/test/test.instructions.js +128 -0
  48. package/test/test.options.js +36 -0
  49. package/test/test.utils.js +17 -0
  50. package/test/utils/setup.js +37 -0
package/.babelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env"
4
+ ],
5
+ "plugins": ["transform-inline-environment-variables"]
6
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npx eslint *)",
5
+ "Bash(node *)",
6
+ "Bash(echo \"exit:$?\")",
7
+ "Bash(npm install *)",
8
+ "Bash(npm run *)",
9
+ "Bash(MapboxAccessToken=dummy npx browserify test/index.js -o /dev/null)",
10
+ "Bash(MapboxAccessToken=dummy npx browserify test/index.js -o /private/tmp/claude-501/-Users-isaacbesora-Documents-workspace-mapbox-gl-directions/707869d0-e6de-468f-8e51-20683fa291a1/scratchpad/bundle.js)",
11
+ "Bash(git check-ignore *)",
12
+ "Bash(git checkout *)",
13
+ "Read(//Users/isaacbesora/Documents/workspace/mapbox-sdk/.github/workflows/**)",
14
+ "Read(//Users/isaacbesora/Documents/workspace/mapbox-sdk/**)",
15
+ "Bash(python3 -c \"import yaml; yaml.safe_load\\(open\\('.circleci/config.yml'\\)\\)\")",
16
+ "Bash(python3 -c \"import yaml; yaml.safe_load\\(open\\('.github/workflows/ci.yml'\\)\\)\")",
17
+ "Bash(pip3 install *)",
18
+ "Bash(python3 -c \"import yaml; print\\('circleci', bool\\(yaml.safe_load\\(open\\('.circleci/config.yml'\\)\\)\\)\\); print\\('gha', bool\\(yaml.safe_load\\(open\\('.github/workflows/ci.yml'\\)\\)\\)\\)\")",
19
+ "Bash(npx tape *)",
20
+ "Bash(export MapboxAccessToken=pk.eyJ1IjoiaWJlc29yYS1tYXBib3giLCJhIjoiY202aHc2c2pkMDF4OTJqcXd4NnJodmdxMiJ9.ZnNRSmVKpZ67wZ7_nDhhGg)",
21
+ "Bash(npm test *)",
22
+ "Bash(timeout 30 npx browserify test/index.js -o /tmp/bundle.js)",
23
+ "Bash(echo \"EXIT:$?\")"
24
+ ]
25
+ }
26
+ }
package/.eslintrc ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "parser": "@babel/eslint-parser",
3
+ "env": {
4
+ "node": true,
5
+ "browser": true
6
+ },
7
+ "globals": {
8
+ "mapboxgl": true,
9
+ "fs": true
10
+ },
11
+ "rules": {
12
+ "strict": [0],
13
+ "curly": [0],
14
+ "no-new": [0],
15
+ "no-alert": [0],
16
+ "no-extra-bind": [0],
17
+ "no-redeclare": [1],
18
+ "new-cap": [0],
19
+ "quotes": [2, "single"],
20
+ "eol-last": [0],
21
+ "no-mixed-requires": [0],
22
+ "no-path-concat": [0],
23
+ "camelcase": [0],
24
+ "consistent-return": [0],
25
+ "no-underscore-dangle": [0],
26
+ "comma-spacing": [0],
27
+ "key-spacing": [0],
28
+ "no-use-before-define": [0]
29
+ }
30
+ }
@@ -0,0 +1,73 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 5
13
+
14
+ steps:
15
+ - uses: actions/checkout@v7
16
+
17
+ - uses: actions/setup-node@v6
18
+ with:
19
+ node-version-file: '.nvmrc'
20
+ cache: 'npm'
21
+
22
+ - run: npm ci
23
+
24
+ - run: npm run build
25
+
26
+ - uses: actions/upload-artifact@v7
27
+ with:
28
+ name: dist
29
+ path: dist
30
+ retention-days: 7
31
+
32
+ lint:
33
+ runs-on: ubuntu-latest
34
+ timeout-minutes: 5
35
+
36
+ steps:
37
+ - uses: actions/checkout@v7
38
+
39
+ - uses: actions/setup-node@v6
40
+ with:
41
+ node-version-file: '.nvmrc'
42
+ cache: 'npm'
43
+
44
+ - run: npm ci
45
+
46
+ - run: npm run lint
47
+
48
+ test:
49
+ runs-on: ubuntu-latest
50
+ timeout-minutes: 5
51
+
52
+ steps:
53
+ - uses: actions/checkout@v7
54
+
55
+ - uses: actions/setup-node@v6
56
+ with:
57
+ node-version-file: '.nvmrc'
58
+ cache: 'npm'
59
+
60
+ - run: npm ci
61
+
62
+ - name: Install Firefox
63
+ run: |
64
+ sudo apt-get update
65
+ sudo apt-get install -y firefox
66
+
67
+ - name: Run tests with Smokestack and Firefox
68
+ env:
69
+ MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
70
+ run: |
71
+ export DISPLAY=:99
72
+ Xvfb :99 -screen 0 1024x768x24 2> /dev/null &
73
+ npm test
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 24
package/API.md ADDED
@@ -0,0 +1,276 @@
1
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2
+
3
+ ### Table of Contents
4
+
5
+ * [MapboxDirections][1]
6
+ * [Parameters][2]
7
+ * [Examples][3]
8
+ * [onRemove][4]
9
+ * [Parameters][5]
10
+ * [interactive][6]
11
+ * [Parameters][7]
12
+ * [getOrigin][8]
13
+ * [setOrigin][9]
14
+ * [Parameters][10]
15
+ * [getDestination][11]
16
+ * [setDestination][12]
17
+ * [Parameters][13]
18
+ * [reverse][14]
19
+ * [addWaypoint][15]
20
+ * [Parameters][16]
21
+ * [setWaypoint][17]
22
+ * [Parameters][18]
23
+ * [removeWaypoint][19]
24
+ * [Parameters][20]
25
+ * [getWaypoints][21]
26
+ * [removeRoutes][22]
27
+ * [on][23]
28
+ * [Parameters][24]
29
+
30
+ ## MapboxDirections
31
+
32
+ The Directions control
33
+
34
+ ### Parameters
35
+
36
+ * `options` **[Object][25]**&#x20;
37
+
38
+ * `options.styles` **[Array][26]?** Override default layer properties of the [directions source][27]. Documentation for each property are specified in the [Mapbox GL Style Reference][28].
39
+ * `options.accessToken` **[String][29]** Required unless `mapboxgl.accessToken` is set globally (optional, default `null`)
40
+ * `options.api` **[String][29]** Override default routing endpoint url (optional, default `"https://api.mapbox.com/directions/v5/"`)
41
+ * `options.interactive` **[Boolean][30]** Enable/Disable mouse or touch interactivity from the plugin (optional, default `true`)
42
+ * `options.profile` **[String][29]** Routing profile to use. Options: `mapbox/driving-traffic`, `mapbox/driving`, `mapbox/walking`, `mapbox/cycling` (optional, default `"mapbox/driving-traffic"`)
43
+ * `options.alternatives` **[Boolean][30]** Whether to enable alternatives. (optional, default `false`)
44
+ * `options.congestion` **[Boolean][30]** Whether to enable congestion along the route line. (optional, default `false`)
45
+ * `options.unit` **[String][29]** Measurement system to be used in navigation instructions. Options: `imperial`, `metric` (optional, default `"imperial"`)
46
+ * `options.compile` **[Function][31]** Provide a custom function for generating instruction, compatible with osrm-text-instructions. (optional, default `null`)
47
+ * `options.geocoder` **[Object][25]?** Accepts an object containing the query parameters as [documented here][32].
48
+ * `options.controls` **[Object][25]?**&#x20;
49
+
50
+ * `options.controls.inputs` **[Boolean][30]** Hide or display the inputs control. (optional, default `true`)
51
+ * `options.controls.instructions` **[Boolean][30]** Hide or display the instructions control. (optional, default `true`)
52
+ * `options.controls.profileSwitcher` **[Boolean][30]** Hide or display the default profile switch with options for traffic, driving, walking and cycling. (optional, default `true`)
53
+ * `options.instructions` **[Object][25]?**&#x20;
54
+
55
+ * `options.instructions.showWaypointInstructions` **[Boolean][30]** Hide or display instructions for waypoints in the route (optional, default `true`)
56
+ * `options.zoom` **[Number][33]** If no bbox exists from the geocoder result, the zoom you set here will be used in the flyTo. (optional, default `16`)
57
+ * `options.language` **[String][29]** The language of returned turn-by-turn text instructions. See supported languages : [https://docs.mapbox.com/api/navigation/#instructions-languages][34] (optional, default `"en"`)
58
+ * `options.placeholderOrigin` **[String][29]** If set, this text will appear as the placeholder attribute for the origin input element. (optional, default `"Choose a starting place"`)
59
+ * `options.placeholderDestination` **[String][29]** If set, this text will appear as the placeholder attribute for the destination input element. (optional, default `"Choose destination"`)
60
+ * `options.flyTo` **[Boolean][30]** If false, animating the map to a selected result is disabled. (optional, default `true`)
61
+ * `options.exclude` **[String][29]** Exclude certain road types from routing. The default is to not exclude anything. Search for `exclude` in `optional parameters`: [https://docs.mapbox.com/api/navigation/#retrieve-directions][35] (optional, default `null`)
62
+ * `options.routePadding` **([number][33] | PaddingOptions)** Specify padding surrounding route. A single number of pixels or a [PaddingOptions][36] object. (optional, default `80`)
63
+
64
+ ### Examples
65
+
66
+ ```javascript
67
+ var MapboxDirections = require('../src/index');
68
+ var directions = new MapboxDirections({
69
+ accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
70
+ unit: 'metric',
71
+ profile: 'mapbox/cycling'
72
+ });
73
+ // add to your mapboxgl map
74
+ map.addControl(directions);
75
+ ```
76
+
77
+ Returns **[MapboxDirections][1]** `this`
78
+
79
+ ### onRemove
80
+
81
+ Removes the control from the map it has been added to. This is called by `map.removeControl`,
82
+ which is the recommended method to remove controls.
83
+
84
+ #### Parameters
85
+
86
+ * `map` &#x20;
87
+
88
+ Returns **Control** `this`
89
+
90
+ ### interactive
91
+
92
+ Turn on or off interactivity
93
+
94
+ #### Parameters
95
+
96
+ * `state` **[Boolean][30]** sets interactivity based on a state of `true` or `false`.
97
+
98
+ Returns **[MapboxDirections][1]** this
99
+
100
+ ### getOrigin
101
+
102
+ Returns the origin of the current route.
103
+
104
+ Returns **[Object][25]** origin
105
+
106
+ ### setOrigin
107
+
108
+ Sets origin. *Note:* calling this method requires the [map load event][37]
109
+ to have run.
110
+
111
+ #### Parameters
112
+
113
+ * `query` **([Array][26]<[number][33]> | [String][29])** An array of coordinates \[lng, lat] or location name as a string.
114
+
115
+ Returns **[MapboxDirections][1]** this
116
+
117
+ ### getDestination
118
+
119
+ Returns the destination of the current route.
120
+
121
+ Returns **[Object][25]** destination
122
+
123
+ ### setDestination
124
+
125
+ Sets destination. *Note:* calling this method requires the [map load event][37]
126
+ to have run.
127
+
128
+ #### Parameters
129
+
130
+ * `query` **([Array][26]<[number][33]> | [String][29])** An array of coordinates \[lng, lat] or location name as a string.
131
+
132
+ Returns **[MapboxDirections][1]** this
133
+
134
+ ### reverse
135
+
136
+ Swap the origin and destination.
137
+
138
+ Returns **[MapboxDirections][1]** this
139
+
140
+ ### addWaypoint
141
+
142
+ Add a waypoint to the route. *Note:* calling this method requires the
143
+ [map load event][37] to have run.
144
+
145
+ #### Parameters
146
+
147
+ * `index` **[Number][33]** position waypoint should be placed in the waypoint array
148
+ * `waypoint` **([Array][26]<[number][33]> | Point)** can be a GeoJSON Point Feature or \[lng, lat] coordinates.
149
+
150
+ Returns **[MapboxDirections][1]** this;
151
+
152
+ ### setWaypoint
153
+
154
+ Change the waypoint at a given index in the route. *Note:* calling this
155
+ method requires the [map load event][37]
156
+ to have run.
157
+
158
+ #### Parameters
159
+
160
+ * `index` **[Number][33]** indexed position of the waypoint to update
161
+ * `waypoint` **([Array][26]<[number][33]> | Point)** can be a GeoJSON Point Feature or \[lng, lat] coordinates.
162
+
163
+ Returns **[MapboxDirections][1]** this;
164
+
165
+ ### removeWaypoint
166
+
167
+ Remove a waypoint from the route.
168
+
169
+ #### Parameters
170
+
171
+ * `index` **[Number][33]** position in the waypoints array.
172
+
173
+ Returns **[MapboxDirections][1]** this;
174
+
175
+ ### getWaypoints
176
+
177
+ Fetch all current waypoints in a route.
178
+
179
+ Returns **[Array][26]** waypoints
180
+
181
+ ### removeRoutes
182
+
183
+ Removes all routes and waypoints from the map.
184
+
185
+ Returns **[MapboxDirections][1]** this;
186
+
187
+ ### on
188
+
189
+ Subscribe to events that happen within the plugin.
190
+
191
+ #### Parameters
192
+
193
+ * `type` **[String][29]** name of event. Available events and the data passed into their respective event objects are:* **clear** `{ type: } Type is one of 'origin' or 'destination'`
194
+ * **loading** `{ type: } Type is one of 'origin' or 'destination'`
195
+ * **profile** `{ profile } Profile is one of 'driving', 'walking', or 'cycling'`
196
+ * **origin** `{ feature } Fired when origin is set`
197
+ * **destination** `{ feature } Fired when destination is set`
198
+ * **route** `{ route } Fired when a route is updated`
199
+ * **error** `{ error } Error as string`
200
+ * `fn` **[Function][31]** function that's called when the event is emitted.
201
+
202
+ Returns **[MapboxDirections][1]** this;
203
+
204
+ [1]: #mapboxdirections
205
+
206
+ [2]: #parameters
207
+
208
+ [3]: #examples
209
+
210
+ [4]: #onremove
211
+
212
+ [5]: #parameters-1
213
+
214
+ [6]: #interactive
215
+
216
+ [7]: #parameters-2
217
+
218
+ [8]: #getorigin
219
+
220
+ [9]: #setorigin
221
+
222
+ [10]: #parameters-3
223
+
224
+ [11]: #getdestination
225
+
226
+ [12]: #setdestination
227
+
228
+ [13]: #parameters-4
229
+
230
+ [14]: #reverse
231
+
232
+ [15]: #addwaypoint
233
+
234
+ [16]: #parameters-5
235
+
236
+ [17]: #setwaypoint
237
+
238
+ [18]: #parameters-6
239
+
240
+ [19]: #removewaypoint
241
+
242
+ [20]: #parameters-7
243
+
244
+ [21]: #getwaypoints
245
+
246
+ [22]: #removeroutes
247
+
248
+ [23]: #on
249
+
250
+ [24]: #parameters-8
251
+
252
+ [25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
253
+
254
+ [26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
255
+
256
+ [27]: https://github.com/mapbox/mapbox-gl-directions/blob/main/src/directions_style.js
257
+
258
+ [28]: https://www.mapbox.com/mapbox-gl-style-spec/
259
+
260
+ [29]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
261
+
262
+ [30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
263
+
264
+ [31]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
265
+
266
+ [32]: https://www.mapbox.com/api-documentation/#search-for-places
267
+
268
+ [33]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
269
+
270
+ [34]: https://docs.mapbox.com/api/navigation/#instructions-languages
271
+
272
+ [35]: https://docs.mapbox.com/api/navigation/#retrieve-directions
273
+
274
+ [36]: https://docs.mapbox.com/mapbox-gl-js/api/#paddingoptions
275
+
276
+ [37]: https://www.mapbox.com/mapbox-gl-js/api/#Map.load
package/CHANGELOG.md ADDED
@@ -0,0 +1,128 @@
1
+ ## 4.3.3
2
+ - [bug] Fix unsanitized `place_name` rendering
3
+
4
+ ## 4.3.2
5
+ - [bug] Fix lodash vulnerabilities
6
+
7
+ ## 4.3.1
8
+
9
+ - [internal] Improve performance of marker dragging [#316](https://github.com/mapbox/mapbox-gl-directions/pull/316)
10
+
11
+ ## 4.3.0
12
+
13
+ - [feature] Added option `instructions.showWaypointInstructions` to control displaying of waypoint instructions [#313](https://github.com/mapbox/mapbox-gl-directions/pull/313)
14
+
15
+ ## 4.2.0
16
+
17
+ - [feature] Display waypoints-related instructions [#310](https://github.com/mapbox/mapbox-gl-directions/pull/310)
18
+ - [chore] Update mapbox-gl peer dependency to support version 3 [#310](https://github.com/mapbox/mapbox-gl-directions/pull/310)
19
+ - [chore] Fixed launching of tests [#310](https://github.com/mapbox/mapbox-gl-directions/pull/310)
20
+
21
+ ## 4.1.2
22
+
23
+ - [chore] Update mapbox-gl peer dependency version [#298](https://github.com/mapbox/mapbox-gl-directions/pull/298)
24
+
25
+ ## 4.1.1
26
+
27
+ - [bug] Exclude `options.api` from query params [#266](https://github.com/mapbox/mapbox-gl-directions/pull/266)
28
+ - [bug] Catch 'No Route found' response [#278](https://github.com/mapbox/mapbox-gl-directions/pull/278)
29
+ * [bug] Abort request after `removeRoutes()` is called [#285](https://github.com/mapbox/mapbox-gl-directions/pull/285)
30
+ * [bug] Fix mixed duration and distance values [#271](https://github.com/mapbox/mapbox-gl-directions/pull/271)
31
+
32
+ ## 4.1.0
33
+ - Adds routePadding option to MapboxDirections object [#243](https://github.com/mapbox/mapbox-gl-directions/pull/243)
34
+ - Fixes bug that showed dropdown suggestions when reversing route [#246](https://github.com/mapbox/mapbox-gl-directions/pull/246)
35
+
36
+ ## 4.0.3
37
+ - Adds exclude parameter [#233](https://github.com/mapbox/mapbox-gl-directions/pull/233)
38
+
39
+ ## 4.0.2
40
+ - Adds language parameter to allow turn-by-turn instructions in other [supported languages](https://docs.mapbox.com/api/navigation/#instructions-languages)
41
+
42
+ ## 4.0.1
43
+ - Update packages to resolve polyline dependency
44
+ - Update peerDependency for Mapbox-GL-JS to support v1.0 release
45
+ - Switch to `yarn` to workaround `sockjs-client` dependency issue
46
+
47
+ ## 4.0.0
48
+ - [Refactor] options passed to internal Geocoder class
49
+ - Made options.geocoder dynamic, accepting only query parameters from the Geocoding API
50
+ - Removed placeholder option in favor of placeholderOrigin and placeholderDestination
51
+ - Added top level options flyTo, zoom, placeholderOrigin and placeholderDestination
52
+ - [Chore] Update packages to resolve vulnerabilities in smokestack
53
+
54
+ ## 3.1.3
55
+ - [bug] Bump package `suggestions` to support autocompletion on quick keypress.[#179](https://github.com/mapbox/mapbox-gl-directions/pull/179)
56
+
57
+ ## 3.1.2
58
+ - [workaround] Include `/dist` directory in published NPM package
59
+
60
+ ## 3.1.1
61
+
62
+ - [bug] Fixes css for turn instruction icons
63
+
64
+ ## 3.1.0
65
+
66
+ - [internal] upgrade to v5 of the Mapbox Directions API
67
+ - [feature] add traffic aware driving directions profile
68
+
69
+ ## 3.0.3
70
+
71
+ - [bug] re-enable hiding instructions panel [#101](https://github.com/mapbox/mapbox-gl-directions/issues/101)
72
+
73
+ ## 3.0.2
74
+
75
+ - [bug] Fixing a fix for `3.0.1`. Missed a single space.
76
+
77
+ ## 3.0.1
78
+
79
+ - [bug] CSS fix for departure/arrival icons that were not center aligned because of global line-height properties
80
+
81
+ ## 3.0.0
82
+
83
+ Support for the Mapbox GL JS 0.27.0 API. This is compatible with 0.27.0 and later, and not compatible with earlier versions.
84
+
85
+ - [breaking] `container` option removed - attaching the control outside of the map is no longer supported
86
+ - [breaking] `position` option removed - the `addControl` method now specifies the position
87
+ - [breaking] Now exports `MapboxDirections` rather than attaches to `mapbox.Directions`
88
+ - [internal] no longer creates a new map control for each of the two geocoders, instead creates two internal geocoders
89
+ - [feature] `removeRoutes` method that removes all route lines, waypoints, and instructions
90
+
91
+ ## 2.2.0
92
+ - [feature] Defer mapboxgl dependency til runtime to support webpack async loading #86 https://github.com/mapbox/mapbox-gl-directions/pull/86
93
+ - [bug] Fix mapboxgl.GeoJSONSource deprecation in gl-js v.22 and map.load race condition
94
+
95
+ ## 2.1.0
96
+
97
+ - [bug] Warn if mapboxgl is not present [#66](https://github.com/mapbox/mapbox-gl-directions/issues/66)
98
+ - [bug] Point `main` in `package.json` to transpiled result [#63](https://github.com/mapbox/mapbox-gl-directions/issues/63)
99
+ - [feature] Wrap coordinates outside of -180, 180 [#54]((https://github.com/mapbox/mapbox-gl-directions/issues/54)
100
+ - [feature] Basic support for touch handling [#61](https://github.com/mapbox/mapbox-gl-directions/issues/61)
101
+ - [feature] Allow interaction to be toggled on or off [#65](https://github.com/mapbox/mapbox-gl-directions/issues/65)
102
+ - [feature] Allow controls to be removed on initialization.
103
+ - [internal] Refactor out native DOM and use registered mapbox-gl-js ones.
104
+ - [internal] Remove custom implementation of a geocoder and use mapbox-gl-geocoder.
105
+ - [internal] Use plain XMLHttpRequest for direction queries.
106
+
107
+ ## 2.0.0
108
+
109
+ - [breaking] Drop `directions` prefix from event names [#59](https://github.com/mapbox/mapbox-gl-directions/issues/59)
110
+ - [bug] Fix loading UI state and clearing past geocoded results [#58](https://github.com/mapbox/mapbox-gl-directions/pull/58)
111
+ - [breaking] Update `peerDependencies` to use mapbox-gl-js@v0.16.0 [#56](https://github.com/mapbox/mapbox-gl-directions/issues/56)
112
+ - [feature] Zoom to bounds if exist on origin or destination geocode [#46](https://github.com/mapbox/mapbox-gl-directions/issues/46)
113
+ - [feature] Pass custom styles in options argument [#45](https://github.com/mapbox/mapbox-gl-directions/issues/45)
114
+ - [bug] Fix points where a geocoded request is not found. Pass coordinates in request [#43](https://github.com/mapbox/mapbox-gl-directions/issues/43)
115
+
116
+ ## 1.0.0
117
+
118
+ - [bug] Infer container if no element is passed [#30](https://github.com/mapbox/mapbox-gl-directions/issues/30)
119
+ - [feature] Pass `container` as an options param [#30](https://github.com/mapbox/mapbox-gl-directions/issues/30)
120
+ - [breaking] Change `proximity` option to [lng, lat] format [#29](https://github.com/mapbox/mapbox-gl-directions/issues/29)
121
+ - [feature] Toggle routes from sidebar listing [#28](https://github.com/mapbox/mapbox-gl-directions/issues/28)
122
+ - [ui] Target mobile devices with media queries [#26](https://github.com/mapbox/mapbox-gl-directions/issues/26)
123
+ - [ui] Add loading state to input queries [#25](https://github.com/mapbox/mapbox-gl-directions/issues/25)
124
+ - [ui] Display routing errors in the instructions panel [#24](https://github.com/mapbox/mapbox-gl-directions/issues/24)
125
+
126
+ ## 0.0.0
127
+
128
+ - Initial commit
@@ -0,0 +1,25 @@
1
+ ### Developing
2
+
3
+ npm install & npm start & open http://localhost:9966/
4
+
5
+ You'll need a [Mapbox access token](https://www.mapbox.com/help/create-api-access-token/) stored in localstorage. Set it via
6
+
7
+ localStorage.setItem('MapboxAccessToken', '<YOUR ACCESS TOKEN>');
8
+
9
+ ### Testing
10
+
11
+ Tests require an MapboxAccessToken env variable to be set.
12
+
13
+ export MapboxAccessToken=<YOUR ACCESS TOKEN> && npm test
14
+
15
+ ### Release process
16
+
17
+ 1. `git checkout main`
18
+ 1. `git pull --rebase --autostash` to ensure you have the latest changes.
19
+ 1. `export MapboxAccessToken=<YOUR ACCESS TOKEN> && npm test`
20
+ 1. Update [`CHANGELOG.md`](https://github.com/mapbox/mapbox-gl-directions/blob/main/CHANGELOG.md)
21
+ 1. `npm version {major|minor|patch}`
22
+ 1. Create a release branch off of master that updates `CHANGELOG.md` and increments `package.json`.
23
+ 1. `git push --follow-tags`
24
+ 1. `mbx npm publish`
25
+ 1. Update version number on [GL JS example page](https://github.com/mapbox/mapbox-gl-js/blob/mb-pages/docs/_posts/examples/3400-01-11-mapbox-gl-directions.html)
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2015, Mapbox
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ Mapbox GL Directions
2
+ ---
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ A full featured directions plugin for [Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) using the [Mapbox Directions API](https://www.mapbox.com/directions/). Quickly add UI to display driving, cycling, or walking directions on the map.
5
+
6
+ For directions functionality in native mobile and desktop applications, see [Mapbox Android Services](https://github.com/mapbox/mapbox-java/), [MapboxDirections.swift](https://github.com/mapbox/MapboxDirections.swift/), and [MapboxNavigation.swift](https://github.com/mapbox/MapboxNavigation.swift/).
7
+
8
+ ### Usage
9
+
10
+ ```javascript
11
+ var mapboxgl = require('@ohos-ports/mapbox-gl');
12
+ var MapboxDirections = require('@ohos-ports/mapbox-gl-directions');
13
+
14
+ var directions = new MapboxDirections({
15
+ accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
16
+ unit: 'metric',
17
+ profile: 'mapbox/cycling'
18
+ });
19
+
20
+ var map = new mapboxgl.Map({
21
+ container: 'map'
22
+ });
23
+
24
+ map.addControl(directions, 'top-left');
25
+ ```
26
+
27
+ Live example: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
28
+
29
+ ### Deeper dive
30
+
31
+ See [API.md](https://github.com/mapbox/mapbox-gl-directions/blob/master/API.md) for complete reference.
32
+
33
+ ### Contributing
34
+
35
+ See [CONTRIBUTING.md](https://github.com/mapbox/mapbox-gl-directions/blob/master/CONTRIBUTING.md).
36
+
37
+ ## Publishing
38
+ To GitHub and NPM:
39
+
40
+ ```
41
+ npm version (major|minor|patch)
42
+ git push --tags
43
+ git push
44
+ npm publish
45
+ ```
46
+
47
+ To CDN:
48
+
49
+ ```
50
+ # make sure you are authenticated for AWS
51
+ git checkout v{x.y.z}
52
+ npm ci
53
+ npm run prepublish
54
+ aws s3 cp --recursive --acl public-read dist s3://mapbox-gl-js/plugins/mapbox-gl-directions/v{x.y.z}
55
+ ```
56
+
57
+ Update the version number in the [GL JS example](https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/).