@remaply/maps 0.0.0-stage → 0.3.0

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 (60) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +280 -2
  4. package/dist/client.d.ts +31 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +208 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/config.d.ts +62 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +65 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/directions.d.ts +68 -0
  13. package/dist/directions.d.ts.map +1 -0
  14. package/dist/directions.js +114 -0
  15. package/dist/directions.js.map +1 -0
  16. package/dist/errors.d.ts +26 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +85 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/geo.d.ts +17 -0
  21. package/dist/geo.d.ts.map +1 -0
  22. package/dist/geo.js +43 -0
  23. package/dist/geo.js.map +1 -0
  24. package/dist/index.d.ts +23 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/map.d.ts +133 -0
  29. package/dist/map.d.ts.map +1 -0
  30. package/dist/map.js +369 -0
  31. package/dist/map.js.map +1 -0
  32. package/dist/routePreview.d.ts +84 -0
  33. package/dist/routePreview.d.ts.map +1 -0
  34. package/dist/routePreview.js +206 -0
  35. package/dist/routePreview.js.map +1 -0
  36. package/dist/search.d.ts +70 -0
  37. package/dist/search.d.ts.map +1 -0
  38. package/dist/search.js +60 -0
  39. package/dist/search.js.map +1 -0
  40. package/dist/security.d.ts +20 -0
  41. package/dist/security.d.ts.map +1 -0
  42. package/dist/security.js +53 -0
  43. package/dist/security.js.map +1 -0
  44. package/dist/stepPreview.d.ts +127 -0
  45. package/dist/stepPreview.d.ts.map +1 -0
  46. package/dist/stepPreview.js +317 -0
  47. package/dist/stepPreview.js.map +1 -0
  48. package/dist/stepPreviewPanel.d.ts +41 -0
  49. package/dist/stepPreviewPanel.d.ts.map +1 -0
  50. package/dist/stepPreviewPanel.js +153 -0
  51. package/dist/stepPreviewPanel.js.map +1 -0
  52. package/dist/style.d.ts +45 -0
  53. package/dist/style.d.ts.map +1 -0
  54. package/dist/style.js +173 -0
  55. package/dist/style.js.map +1 -0
  56. package/dist/version.d.ts +3 -0
  57. package/dist/version.d.ts.map +1 -0
  58. package/dist/version.js +5 -0
  59. package/dist/version.js.map +1 -0
  60. package/package.json +56 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ Remaply Maps SDK
