@remaply/maps 0.0.0-stage → 0.2.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.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +240 -2
- package/dist/client.d.ts +31 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +208 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +62 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +65 -0
- package/dist/config.js.map +1 -0
- package/dist/directions.d.ts +68 -0
- package/dist/directions.d.ts.map +1 -0
- package/dist/directions.js +114 -0
- package/dist/directions.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -0
- package/dist/errors.js.map +1 -0
- package/dist/geo.d.ts +17 -0
- package/dist/geo.d.ts.map +1 -0
- package/dist/geo.js +43 -0
- package/dist/geo.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/map.d.ts +117 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +357 -0
- package/dist/map.js.map +1 -0
- package/dist/routePreview.d.ts +84 -0
- package/dist/routePreview.d.ts.map +1 -0
- package/dist/routePreview.js +206 -0
- package/dist/routePreview.js.map +1 -0
- package/dist/search.d.ts +70 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +60 -0
- package/dist/search.js.map +1 -0
- package/dist/security.d.ts +20 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +53 -0
- package/dist/security.js.map +1 -0
- package/dist/style.d.ts +45 -0
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +173 -0
- package/dist/style.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +56 -4
package/dist/map.js
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// Copyright 2026 Remaply
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { GeolocateControl, Map as MaplibreMapClass, NavigationControl, ScaleControl } from "maplibre-gl";
|
|
4
|
+
import { isApiUrl, withKeyParam } from "./client.js";
|
|
5
|
+
import { currentSettings, isConfigured } from "./config.js";
|
|
6
|
+
import { RemaplyApiError, apiKeyErrorMessage, isCancelled } from "./errors.js";
|
|
7
|
+
import { boundsOf, unwrapLongitudes } from "./geo.js";
|
|
8
|
+
import { isSecretKey } from "./security.js";
|
|
9
|
+
import { MapStyleError, firstFont, loadStyle } from "./style.js";
|
|
10
|
+
import { RoutePreview } from "./routePreview.js";
|
|
11
|
+
/** Where the map opens before anything else is known: Suva, Fiji, at the zoom buildings show from. */
|
|
12
|
+
export const DEFAULT_CENTER = { lat: -18.1416, lon: 178.4419 };
|
|
13
|
+
export const DEFAULT_ZOOM = 15;
|
|
14
|
+
const MARKER_SOURCE = "remaply-sdk-markers";
|
|
15
|
+
const MARKER_RINGS = "remaply-sdk-marker-rings";
|
|
16
|
+
const MARKER_PINS = "remaply-sdk-marker-pins";
|
|
17
|
+
const PIN_IMAGE = "remaply-sdk-pin";
|
|
18
|
+
const PIN_ACTIVE_IMAGE = "remaply-sdk-pin-active";
|
|
19
|
+
/** The apps' colours (android/.../compose/internal/Common.kt and MapImages.kt). */
|
|
20
|
+
const COLORS = {
|
|
21
|
+
pin: "#1A73E8",
|
|
22
|
+
pinActive: "#D93025",
|
|
23
|
+
originRing: "#1F1F1F",
|
|
24
|
+
stopRing: "#5F6670",
|
|
25
|
+
};
|
|
26
|
+
/** Shown when MapLibre cannot start its worker (see "Bundlers" in the README). */
|
|
27
|
+
export const WORKER_ERROR_MESSAGE = "The map could not start: MapLibre's worker file did not load. Call setWorkerUrl() from maplibre-gl " +
|
|
28
|
+
"with the URL of maplibre-gl/dist/maplibre-gl-worker.mjs (see Bundlers in the @remaply/maps README).";
|
|
29
|
+
/** An empty style, shown while the Remaply style loads, so MapLibre can start at once. */
|
|
30
|
+
const LOADING_STYLE = {
|
|
31
|
+
version: 8,
|
|
32
|
+
sources: {},
|
|
33
|
+
layers: [{ id: "background", type: "background", paint: { "background-color": "#f2f3f0" } }],
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A MapLibre `transformRequest` that adds the API key to the map's requests for the Remaply API's
|
|
37
|
+
* origin (tiles, sprite, fonts), and only those. Use it when you create your own MapLibre map with
|
|
38
|
+
* {@link loadStyle}; `RemaplyMap` already does.
|
|
39
|
+
*/
|
|
40
|
+
export function transformRequest(url, _resourceType) {
|
|
41
|
+
// MapLibre's default credentials ("same-origin") already keep cookies away from the API's origin.
|
|
42
|
+
return isApiUrl(url) ? { url: withKeyParam(url) } : { url };
|
|
43
|
+
}
|
|
44
|
+
/** Copy for a map style that cannot load. */
|
|
45
|
+
export function mapErrorMessage(error) {
|
|
46
|
+
if (isSecretKey(currentSettings().apiKey)) {
|
|
47
|
+
return "A secret Remaply API key (rmp_sk_) cannot be used on a website. Use a publishable rmp_pk_ key.";
|
|
48
|
+
}
|
|
49
|
+
if (!isConfigured())
|
|
50
|
+
return "The Remaply API key is missing. Call configure({ apiKey }) first.";
|
|
51
|
+
if (error instanceof MapStyleError)
|
|
52
|
+
return `Could not load the map style: ${error.message}`;
|
|
53
|
+
if (error instanceof RemaplyApiError) {
|
|
54
|
+
switch (error.code) {
|
|
55
|
+
case "scope_not_allowed":
|
|
56
|
+
return "The API key needs the styles and tiles scopes. Add them in Remaply Console.";
|
|
57
|
+
case "style_not_found":
|
|
58
|
+
return "There is no default map style in this environment. Activate one in Remaply Console, or set mapStyleUrl.";
|
|
59
|
+
case "tileset_not_found":
|
|
60
|
+
return `Tileset "${currentSettings().tileset}" does not exist in the API.`;
|
|
61
|
+
default:
|
|
62
|
+
return apiKeyErrorMessage(error) ?? "Could not load the map. Please try again.";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return "Could not load the map. Please try again.";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The Remaply map: the Remaply style and tiles on MapLibre GL JS, with markers and routes.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* configure({ apiKey: "rmp_pk_..." });
|
|
72
|
+
* const map = new RemaplyMap({ container: "map", showUserLocation: true });
|
|
73
|
+
* map.setMarkers([{ id: "cwm", location: { lat: -18.1351, lon: 178.4351 }, label: "CWM Hospital" }]);
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* `map.maplibre` is the MapLibre map underneath, for anything the SDK does not cover. Call
|
|
77
|
+
* `remove()` when the map goes away.
|
|
78
|
+
*/
|
|
79
|
+
export class RemaplyMap {
|
|
80
|
+
constructor(options) {
|
|
81
|
+
this.errorBox = null;
|
|
82
|
+
this.loadController = null;
|
|
83
|
+
this.labelFont = null;
|
|
84
|
+
this.removed = false;
|
|
85
|
+
this.ends = { from: null, to: null };
|
|
86
|
+
this.options = options;
|
|
87
|
+
this.markers = options.markers ?? [];
|
|
88
|
+
this.routes = options.routes ?? [];
|
|
89
|
+
const center = options.center ?? DEFAULT_CENTER;
|
|
90
|
+
this.maplibre = new MaplibreMapClass({
|
|
91
|
+
...options.mapOptions,
|
|
92
|
+
container: options.container,
|
|
93
|
+
style: LOADING_STYLE,
|
|
94
|
+
center: [center.lon, center.lat],
|
|
95
|
+
zoom: options.zoom ?? DEFAULT_ZOOM,
|
|
96
|
+
bearing: options.bearing ?? 0,
|
|
97
|
+
pitch: options.pitch ?? 0,
|
|
98
|
+
// The data licences (ODbL, CC BY) require the attribution: always shown.
|
|
99
|
+
attributionControl: { compact: true },
|
|
100
|
+
transformRequest: (url, type) => {
|
|
101
|
+
const mine = transformRequest(url, type);
|
|
102
|
+
return options.mapOptions?.transformRequest?.(mine.url, type) ?? mine;
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
this.container = this.maplibre.getContainer();
|
|
106
|
+
if (options.showZoomControls ?? true) {
|
|
107
|
+
this.maplibre.addControl(new NavigationControl({ showCompass: false }), "bottom-right");
|
|
108
|
+
}
|
|
109
|
+
if (options.showUserLocation) {
|
|
110
|
+
this.maplibre.addControl(new GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }), "bottom-right");
|
|
111
|
+
}
|
|
112
|
+
this.maplibre.addControl(new ScaleControl({ unit: "metric" }), "bottom-left");
|
|
113
|
+
// MapLibre 6 loads its worker from a file next to its own; a bundler that does not copy that
|
|
114
|
+
// file leaves the map without tiles and no visible error. Say what to do instead.
|
|
115
|
+
this.maplibre.on("error", (e) => {
|
|
116
|
+
const text = String(e.error?.message ?? e.error ?? "");
|
|
117
|
+
if (!/worker failed to load|failed to fetch worker script/i.test(text))
|
|
118
|
+
return;
|
|
119
|
+
const message = WORKER_ERROR_MESSAGE;
|
|
120
|
+
this.showError(message);
|
|
121
|
+
this.options.onError?.(message, e.error);
|
|
122
|
+
});
|
|
123
|
+
// Custom layers go with every style change: add them again each time a style loads. The
|
|
124
|
+
// routes first (under the labels), then the markers, with the route's ends kept on top.
|
|
125
|
+
this.preview = new RoutePreview(this.maplibre);
|
|
126
|
+
this.preview.set({ routes: this.routes });
|
|
127
|
+
this.maplibre.on("style.load", () => this.addOverlays());
|
|
128
|
+
this.maplibre.on("click", (e) => this.handleClick(e));
|
|
129
|
+
this.maplibre.on("mousemove", (e) => {
|
|
130
|
+
const hit = this.markerAt(e.point);
|
|
131
|
+
this.maplibre.getCanvas().style.cursor = hit ? "pointer" : "";
|
|
132
|
+
});
|
|
133
|
+
this.ready = new Promise((resolve, reject) => {
|
|
134
|
+
this.resolveReady = resolve;
|
|
135
|
+
this.rejectReady = reject;
|
|
136
|
+
});
|
|
137
|
+
// Callers that never await `ready` should not see an unhandled rejection: errors also go to onError.
|
|
138
|
+
this.ready.catch(() => undefined);
|
|
139
|
+
void this.reloadStyle();
|
|
140
|
+
}
|
|
141
|
+
/** Load the style again, e.g. after a failure or after `configure()` changed the key or style. */
|
|
142
|
+
async reloadStyle() {
|
|
143
|
+
this.loadController?.abort();
|
|
144
|
+
const controller = new AbortController();
|
|
145
|
+
this.loadController = controller;
|
|
146
|
+
this.showError(null);
|
|
147
|
+
try {
|
|
148
|
+
const style = await loadStyle({ signal: controller.signal });
|
|
149
|
+
if (controller.signal.aborted || this.removed)
|
|
150
|
+
return;
|
|
151
|
+
this.labelFont = firstFont(style);
|
|
152
|
+
this.maplibre.once("style.load", () => this.resolveReady());
|
|
153
|
+
this.maplibre.setStyle(style);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (controller.signal.aborted || this.removed || isCancelled(error))
|
|
157
|
+
return;
|
|
158
|
+
const message = mapErrorMessage(error);
|
|
159
|
+
this.showError(message);
|
|
160
|
+
this.rejectReady(error);
|
|
161
|
+
this.options.onError?.(message, error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Replace the markers. */
|
|
165
|
+
setMarkers(markers) {
|
|
166
|
+
this.markers = markers;
|
|
167
|
+
this.maplibre.getSource(MARKER_SOURCE)?.setData(markersGeoJson(markers));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Replace the routes: the active one blue, the others grey behind it. Draw a route from
|
|
171
|
+
* `route()` with `{ id, points: routePoints(r), active }`.
|
|
172
|
+
*/
|
|
173
|
+
setRoutes(routes) {
|
|
174
|
+
this.routes = routes;
|
|
175
|
+
this.preview.set({ routes, ...this.ends });
|
|
176
|
+
}
|
|
177
|
+
/** The route's start and destination, labelled "From: …" and "To: …" (null removes one). */
|
|
178
|
+
setRouteEnds(from, to) {
|
|
179
|
+
this.ends = { from, to };
|
|
180
|
+
this.preview.set({ routes: this.routes, ...this.ends });
|
|
181
|
+
}
|
|
182
|
+
/** Fly to a point, at `zoom` or the current zoom. */
|
|
183
|
+
flyTo(location, zoom) {
|
|
184
|
+
this.maplibre.flyTo({ center: [location.lon, location.lat], zoom: zoom ?? this.maplibre.getZoom(), duration: 800 });
|
|
185
|
+
}
|
|
186
|
+
/** Fit a box, or every route and marker when none is given, on screen. */
|
|
187
|
+
fitBounds(bounds, padding = 64) {
|
|
188
|
+
const ends = [this.ends.from, this.ends.to].filter((e) => !!e).map((e) => e.location);
|
|
189
|
+
const box = bounds ??
|
|
190
|
+
boundsOf([...this.routes.map((r) => r.points), this.markers.map((m) => m.location), ends].filter((l) => l.length > 0));
|
|
191
|
+
if (!box)
|
|
192
|
+
return;
|
|
193
|
+
const [west, south, east, north] = box;
|
|
194
|
+
// A single point has no area: fly there instead.
|
|
195
|
+
if (west === east && south === north)
|
|
196
|
+
return this.flyTo({ lat: south, lon: west });
|
|
197
|
+
this.maplibre.fitBounds([[west, south], [east, north]], { padding, duration: 800, maxZoom: 17 });
|
|
198
|
+
}
|
|
199
|
+
/** The map's centre. */
|
|
200
|
+
getCenter() {
|
|
201
|
+
const c = this.maplibre.getCenter();
|
|
202
|
+
return { lat: c.lat, lon: c.lng };
|
|
203
|
+
}
|
|
204
|
+
/** Remove the map and free its WebGL context. */
|
|
205
|
+
remove() {
|
|
206
|
+
this.removed = true;
|
|
207
|
+
this.loadController?.abort();
|
|
208
|
+
this.errorBox?.remove();
|
|
209
|
+
this.maplibre.remove();
|
|
210
|
+
}
|
|
211
|
+
addOverlays() {
|
|
212
|
+
const map = this.maplibre;
|
|
213
|
+
if (map.getSource(MARKER_SOURCE))
|
|
214
|
+
return;
|
|
215
|
+
ensurePinImages(map);
|
|
216
|
+
map.addSource(MARKER_SOURCE, { type: "geojson", data: markersGeoJson(this.markers) });
|
|
217
|
+
const isRing = ["in", ["get", "variant"], ["literal", ["origin", "stop"]]];
|
|
218
|
+
map.addLayer({
|
|
219
|
+
id: MARKER_RINGS,
|
|
220
|
+
type: "circle",
|
|
221
|
+
source: MARKER_SOURCE,
|
|
222
|
+
filter: isRing,
|
|
223
|
+
paint: {
|
|
224
|
+
"circle-radius": ["case", ["==", ["get", "variant"], "origin"], 7, 5],
|
|
225
|
+
"circle-color": "#FFFFFF",
|
|
226
|
+
"circle-stroke-width": 3,
|
|
227
|
+
"circle-stroke-color": ["case", ["==", ["get", "variant"], "origin"], COLORS.originRing, COLORS.stopRing],
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
map.addLayer({
|
|
231
|
+
id: MARKER_PINS,
|
|
232
|
+
type: "symbol",
|
|
233
|
+
source: MARKER_SOURCE,
|
|
234
|
+
filter: ["!", isRing],
|
|
235
|
+
layout: {
|
|
236
|
+
"icon-image": ["case", ["get", "active"], PIN_ACTIVE_IMAGE, PIN_IMAGE],
|
|
237
|
+
"icon-anchor": "bottom",
|
|
238
|
+
"icon-allow-overlap": true,
|
|
239
|
+
"symbol-sort-key": ["case", ["get", "active"], 0, 1],
|
|
240
|
+
...(this.labelFont
|
|
241
|
+
? {
|
|
242
|
+
"text-field": ["get", "label"],
|
|
243
|
+
"text-font": [this.labelFont],
|
|
244
|
+
"text-size": 13,
|
|
245
|
+
"text-anchor": "top",
|
|
246
|
+
"text-offset": [0, 0.3],
|
|
247
|
+
"text-optional": true,
|
|
248
|
+
}
|
|
249
|
+
: {}),
|
|
250
|
+
},
|
|
251
|
+
paint: { "text-color": "#202124", "text-halo-color": "#FFFFFF", "text-halo-width": 1.5 },
|
|
252
|
+
});
|
|
253
|
+
this.preview.bringEndsToFront();
|
|
254
|
+
}
|
|
255
|
+
markerAt(point) {
|
|
256
|
+
const map = this.maplibre;
|
|
257
|
+
const layers = [MARKER_PINS, MARKER_RINGS].filter((id) => map.getLayer(id));
|
|
258
|
+
if (layers.length === 0)
|
|
259
|
+
return null;
|
|
260
|
+
const hit = map.queryRenderedFeatures([point.x, point.y], { layers })[0];
|
|
261
|
+
const id = hit?.properties?.id;
|
|
262
|
+
return id === undefined ? null : (this.markers.find((m) => m.id === String(id)) ?? null);
|
|
263
|
+
}
|
|
264
|
+
handleClick(e) {
|
|
265
|
+
const marker = this.markerAt(e.point);
|
|
266
|
+
if (marker)
|
|
267
|
+
this.options.onMarkerClick?.(marker);
|
|
268
|
+
else
|
|
269
|
+
this.options.onMapClick?.({ lat: e.lngLat.lat, lon: e.lngLat.lng });
|
|
270
|
+
}
|
|
271
|
+
showError(message) {
|
|
272
|
+
if (message === null) {
|
|
273
|
+
this.errorBox?.remove();
|
|
274
|
+
this.errorBox = null;
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (!this.errorBox) {
|
|
278
|
+
const box = document.createElement("div");
|
|
279
|
+
box.setAttribute("role", "alert");
|
|
280
|
+
box.className = "remaply-map-error";
|
|
281
|
+
box.style.cssText =
|
|
282
|
+
"position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);max-width:min(360px,calc(100% - 32px));" +
|
|
283
|
+
"padding:12px 16px;border-radius:8px;background:#fff;color:#202124;font:14px/1.4 system-ui,sans-serif;" +
|
|
284
|
+
"box-shadow:0 1px 4px rgba(0,0,0,.3);text-align:center;z-index:2;";
|
|
285
|
+
this.container.appendChild(box);
|
|
286
|
+
this.errorBox = box;
|
|
287
|
+
}
|
|
288
|
+
this.errorBox.textContent = message;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/** Exported for tests. */
|
|
292
|
+
export function markersGeoJson(markers) {
|
|
293
|
+
return {
|
|
294
|
+
type: "FeatureCollection",
|
|
295
|
+
features: markers.map((m) => ({
|
|
296
|
+
type: "Feature",
|
|
297
|
+
geometry: { type: "Point", coordinates: [m.location.lon, m.location.lat] },
|
|
298
|
+
properties: { id: m.id, label: m.label ?? "", active: m.active ?? false, variant: m.variant ?? "pin" },
|
|
299
|
+
})),
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** Exported for tests. Longitudes unwrapped, so a route across the antimeridian is not drawn round the world. */
|
|
303
|
+
export function routesGeoJson(routes) {
|
|
304
|
+
return {
|
|
305
|
+
type: "FeatureCollection",
|
|
306
|
+
features: routes
|
|
307
|
+
.filter((r) => r.points.length >= 2)
|
|
308
|
+
.map((r) => ({
|
|
309
|
+
type: "Feature",
|
|
310
|
+
geometry: { type: "LineString", coordinates: unwrapLongitudes(r.points).map((p) => [p.lon, p.lat]) },
|
|
311
|
+
properties: { id: r.id, active: r.active ?? false },
|
|
312
|
+
})),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/** The pin images: a circle with a point at the bottom, the anchor, as the apps draw them. */
|
|
316
|
+
function ensurePinImages(map) {
|
|
317
|
+
const ratio = Math.max(1, Math.min(3, Math.round(globalThis.devicePixelRatio || 1)));
|
|
318
|
+
for (const [id, color] of [[PIN_IMAGE, COLORS.pin], [PIN_ACTIVE_IMAGE, COLORS.pinActive]]) {
|
|
319
|
+
if (map.hasImage(id))
|
|
320
|
+
continue;
|
|
321
|
+
const image = drawPin(color, ratio);
|
|
322
|
+
if (image)
|
|
323
|
+
map.addImage(id, image, { pixelRatio: ratio });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function drawPin(color, ratio) {
|
|
327
|
+
const w = 28, h = 38;
|
|
328
|
+
const canvas = document.createElement("canvas");
|
|
329
|
+
canvas.width = w * ratio;
|
|
330
|
+
canvas.height = h * ratio;
|
|
331
|
+
const ctx = canvas.getContext("2d");
|
|
332
|
+
if (!ctx)
|
|
333
|
+
return null;
|
|
334
|
+
ctx.scale(ratio, ratio);
|
|
335
|
+
const r = 12, cx = w / 2, cy = r + 2;
|
|
336
|
+
ctx.beginPath();
|
|
337
|
+
ctx.moveTo(cx, h - 1);
|
|
338
|
+
ctx.bezierCurveTo(cx - 4, h - 10, cx - r, cy + 8, cx - r, cy);
|
|
339
|
+
ctx.arc(cx, cy, r, Math.PI, 0);
|
|
340
|
+
ctx.bezierCurveTo(cx + r, cy + 8, cx + 4, h - 10, cx, h - 1);
|
|
341
|
+
ctx.closePath();
|
|
342
|
+
ctx.shadowColor = "rgba(0,0,0,0.3)";
|
|
343
|
+
ctx.shadowBlur = 2;
|
|
344
|
+
ctx.shadowOffsetY = 1;
|
|
345
|
+
ctx.fillStyle = color;
|
|
346
|
+
ctx.fill();
|
|
347
|
+
ctx.shadowColor = "transparent";
|
|
348
|
+
ctx.lineWidth = 2;
|
|
349
|
+
ctx.strokeStyle = "#FFFFFF";
|
|
350
|
+
ctx.stroke();
|
|
351
|
+
ctx.beginPath();
|
|
352
|
+
ctx.arc(cx, cy, 4.5, 0, Math.PI * 2);
|
|
353
|
+
ctx.fillStyle = "#FFFFFF";
|
|
354
|
+
ctx.fill();
|
|
355
|
+
return ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=map.js.map
|
package/dist/map.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,sCAAsC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAazG,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAA4B,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,YAAY,EAAgC,MAAM,mBAAmB,CAAC;AAE/E,sGAAsG;AACtG,MAAM,CAAC,MAAM,cAAc,GAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AA+C/B,MAAM,aAAa,GAAG,qBAAqB,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M,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Map as MaplibreMap } from "maplibre-gl";
|
|
2
|
+
import { type LatLon } from "./geo.js";
|
|
3
|
+
/** A line on the map, such as a route. */
|
|
4
|
+
export interface MapRoute {
|
|
5
|
+
id: string;
|
|
6
|
+
points: readonly LatLon[];
|
|
7
|
+
/** Drawn in front, in blue; the others are drawn grey behind it. */
|
|
8
|
+
active?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** One end of a route: a point and the label drawn above it ("From: Your location"). */
|
|
11
|
+
export interface RouteEnd {
|
|
12
|
+
location: LatLon;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RoutePreviewData {
|
|
16
|
+
routes: readonly MapRoute[];
|
|
17
|
+
/** The start: a white dot ringed in blue. */
|
|
18
|
+
from?: RouteEnd | null;
|
|
19
|
+
/** The destination: a red dot. */
|
|
20
|
+
to?: RouteEnd | null;
|
|
21
|
+
}
|
|
22
|
+
/** The route colours, as in the Android and iOS SDKs: the chosen route blue, alternatives grey. */
|
|
23
|
+
export declare const ROUTE_COLORS: {
|
|
24
|
+
readonly line: "#1A73E8";
|
|
25
|
+
readonly casing: "#0B57D0";
|
|
26
|
+
readonly alternativeLine: "#C5D2E6";
|
|
27
|
+
readonly alternativeCasing: "#8F9DB3";
|
|
28
|
+
readonly from: "#0B57D0";
|
|
29
|
+
readonly to: "#D93025";
|
|
30
|
+
};
|
|
31
|
+
/** Layer ids, bottom to top. Routes go under the map's labels, the ends on top of everything. */
|
|
32
|
+
export declare const ROUTE_PREVIEW_LAYERS: {
|
|
33
|
+
readonly casing: "remaply-sdk-route-casing";
|
|
34
|
+
readonly line: "remaply-sdk-route-line";
|
|
35
|
+
readonly links: "remaply-sdk-route-end-links";
|
|
36
|
+
readonly ends: "remaply-sdk-route-ends";
|
|
37
|
+
readonly labels: "remaply-sdk-route-end-labels";
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The route preview, as GeoJSON: each route (longitudes unwrapped across the antimeridian), the
|
|
41
|
+
* From and To points with their labels, and a dotted link from each to where the route line begins
|
|
42
|
+
* or ends (a router starts and ends on the nearest road, which can be a little way off).
|
|
43
|
+
* Exported for tests and for maps drawn another way.
|
|
44
|
+
*/
|
|
45
|
+
export declare function routePreviewGeoJson(data: RoutePreviewData): GeoJSON.FeatureCollection;
|
|
46
|
+
/**
|
|
47
|
+
* Routes and their From and To on a MapLibre map showing the Remaply style (from `loadStyle`):
|
|
48
|
+
* the chosen route blue, alternatives grey, the ends labelled. Survives style changes.
|
|
49
|
+
* `RemaplyMap` uses it; use it directly on your own MapLibre map.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const preview = new RoutePreview(map);
|
|
53
|
+
* const routes = await route([from, to], { alternatives: 2 });
|
|
54
|
+
* preview.set({
|
|
55
|
+
* routes: routes.map((r, i) => ({ id: `r${i}`, points: routePoints(r), active: i === 0 })),
|
|
56
|
+
* from: { location: from, label: "Your location" },
|
|
57
|
+
* to: { location: to, label: "CWM Hospital" },
|
|
58
|
+
* });
|
|
59
|
+
* preview.fit();
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare class RoutePreview {
|
|
63
|
+
private readonly map;
|
|
64
|
+
private data;
|
|
65
|
+
private readonly onStyleLoad;
|
|
66
|
+
constructor(map: MaplibreMap);
|
|
67
|
+
/** Show these routes and ends (replacing what was shown). */
|
|
68
|
+
set(data: RoutePreviewData): void;
|
|
69
|
+
/** Remove the routes and ends from view. */
|
|
70
|
+
clear(): void;
|
|
71
|
+
/** Fit the routes and ends on screen. [padding] in pixels, a number or per side. */
|
|
72
|
+
fit(padding?: number | {
|
|
73
|
+
top: number;
|
|
74
|
+
bottom: number;
|
|
75
|
+
left: number;
|
|
76
|
+
right: number;
|
|
77
|
+
}, maxZoom?: number): void;
|
|
78
|
+
/** Remove the layers and stop following style changes. */
|
|
79
|
+
remove(): void;
|
|
80
|
+
private add;
|
|
81
|
+
/** Keep the ends above layers added after the preview (an app's own pins), so they're never hidden. */
|
|
82
|
+
bringEndsToFront(): void;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=routePreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routePreview.d.ts","sourceRoot":"","sources":["../src/routePreview.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoF,GAAG,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACxI,OAAO,EAAY,KAAK,MAAM,EAAoB,MAAM,UAAU,CAAC;AAGnE,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wFAAwF;AACxF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC5B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,kCAAkC;IAClC,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACtB;AAED,mGAAmG;AACnG,eAAO,MAAM,YAAY;;;;;;;CAOf,CAAC;AAGX,iGAAiG;AACjG,eAAO,MAAM,oBAAoB;;;;;;CAMvB,CAAC;AAIX;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CA4BrF;AAID;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,OAAO,CAAC,IAAI,CAA2B;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