2
+ Copyright 2026 Remaply
3
+
4
+ This product includes software developed by Remaply (https://remaply.com).
5
+
6
+ Licensed under the Apache License, Version 2.0. See the LICENSE file.
7
+
8
+ Third-party software and map data used by this product are listed in THIRD-PARTY-NOTICES.md.
package/README.md CHANGED
@@ -1,3 +1,281 @@
1
- # Temporary Holding Version
1
+ # Remaply Maps for the web
2
2
 
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.
3
+ The [Remaply](https://remaply.com) map, place search and directions for websites, on
4
+ [MapLibre GL JS](https://maplibre.org). The web counterpart of the Remaply Maps SDK for Android and
5
+ iOS, on the same Remaply API.
6
+
7
+ ```ts
8
+ import "maplibre-gl/dist/maplibre-gl.css";
9
+ import { configure, RemaplyMap, search, route, routePoints } from "@remaply/maps";
10
+
11
+ configure({ apiKey: "rmp_pk_..." });
12
+
13
+ const map = new RemaplyMap({ container: "map", showUserLocation: true });
14
+
15
+ const [hospital] = await search("CWM Hospital", { near: map.getCenter() });
16
+ const [best] = await route([map.getCenter(), hospital.location], { profile: "car" });
17
+
18
+ map.setMarkers([{ id: hospital.id, location: hospital.location, label: hospital.name, active: true }]);
19
+ map.setRoutes([{ id: "best", points: routePoints(best), active: true }]);
20
+ map.fitBounds();
21
+ ```
22
+
23
+ ## What's included
24
+
25
+ | | |
26
+ |---|---|
27
+ | **Map** | `RemaplyMap`: the Remaply style and vector tiles (roads, buildings, building numbers, places) with markers, routes, zoom and location buttons, camera control. Or `loadStyle()` + `transformRequest` for your own MapLibre map |
28
+ | **Search** | `search()`: places and addresses as you type, biased to a point. `nearby()`: places around a point, by category |
29
+ | **Directions** | `route()`: routes for car, motorcycle, walking, cycling and truck, with alternatives, stops and turn-by-turn steps |
30
+ | **Turn-by-turn preview** | `previewSteps()` / `StepPreview`: step through a route's turns before setting off, with Back, Next and Exit preview, as in the apps' route planner |
31
+ | **API key** | `configure()`: one publishable key; it goes only to the Remaply API, never to other hosts |
32
+
33
+ Live turn-by-turn navigation (following your location, voice, re-routing) is in the Android and
34
+ iOS SDKs only. The web previews the turns.
35
+
36
+ ## Install
37
+
38
+ ```sh
39
+ npm install @remaply/maps maplibre-gl
40
+ ```
41
+
42
+ `maplibre-gl` 5 or 6 is a peer dependency, so your app controls its version. Import its CSS once
43
+ (`maplibre-gl/dist/maplibre-gl.css`).
44
+
45
+ ### Bundlers (MapLibre 6)
46
+
47
+ MapLibre 6 runs its worker from a separate file, `maplibre-gl-worker.mjs`, next to its own module.
48
+ Bundlers that merge MapLibre into your bundle do not copy that file, and the map stays empty. Tell
49
+ MapLibre where the file is, once, before creating a map:
50
+
51
+ ```ts
52
+ // Vite
53
+ import { setWorkerUrl } from "maplibre-gl";
54
+ import workerUrl from "maplibre-gl/dist/maplibre-gl-worker.mjs?url";
55
+ setWorkerUrl(workerUrl);
56
+ ```
57
+
58
+ ```ts
59
+ // webpack 5, Rspack, Parcel
60
+ import { setWorkerUrl } from "maplibre-gl";
61
+ setWorkerUrl(new URL("maplibre-gl/dist/maplibre-gl-worker.mjs", import.meta.url).href);
62
+ ```
63
+
64
+ If you forget, `RemaplyMap` shows a message saying so. MapLibre 5 needs none of this.
65
+
66
+ ## API key
67
+
68
+ Every request (style, tiles, search, routes) carries your Remaply API key. Use a **publishable**
69
+ key (`rmp_pk_...`) from Remaply Console with the scopes you use:
70
+
71
+ | Scope | Used for |
72
+ |---|---|
73
+ | `styles` | The map style |
74
+ | `tiles` | Map tiles and icons |
75
+ | `search` | `search()` |
76
+ | `geocode` | `nearby()` |
77
+ | `routing` | `route()` |
78
+
79
+ ```ts
80
+ configure({ apiKey: import.meta.env.VITE_REMAPLY_API_KEY });
81
+ ```
82
+
83
+ A key in a web page is public: anyone can read it from your site. So:
84
+
85
+ - **Restrict it to your website's origins** in Remaply Console (`https://www.example.com`,
86
+ `https://*.example.com`). Browsers send the page's origin with every request, and the API
87
+ refuses the key from other sites (`api_key_restricted`). Add `http://localhost:5173` (or your dev
88
+ server) to a separate development key.
89
+ - Give it **only the scopes it needs** and a **quota**.
90
+ - **Never use a secret key** (`rmp_sk_...`). The SDK refuses to send one: requests fail with
91
+ `secret_api_key`, `isConfigured()` is false, and the console says to rotate it.
92
+
93
+ How the key is sent: the SDK's own requests (style, TileJSON, search, routes) put it in the
94
+ `X-Api-Key` header. The map's tile, sprite and font requests put it in the URL (`?key=`), so the
95
+ browser does not send a CORS preflight for every tile. Either way it goes only to the API's exact
96
+ origin (scheme, host and port) over HTTPS: font servers and other hosts in a style never get it.
97
+
98
+ `configure({ apiKey, apiBaseUrl })` points the SDK at another Remaply API, such as staging. The URL
99
+ must be `https://` (`http://` only for `localhost`); anything else throws.
100
+
101
+ ## Map
102
+
103
+ ```ts
104
+ const map = new RemaplyMap({
105
+ container: "map", // an element or its id; give it a size
106
+ center: { lat: -17.8, lon: 177.4 },
107
+ zoom: 12,
108
+ showUserLocation: true, // a button that shows the user's position
109
+ onMarkerClick: (marker) => console.log(marker.id),
110
+ onMapClick: (location) => console.log(location),
111
+ onError: (message, error) => report(error),
112
+ });
113
+
114
+ await map.ready; // the Remaply style has loaded
115
+
116
+ map.setMarkers([
117
+ { id: "start", location: a, variant: "origin" }, // a ring
118
+ { id: "stop", location: b, variant: "stop" }, // a small ring
119
+ { id: "end", location: c, label: "CWM Hospital", active: true }, // a red pin with a label
120
+ ]);
121
+ map.setRoutes(routes.map((r, i) => ({ id: `r${i}`, points: routePoints(r), active: i === 0 })));
122
+ map.fitBounds(); // every route and marker on screen
123
+ map.flyTo({ lat: -18.1416, lon: 178.4419 }, 16);
124
+ map.remove(); // when the map goes away
125
+ ```
126
+
127
+ If the style cannot load (no key, a missing scope, a key not allowed on this site), the map shows
128
+ the reason itself and `ready` rejects. `map.reloadStyle()` tries again.
129
+
130
+ `map.maplibre` is the MapLibre map underneath, for anything else (layers, events, camera).
131
+ `mapOptions` passes more MapLibre options (`maxZoom`, `hash`, `cooperativeGestures`...). The
132
+ attribution control is always on: the data licences require it.
133
+
134
+ ### Route preview
135
+
136
+ Plan a route and show it before anyone sets off: the chosen route in blue, alternatives grey, the
137
+ start and destination labelled.
138
+
139
+ ```ts
140
+ const routes = await route([from, to], { alternatives: 2 });
141
+ map.setRoutes(routes.map((r, i) => ({ id: `r${i}`, points: routePoints(r), active: i === 0 })));
142
+ map.setRouteEnds({ location: from, label: "Your location" }, { location: to, label: "CWM Hospital" });
143
+ map.fitBounds();
144
+ ```
145
+
146
+ On your own MapLibre map, `RoutePreview` draws the same:
147
+
148
+ ```ts
149
+ const preview = new RoutePreview(maplibreMap);
150
+ preview.set({ routes: [...], from: { location: from, label: "Your location" }, to: { location: to, label: "CWM Hospital" } });
151
+ preview.fit();
152
+ ```
153
+
154
+ Show a route's turn-by-turn steps from `route()` (`legs[].steps[].instruction`, `maneuverOf(type)`)
155
+ as a list, or step through them on the map (below).
156
+
157
+ ### Turn-by-turn preview
158
+
159
+ Step through a route's turns before setting off, as the Preview in the apps' route planner: each
160
+ step flies the camera to that turn, zoomed in (16.5), tilted (45°) and facing the way you will
161
+ travel, and marks it on the route. A panel at the bottom of the map shows the turn's icon, its
162
+ instruction ("Turn right onto Milverton Road", "for 400 m"), progress (`3 / 12`), **Back**,
163
+ **Next** (**Arrived** on the last step) and **Exit preview**, which puts the camera back where it
164
+ was. The Left and Right arrow keys go back and forward; Escape exits.
165
+
166
+ ```ts
167
+ const [best] = await route([from, to]);
168
+ map.setRoutes([{ id: "best", points: routePoints(best), active: true }]);
169
+ map.previewSteps(best); // false for a route without steps
170
+
171
+ map.stepPreview.next(); // or back(), goTo(4), exit()
172
+ map.stepPreview.state; // { index, count, step, isFirst, isLast }, null when not previewing
173
+ ```
174
+
175
+ A ferry crossing is framed whole, flat and north up, rather than zoomed in on its start. On a
176
+ route with stops, the departure from each stop is left out: the arrival there shows it.
177
+
178
+ Options, as `new RemaplyMap({ stepPreview: { ... } })` or on your own MapLibre map with
179
+ `new StepPreview(maplibreMap, { ... })` and `start(route)`:
180
+
181
+ | | |
182
+ |---|---|
183
+ | `panel` | The built-in panel. Default `true`; `false` to draw your own from `onChange` |
184
+ | `theme` | `"light"`, `"dark"` or `"auto"` (the system setting). Default `"auto"` |
185
+ | `onChange` | `(state) => ...` on every step shown, and `null` when the preview ends |
186
+ | `keyboard` | Arrow keys and Escape. Default `true` |
187
+ | `zoom`, `pitch` | The close-in camera on a turn. Default 16.5 and 45 |
188
+ | `padding` | Space kept clear of the turn, in pixels. Default: room for the panel |
189
+
190
+ For your own panel, `previewSteps(route)` gives the steps (`instruction`, `distance`, `maneuver`,
191
+ `location`, `bearing`) and `maneuverIconSvg(maneuver)` the icon the built-in panel draws.
192
+
193
+ This is a preview: it does not follow your location, speak, or re-route.
194
+
195
+ ### Your own MapLibre map
196
+
197
+ ```ts
198
+ import { Map } from "maplibre-gl";
199
+ import { loadStyle, transformRequest } from "@remaply/maps";
200
+
201
+ const map = new Map({ container: "map", style: await loadStyle(), transformRequest });
202
+ ```
203
+
204
+ `transformRequest` adds the key to requests for the Remaply API only.
205
+
206
+ ### Your own style
207
+
208
+ `configure({ apiKey, mapStyleUrl: "https://example.com/style.json" })` shows your MapLibre style
209
+ instead of Remaply's. It needs a vector source named `remaply`; the SDK points it at the Remaply
210
+ tiles. The tile layers are `buildings`, `roads`, `addresses`, `pois`, `admin_boundaries` and
211
+ `admin_labels`.
212
+
213
+ `buildingMinZoom` and `addressNumberMinZoom` (default 15) set the zoom from which buildings and
214
+ building numbers show; `null` keeps the tiles' own zooms.
215
+
216
+ ## Search
217
+
218
+ ```ts
219
+ const controller = new AbortController();
220
+ const places = await search("hospital", {
221
+ near: map.getCenter(), // nearest first
222
+ limit: 8,
223
+ signal: controller.signal, // cancel when the user types again
224
+ });
225
+
226
+ const atms = await nearby(map.getCenter(), { categories: ["atm"], radiusM: 2000 });
227
+
228
+ formatAddress(places[0]); // "12 Victoria Parade, Suva, Fiji"
229
+ formatCategory("fast_food"); // "Fast food"
230
+ NEARBY_CATEGORIES; // the categories the Remaply apps offer
231
+ ```
232
+
233
+ ## Directions
234
+
235
+ ```ts
236
+ const routes = await route([start, stop, destination], {
237
+ profile: "car", // "car" | "motorcycle" | "foot" | "bicycle" | "truck"
238
+ alternatives: 2, // only for two points
239
+ });
240
+
241
+ const best = routes[0];
242
+ formatDuration(best.duration_s); // "1 h 2 min"
243
+ formatDistance(best.distance_m); // "12.4 km"
244
+ mainRoad(best); // "Queens Road", for "via Queens Road"
245
+ best.legs[0].steps.map((s) => [maneuverOf(s.type), s.instruction]);
246
+ ```
247
+
248
+ Up to 10 points per route.
249
+
250
+ ## Errors
251
+
252
+ API errors are `RemaplyApiError` with a stable `code` (`scope_not_allowed`, `route_not_found`,
253
+ `api_key_restricted`...) and an HTTP `status`. For copy to show users:
254
+
255
+ ```ts
256
+ try {
257
+ await route(points);
258
+ } catch (error) {
259
+ if (isCancelled(error)) return;
260
+ showMessage(directionsErrorMessage(error)); // or searchErrorMessage, mapErrorMessage
261
+ }
262
+ ```
263
+
264
+ Requests time out after 20 seconds, and network errors, `5xx` and `429` are retried twice.
265
+
266
+ ## Licence and attribution
267
+
268
+ Copyright 2026 Remaply. The SDK source code is licensed under Apache-2.0; see `LICENSE` and
269
+ `NOTICE`. The licence covers the code only. Using the Remaply API, tiles and data needs an API key
270
+ and is governed by the Remaply Terms of Service.
271
+
272
+ Map data © Remaply, © OpenStreetMap contributors (ODbL), © Overture Maps Foundation, © ESA
273
+ WorldCover project 2021 / Contains modified Copernicus Sentinel data (2021) processed by ESA
274
+ WorldCover consortium (CC BY 4.0). The map keeps its attribution visible; do not hide it. If you
275
+ show search results without the map, credit these sources on your site. MapLibre GL JS is
276
+ BSD-3-Clause.
277
+
278
+ ## Sample
279
+
280
+ [`samples/web`](https://github.com/Remaply-Fiji/remaply-maps-sdk/tree/main/samples/web): a map
281
+ with place search and directions to the place you pick.
@@ -0,0 +1,31 @@
1
+ /** Where the docs explain how to set the API key. */
2
+ export declare const API_KEY_HELP = "https://github.com/Remaply-Fiji/remaply-maps-sdk/blob/main/web/README.md#api-key";
3
+ /** Header the API reads the key from. The API's CORS rules allow only this one and Content-Type. */
4
+ export declare const API_KEY_HEADER = "X-Api-Key";
5
+ /** Query parameter the API also reads publishable keys from, for map clients that can only set a URL. */
6
+ export declare const API_KEY_QUERY_PARAM = "key";
7
+ export type QueryValue = string | number | boolean | null | undefined | ReadonlyArray<string | number>;
8
+ export declare function apiBaseUrl(): string;
9
+ /** True when [url] is on the Remaply API's origin: the only requests that carry the key. */
10
+ export declare function isApiUrl(url: string): boolean;
11
+ /**
12
+ * `${apiBaseUrl}${path}` with [params]. Null and empty values are dropped; an array repeats the
13
+ * parameter (`category=a&category=b`).
14
+ */
15
+ export declare function apiUrl(path: string, params?: Record<string, QueryValue>): string;
16
+ /**
17
+ * [url] with the publishable key as `?key=`, for the map's own tile, sprite and glyph requests on the
18
+ * API origin. In the URL, not a header, so the browser sends them without a CORS preflight per tile.
19
+ * Any other URL is returned unchanged. Never adds a secret key.
20
+ */
21
+ export declare function withKeyParam(url: string): string;
22
+ /** GET [path] on the API and parse the JSON. Throws [RemaplyApiError] for API errors. */
23
+ export declare function apiGet<T>(path: string, params: Record<string, QueryValue>, signal?: AbortSignal): Promise<T>;
24
+ /**
25
+ * GET an absolute URL and return the body. The key goes only to the API's origin. Retries network
26
+ * errors, 5xx and 429 twice with backoff; never retries after [signal] aborts.
27
+ */
28
+ export declare function getText(url: string, signal?: AbortSignal): Promise<string>;
29
+ /** GET [url] and report only whether it answered with success, for the glyph check. */
30
+ export declare function isReachable(url: string, signal?: AbortSignal): Promise<boolean>;
31
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,qDAAqD;AACrD,eAAO,MAAM,YAAY,qFAAqF,CAAC;AAE/G,oGAAoG;AACpG,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAMzC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAEvG,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM,GAAG,MAAM,CAWpF;AAcD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,yFAAyF;AACzF,wBAAsB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAElH;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBhF;AAED,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CASrF"}