@page-speed/maps 0.1.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 +21 -0
- package/README.md +54 -0
- package/dist/core/MapLibre.cjs +383 -0
- package/dist/core/MapLibre.cjs.map +1 -0
- package/dist/core/MapLibre.d.cts +8 -0
- package/dist/core/MapLibre.d.ts +8 -0
- package/dist/core/MapLibre.js +376 -0
- package/dist/core/MapLibre.js.map +1 -0
- package/dist/core/index.cjs +383 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +4 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +376 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +395 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +384 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +67 -0
- package/dist/types/index.d.ts +67 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/getMapLibreStyleUrl.cjs +62 -0
- package/dist/utils/getMapLibreStyleUrl.cjs.map +1 -0
- package/dist/utils/getMapLibreStyleUrl.d.cts +8 -0
- package/dist/utils/getMapLibreStyleUrl.d.ts +8 -0
- package/dist/utils/getMapLibreStyleUrl.js +57 -0
- package/dist/utils/getMapLibreStyleUrl.js.map +1 -0
- package/dist/utils/googleMapLinks.cjs +14 -0
- package/dist/utils/googleMapLinks.cjs.map +1 -0
- package/dist/utils/googleMapLinks.d.cts +4 -0
- package/dist/utils/googleMapLinks.d.ts +4 -0
- package/dist/utils/googleMapLinks.js +11 -0
- package/dist/utils/googleMapLinks.js.map +1 -0
- package/dist/utils/index.cjs +72 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +65 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +112 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Marker, Map, GeolocateControl, NavigationControl } from 'react-map-gl/maplibre';
|
|
3
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/core/MapLibre.tsx
|
|
7
|
+
|
|
8
|
+
// src/utils/getMapLibreStyleUrl.ts
|
|
9
|
+
var MAPLIBRE_DEFAULT_STYLE_URL = "https://demotiles.maplibre.org/style.json";
|
|
10
|
+
var DEFAULT_STADIA_STYLE_URL = "https://tiles.stadiamaps.com/styles/osm_bright.json";
|
|
11
|
+
var STYLE_MAP = {
|
|
12
|
+
default: DEFAULT_STADIA_STYLE_URL,
|
|
13
|
+
"alidade-smooth": "https://tiles.stadiamaps.com/styles/alidade_smooth.json",
|
|
14
|
+
"alidade-smooth-dark": "https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json",
|
|
15
|
+
"maplibre-default": MAPLIBRE_DEFAULT_STYLE_URL,
|
|
16
|
+
"osm-bright": "https://tiles.stadiamaps.com/styles/osm_bright.json",
|
|
17
|
+
"stadia-outdoors": "https://tiles.stadiamaps.com/styles/outdoors.json",
|
|
18
|
+
"stamen-toner": "https://tiles.stadiamaps.com/styles/stamen_toner.json",
|
|
19
|
+
"stamen-terrain": "https://tiles.stadiamaps.com/styles/stamen_terrain.json",
|
|
20
|
+
"stamen-watercolor": "https://tiles.stadiamaps.com/styles/stamen_watercolor.json"
|
|
21
|
+
};
|
|
22
|
+
var HTTP_URL_REGEX = /^https?:\/\//i;
|
|
23
|
+
function isStadiaMapsUrl(url) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = new URL(url);
|
|
26
|
+
return parsed.hostname === "tiles.stadiamaps.com";
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function assertStadiaApiKey(stadiaApiKey) {
|
|
32
|
+
if (!stadiaApiKey.trim()) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"A non-empty stadiaApiKey is required for Stadia Maps style URLs."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function appendStadiaApiKey(styleUrl, stadiaApiKey) {
|
|
39
|
+
if (!isStadiaMapsUrl(styleUrl)) {
|
|
40
|
+
return styleUrl;
|
|
41
|
+
}
|
|
42
|
+
assertStadiaApiKey(stadiaApiKey);
|
|
43
|
+
const parsed = new URL(styleUrl);
|
|
44
|
+
if (!parsed.searchParams.has("api_key")) {
|
|
45
|
+
parsed.searchParams.set("api_key", stadiaApiKey);
|
|
46
|
+
}
|
|
47
|
+
return parsed.toString();
|
|
48
|
+
}
|
|
49
|
+
function getMapLibreStyleUrl(value, stadiaApiKey) {
|
|
50
|
+
if (!value || typeof value !== "string") {
|
|
51
|
+
return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);
|
|
52
|
+
}
|
|
53
|
+
if (STYLE_MAP[value]) {
|
|
54
|
+
return appendStadiaApiKey(STYLE_MAP[value], stadiaApiKey);
|
|
55
|
+
}
|
|
56
|
+
if (HTTP_URL_REGEX.test(value)) {
|
|
57
|
+
return appendStadiaApiKey(value, stadiaApiKey);
|
|
58
|
+
}
|
|
59
|
+
return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/utils/googleMapLinks.ts
|
|
63
|
+
function generateGoogleMapLink(latitude, longitude, zoom = 15) {
|
|
64
|
+
return `https://www.google.com/maps/@${latitude},${longitude},${zoom}z`;
|
|
65
|
+
}
|
|
66
|
+
function generateGoogleDirectionsLink(latitude, longitude) {
|
|
67
|
+
return `https://www.google.com/maps/dir/?api=1&destination=${latitude},${longitude}`;
|
|
68
|
+
}
|
|
69
|
+
function joinClassNames(...classNames) {
|
|
70
|
+
return classNames.filter(Boolean).join(" ");
|
|
71
|
+
}
|
|
72
|
+
function DefaultMarker({ marker }) {
|
|
73
|
+
return /* @__PURE__ */ jsxs(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
style: {
|
|
77
|
+
cursor: marker.draggable ? "grab" : "pointer",
|
|
78
|
+
transform: "translate(-50%, -100%)",
|
|
79
|
+
display: "inline-flex",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
position: "relative"
|
|
83
|
+
},
|
|
84
|
+
onClick: marker.onClick,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"svg",
|
|
88
|
+
{
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
width: "32",
|
|
91
|
+
height: "32",
|
|
92
|
+
viewBox: "0 0 24 24",
|
|
93
|
+
fill: marker.color || "#3B82F6",
|
|
94
|
+
style: { filter: "drop-shadow(0 2px 8px rgba(0,0,0,0.35))" },
|
|
95
|
+
children: /* @__PURE__ */ jsx("path", { d: "M12 2C8.13 2 5 5.13 5 9c0 4.85 6.13 12.24 6.39 12.55a.75.75 0 0 0 1.16 0C12.87 21.24 19 13.85 19 9c0-3.87-3.13-7-7-7Zm0 9.75A2.75 2.75 0 1 1 12 6.25a2.75 2.75 0 0 1 0 5.5Z" })
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
marker.label ? /* @__PURE__ */ jsx(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
style: {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
bottom: -28,
|
|
104
|
+
left: "50%",
|
|
105
|
+
transform: "translateX(-50%)",
|
|
106
|
+
background: "#FFFFFF",
|
|
107
|
+
borderRadius: 6,
|
|
108
|
+
padding: "2px 8px",
|
|
109
|
+
fontSize: 12,
|
|
110
|
+
fontWeight: 500,
|
|
111
|
+
whiteSpace: "nowrap",
|
|
112
|
+
boxShadow: "0 3px 10px rgba(0, 0, 0, 0.2)"
|
|
113
|
+
},
|
|
114
|
+
children: marker.label
|
|
115
|
+
}
|
|
116
|
+
) : null
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
function normalizeMarkers(markers) {
|
|
122
|
+
return markers.map((marker, index) => {
|
|
123
|
+
if (marker.lat !== void 0 && marker.lng !== void 0) {
|
|
124
|
+
return marker;
|
|
125
|
+
}
|
|
126
|
+
const basicMarker = marker;
|
|
127
|
+
return {
|
|
128
|
+
id: basicMarker.id ?? index,
|
|
129
|
+
lat: basicMarker.latitude,
|
|
130
|
+
lng: basicMarker.longitude,
|
|
131
|
+
color: basicMarker.color,
|
|
132
|
+
draggable: basicMarker.draggable,
|
|
133
|
+
label: basicMarker.label,
|
|
134
|
+
element: basicMarker.element,
|
|
135
|
+
onClick: basicMarker.onClick
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function MapLibre({
|
|
140
|
+
stadiaApiKey,
|
|
141
|
+
viewState,
|
|
142
|
+
onViewStateChange,
|
|
143
|
+
mapStyle,
|
|
144
|
+
center = viewState ? { lat: viewState.latitude ?? 0, lng: viewState.longitude ?? 0 } : { lat: 0, lng: 0 },
|
|
145
|
+
zoom = viewState?.zoom ?? 14,
|
|
146
|
+
styleUrl,
|
|
147
|
+
markers = [],
|
|
148
|
+
onMoveEnd,
|
|
149
|
+
onClick,
|
|
150
|
+
onMarkerDrag,
|
|
151
|
+
className,
|
|
152
|
+
style,
|
|
153
|
+
children,
|
|
154
|
+
showNavigationControl = true,
|
|
155
|
+
showGeolocateControl = false,
|
|
156
|
+
navigationControlPosition = "bottom-right",
|
|
157
|
+
geolocateControlPosition = "top-left",
|
|
158
|
+
flyToOptions = {}
|
|
159
|
+
}) {
|
|
160
|
+
const mapRef = React.useRef(null);
|
|
161
|
+
const [internalViewState, setInternalViewState] = React.useState({
|
|
162
|
+
latitude: viewState?.latitude ?? center.lat,
|
|
163
|
+
longitude: viewState?.longitude ?? center.lng,
|
|
164
|
+
zoom: viewState?.zoom ?? zoom
|
|
165
|
+
});
|
|
166
|
+
const isUserInteracting = React.useRef(false);
|
|
167
|
+
const isMarkerDragging = React.useRef(false);
|
|
168
|
+
const dragAnimationFrame = React.useRef(null);
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
if (!mapRef.current || !viewState || isUserInteracting.current || isMarkerDragging.current) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
setInternalViewState((previous) => {
|
|
174
|
+
const next = {
|
|
175
|
+
latitude: viewState.latitude ?? previous.latitude,
|
|
176
|
+
longitude: viewState.longitude ?? previous.longitude,
|
|
177
|
+
zoom: viewState.zoom ?? previous.zoom
|
|
178
|
+
};
|
|
179
|
+
const hasChanged = previous.latitude !== next.latitude || previous.longitude !== next.longitude || previous.zoom !== next.zoom;
|
|
180
|
+
if (!hasChanged) {
|
|
181
|
+
return previous;
|
|
182
|
+
}
|
|
183
|
+
const {
|
|
184
|
+
speed = 0.8,
|
|
185
|
+
curve = 1.2,
|
|
186
|
+
bearing = 0,
|
|
187
|
+
easing = (t) => 1 - Math.pow(1 - t, 3)
|
|
188
|
+
} = flyToOptions;
|
|
189
|
+
mapRef.current?.flyTo({
|
|
190
|
+
center: [next.longitude, next.latitude],
|
|
191
|
+
zoom: next.zoom,
|
|
192
|
+
speed,
|
|
193
|
+
curve,
|
|
194
|
+
bearing,
|
|
195
|
+
easing,
|
|
196
|
+
essential: true
|
|
197
|
+
});
|
|
198
|
+
return next;
|
|
199
|
+
});
|
|
200
|
+
}, [flyToOptions, viewState?.latitude, viewState?.longitude, viewState?.zoom]);
|
|
201
|
+
const handleMoveStart = React.useCallback(() => {
|
|
202
|
+
isUserInteracting.current = true;
|
|
203
|
+
}, []);
|
|
204
|
+
const handleMove = React.useCallback(
|
|
205
|
+
(event) => {
|
|
206
|
+
const nextViewState = event.viewState;
|
|
207
|
+
setInternalViewState({
|
|
208
|
+
latitude: nextViewState.latitude,
|
|
209
|
+
longitude: nextViewState.longitude,
|
|
210
|
+
zoom: nextViewState.zoom
|
|
211
|
+
});
|
|
212
|
+
onViewStateChange?.({
|
|
213
|
+
latitude: Number(nextViewState.latitude.toFixed(6)),
|
|
214
|
+
longitude: Number(nextViewState.longitude.toFixed(6)),
|
|
215
|
+
zoom: Number(nextViewState.zoom.toFixed(2))
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
[onViewStateChange]
|
|
219
|
+
);
|
|
220
|
+
const handleMoveEnd = React.useCallback(
|
|
221
|
+
(event) => {
|
|
222
|
+
isUserInteracting.current = false;
|
|
223
|
+
if (!onMoveEnd) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const map = event.target;
|
|
227
|
+
const nextCenter = map.getCenter();
|
|
228
|
+
const nextZoom = map.getZoom();
|
|
229
|
+
const bounds = map.getBounds();
|
|
230
|
+
onMoveEnd(
|
|
231
|
+
{
|
|
232
|
+
lat: Number(nextCenter.lat.toFixed(6)),
|
|
233
|
+
lng: Number(nextCenter.lng.toFixed(6))
|
|
234
|
+
},
|
|
235
|
+
Number(nextZoom.toFixed(2)),
|
|
236
|
+
bounds
|
|
237
|
+
);
|
|
238
|
+
},
|
|
239
|
+
[onMoveEnd]
|
|
240
|
+
);
|
|
241
|
+
const handleMapClick = React.useCallback(
|
|
242
|
+
(event) => {
|
|
243
|
+
if (!onClick) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
onClick({ latitude: event.lngLat.lat, longitude: event.lngLat.lng });
|
|
247
|
+
},
|
|
248
|
+
[onClick]
|
|
249
|
+
);
|
|
250
|
+
const normalizedMarkers = React.useMemo(
|
|
251
|
+
() => normalizeMarkers(markers),
|
|
252
|
+
[markers]
|
|
253
|
+
);
|
|
254
|
+
const markerElements = React.useMemo(
|
|
255
|
+
() => normalizedMarkers.map((marker) => /* @__PURE__ */ jsx(
|
|
256
|
+
Marker,
|
|
257
|
+
{
|
|
258
|
+
longitude: marker.lng,
|
|
259
|
+
latitude: marker.lat,
|
|
260
|
+
draggable: marker.draggable,
|
|
261
|
+
onDragStart: () => {
|
|
262
|
+
isMarkerDragging.current = true;
|
|
263
|
+
},
|
|
264
|
+
onDrag: (event) => {
|
|
265
|
+
if (!mapRef.current) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const nextLngLat = event.lngLat;
|
|
269
|
+
if (!nextLngLat || nextLngLat.lng === void 0 || nextLngLat.lat === void 0) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const draggedLng = nextLngLat.lng;
|
|
273
|
+
const draggedLat = nextLngLat.lat;
|
|
274
|
+
if (dragAnimationFrame.current) {
|
|
275
|
+
cancelAnimationFrame(dragAnimationFrame.current);
|
|
276
|
+
}
|
|
277
|
+
dragAnimationFrame.current = requestAnimationFrame(() => {
|
|
278
|
+
if (!mapRef.current) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const bounds = mapRef.current.getBounds();
|
|
282
|
+
const viewportWidth = bounds.getEast() - bounds.getWest();
|
|
283
|
+
const viewportHeight = bounds.getNorth() - bounds.getSouth();
|
|
284
|
+
const edgePadding = 0.1;
|
|
285
|
+
const westThreshold = bounds.getWest() + viewportWidth * edgePadding;
|
|
286
|
+
const eastThreshold = bounds.getEast() - viewportWidth * edgePadding;
|
|
287
|
+
const southThreshold = bounds.getSouth() + viewportHeight * edgePadding;
|
|
288
|
+
const northThreshold = bounds.getNorth() - viewportHeight * edgePadding;
|
|
289
|
+
const nearWestEdge = draggedLng < westThreshold;
|
|
290
|
+
const nearEastEdge = draggedLng > eastThreshold;
|
|
291
|
+
const nearSouthEdge = draggedLat < southThreshold;
|
|
292
|
+
const nearNorthEdge = draggedLat > northThreshold;
|
|
293
|
+
if (!nearWestEdge && !nearEastEdge && !nearSouthEdge && !nearNorthEdge) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
let panLng = draggedLng;
|
|
297
|
+
let panLat = draggedLat;
|
|
298
|
+
const offsetAmount = 0.2;
|
|
299
|
+
if (nearWestEdge) {
|
|
300
|
+
panLng = draggedLng - viewportWidth * offsetAmount;
|
|
301
|
+
}
|
|
302
|
+
if (nearEastEdge) {
|
|
303
|
+
panLng = draggedLng + viewportWidth * offsetAmount;
|
|
304
|
+
}
|
|
305
|
+
if (nearSouthEdge) {
|
|
306
|
+
panLat = draggedLat - viewportHeight * offsetAmount;
|
|
307
|
+
}
|
|
308
|
+
if (nearNorthEdge) {
|
|
309
|
+
panLat = draggedLat + viewportHeight * offsetAmount;
|
|
310
|
+
}
|
|
311
|
+
mapRef.current?.easeTo({
|
|
312
|
+
center: [panLng, panLat],
|
|
313
|
+
duration: 200
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
onDragEnd: (event) => {
|
|
318
|
+
isMarkerDragging.current = false;
|
|
319
|
+
if (dragAnimationFrame.current) {
|
|
320
|
+
cancelAnimationFrame(dragAnimationFrame.current);
|
|
321
|
+
dragAnimationFrame.current = null;
|
|
322
|
+
}
|
|
323
|
+
if (!onMarkerDrag) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const nextLngLat = event.lngLat;
|
|
327
|
+
if (!nextLngLat || nextLngLat.lng === void 0 || nextLngLat.lat === void 0) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
onMarkerDrag(marker.id ?? null, {
|
|
331
|
+
latitude: nextLngLat.lat,
|
|
332
|
+
longitude: nextLngLat.lng
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
children: marker.element ? typeof marker.element === "function" ? marker.element() : marker.element : /* @__PURE__ */ jsx(DefaultMarker, { marker })
|
|
336
|
+
},
|
|
337
|
+
marker.id
|
|
338
|
+
)),
|
|
339
|
+
[normalizedMarkers, onMarkerDrag]
|
|
340
|
+
);
|
|
341
|
+
const resolvedMapStyleUrl = React.useMemo(() => {
|
|
342
|
+
if (styleUrl) {
|
|
343
|
+
return appendStadiaApiKey(styleUrl, stadiaApiKey);
|
|
344
|
+
}
|
|
345
|
+
if (mapStyle) {
|
|
346
|
+
return getMapLibreStyleUrl(mapStyle, stadiaApiKey);
|
|
347
|
+
}
|
|
348
|
+
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
349
|
+
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
350
|
+
return /* @__PURE__ */ jsx(
|
|
351
|
+
"div",
|
|
352
|
+
{
|
|
353
|
+
className: joinClassNames("relative w-full h-full", className),
|
|
354
|
+
style: { width: "100%", height: "100%", ...style },
|
|
355
|
+
children: /* @__PURE__ */ jsxs(
|
|
356
|
+
Map,
|
|
357
|
+
{
|
|
358
|
+
ref: mapRef,
|
|
359
|
+
...internalViewState,
|
|
360
|
+
mapStyle: resolvedMapStyleUrl,
|
|
361
|
+
onMoveStart: handleMoveStart,
|
|
362
|
+
onMove: handleMove,
|
|
363
|
+
onMoveEnd: handleMoveEnd,
|
|
364
|
+
onClick: handleMapClick,
|
|
365
|
+
attributionControl: false,
|
|
366
|
+
trackResize: true,
|
|
367
|
+
dragRotate: false,
|
|
368
|
+
touchZoomRotate: false,
|
|
369
|
+
children: [
|
|
370
|
+
showGeolocateControl ? /* @__PURE__ */ jsx(GeolocateControl, { position: geolocateControlPosition }) : null,
|
|
371
|
+
showNavigationControl ? /* @__PURE__ */ jsx(NavigationControl, { position: navigationControlPosition }) : null,
|
|
372
|
+
markerElements,
|
|
373
|
+
children
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
var DTMapLibreMap = MapLibre;
|
|
381
|
+
|
|
382
|
+
export { DTMapLibreMap, MapLibre, appendStadiaApiKey, generateGoogleDirectionsLink, generateGoogleMapLink, getMapLibreStyleUrl };
|
|
383
|
+
//# sourceMappingURL=index.js.map
|
|
384
|
+
//# sourceMappingURL=index.js.map
|
|
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AErC,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,cAAA,CAAe,wBAAA,EAA0B,SAAS,CAAA;AAAA,MAC7D,OAAO,EAAE,KAAA,EAAO,QAAQ,MAAA,EAAQ,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,MAEjD,QAAA,kBAAA,IAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UACC,GAAA,EAAK,MAAA;AAAA,UACJ,GAAG,iBAAA;AAAA,UACJ,QAAA,EAAU,mBAAA;AAAA,UACV,WAAA,EAAa,eAAA;AAAA,UACb,MAAA,EAAQ,UAAA;AAAA,UACR,SAAA,EAAW,aAAA;AAAA,UACX,OAAA,EAAS,cAAA;AAAA,UACT,kBAAA,EAAoB,KAAA;AAAA,UACpB,WAAA,EAAW,IAAA;AAAA,UACX,UAAA,EAAY,KAAA;AAAA,UACZ,eAAA,EAAiB,KAAA;AAAA,UAEhB,QAAA,EAAA;AAAA,YAAA,oBAAA,mBACC,GAAA,CAAC,gBAAA,EAAA,EAAiB,QAAA,EAAU,wBAAA,EAA0B,CAAA,GACpD,IAAA;AAAA,YAEH,qBAAA,mBACC,GAAA,CAAC,iBAAA,EAAA,EAAkB,QAAA,EAAU,2BAA2B,CAAA,GACtD,IAAA;AAAA,YAEH,cAAA;AAAA,YAEA;AAAA;AAAA;AAAA;AACH;AAAA,GACF;AAEJ;AAEO,IAAM,aAAA,GAAgB","file":"index.js","sourcesContent":["const MAPLIBRE_DEFAULT_STYLE_URL = \"https://demotiles.maplibre.org/style.json\";\nconst DEFAULT_STADIA_STYLE_URL =\n \"https://tiles.stadiamaps.com/styles/osm_bright.json\";\n\nconst STYLE_MAP: Record<string, string> = {\n default: DEFAULT_STADIA_STYLE_URL,\n \"alidade-smooth\": \"https://tiles.stadiamaps.com/styles/alidade_smooth.json\",\n \"alidade-smooth-dark\": \"https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json\",\n \"maplibre-default\": MAPLIBRE_DEFAULT_STYLE_URL,\n \"osm-bright\": \"https://tiles.stadiamaps.com/styles/osm_bright.json\",\n \"stadia-outdoors\": \"https://tiles.stadiamaps.com/styles/outdoors.json\",\n \"stamen-toner\": \"https://tiles.stadiamaps.com/styles/stamen_toner.json\",\n \"stamen-terrain\": \"https://tiles.stadiamaps.com/styles/stamen_terrain.json\",\n \"stamen-watercolor\": \"https://tiles.stadiamaps.com/styles/stamen_watercolor.json\"\n};\n\nconst HTTP_URL_REGEX = /^https?:\\/\\//i;\n\nexport type MapLibreBuiltInStyle = keyof typeof STYLE_MAP;\n\nfunction isStadiaMapsUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.hostname === \"tiles.stadiamaps.com\";\n } catch {\n return false;\n }\n}\n\nfunction assertStadiaApiKey(stadiaApiKey: string): void {\n if (!stadiaApiKey.trim()) {\n throw new Error(\n \"A non-empty stadiaApiKey is required for Stadia Maps style URLs.\"\n );\n }\n}\n\nexport function appendStadiaApiKey(\n styleUrl: string,\n stadiaApiKey: string\n): string {\n if (!isStadiaMapsUrl(styleUrl)) {\n return styleUrl;\n }\n\n assertStadiaApiKey(stadiaApiKey);\n\n const parsed = new URL(styleUrl);\n if (!parsed.searchParams.has(\"api_key\")) {\n parsed.searchParams.set(\"api_key\", stadiaApiKey);\n }\n\n return parsed.toString();\n}\n\nexport function getMapLibreStyleUrl(\n value: string | undefined,\n stadiaApiKey: string\n): string {\n if (!value || typeof value !== \"string\") {\n return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);\n }\n\n if (STYLE_MAP[value]) {\n return appendStadiaApiKey(STYLE_MAP[value], stadiaApiKey);\n }\n\n if (HTTP_URL_REGEX.test(value)) {\n return appendStadiaApiKey(value, stadiaApiKey);\n }\n\n return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);\n}\n\nexport { DEFAULT_STADIA_STYLE_URL, MAPLIBRE_DEFAULT_STYLE_URL };\n","export function generateGoogleMapLink(\n latitude: number,\n longitude: number,\n zoom = 15\n): string {\n return `https://www.google.com/maps/@${latitude},${longitude},${zoom}z`;\n}\n\nexport function generateGoogleDirectionsLink(\n latitude: number,\n longitude: number\n): string {\n return `https://www.google.com/maps/dir/?api=1&destination=${latitude},${longitude}`;\n}\n","import React from \"react\";\nimport {\n GeolocateControl,\n Map,\n Marker,\n NavigationControl,\n type MapRef,\n type ViewStateChangeEvent\n} from \"react-map-gl/maplibre\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\n\nimport type {\n BasicMarkerInput,\n MapLibreMarker,\n MapLibreProps,\n MapViewState\n} from \"../types\";\nimport { appendStadiaApiKey, getMapLibreStyleUrl } from \"../utils\";\n\nfunction joinClassNames(...classNames: Array<string | undefined>): string {\n return classNames.filter(Boolean).join(\" \");\n}\n\nfunction DefaultMarker({ marker }: { marker: MapLibreMarker }) {\n return (\n <div\n style={{\n cursor: marker.draggable ? \"grab\" : \"pointer\",\n transform: \"translate(-50%, -100%)\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n position: \"relative\"\n }}\n onClick={marker.onClick}\n >\n <svg\n aria-hidden=\"true\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n fill={marker.color || \"#3B82F6\"}\n style={{ filter: \"drop-shadow(0 2px 8px rgba(0,0,0,0.35))\" }}\n >\n <path d=\"M12 2C8.13 2 5 5.13 5 9c0 4.85 6.13 12.24 6.39 12.55a.75.75 0 0 0 1.16 0C12.87 21.24 19 13.85 19 9c0-3.87-3.13-7-7-7Zm0 9.75A2.75 2.75 0 1 1 12 6.25a2.75 2.75 0 0 1 0 5.5Z\" />\n </svg>\n {marker.label ? (\n <div\n style={{\n position: \"absolute\",\n bottom: -28,\n left: \"50%\",\n transform: \"translateX(-50%)\",\n background: \"#FFFFFF\",\n borderRadius: 6,\n padding: \"2px 8px\",\n fontSize: 12,\n fontWeight: 500,\n whiteSpace: \"nowrap\",\n boxShadow: \"0 3px 10px rgba(0, 0, 0, 0.2)\"\n }}\n >\n {marker.label}\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction normalizeMarkers(\n markers: (MapLibreMarker | BasicMarkerInput)[]\n): MapLibreMarker[] {\n return markers.map((marker, index) => {\n if (\n (marker as MapLibreMarker).lat !== undefined &&\n (marker as MapLibreMarker).lng !== undefined\n ) {\n return marker as MapLibreMarker;\n }\n\n const basicMarker = marker as BasicMarkerInput;\n return {\n id: basicMarker.id ?? index,\n lat: basicMarker.latitude,\n lng: basicMarker.longitude,\n color: basicMarker.color,\n draggable: basicMarker.draggable,\n label: basicMarker.label,\n element: basicMarker.element,\n onClick: basicMarker.onClick\n };\n });\n}\n\nexport function MapLibre({\n stadiaApiKey,\n viewState,\n onViewStateChange,\n mapStyle,\n center = viewState\n ? { lat: viewState.latitude ?? 0, lng: viewState.longitude ?? 0 }\n : { lat: 0, lng: 0 },\n zoom = viewState?.zoom ?? 14,\n styleUrl,\n markers = [],\n onMoveEnd,\n onClick,\n onMarkerDrag,\n className,\n style,\n children,\n showNavigationControl = true,\n showGeolocateControl = false,\n navigationControlPosition = \"bottom-right\",\n geolocateControlPosition = \"top-left\",\n flyToOptions = {}\n}: MapLibreProps) {\n const mapRef = React.useRef<MapRef>(null);\n const [internalViewState, setInternalViewState] = React.useState<MapViewState>({\n latitude: viewState?.latitude ?? center.lat,\n longitude: viewState?.longitude ?? center.lng,\n zoom: viewState?.zoom ?? zoom\n });\n\n const isUserInteracting = React.useRef(false);\n const isMarkerDragging = React.useRef(false);\n const dragAnimationFrame = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n if (\n !mapRef.current ||\n !viewState ||\n isUserInteracting.current ||\n isMarkerDragging.current\n ) {\n return;\n }\n\n setInternalViewState((previous) => {\n const next = {\n latitude: viewState.latitude ?? previous.latitude,\n longitude: viewState.longitude ?? previous.longitude,\n zoom: viewState.zoom ?? previous.zoom\n };\n\n const hasChanged =\n previous.latitude !== next.latitude ||\n previous.longitude !== next.longitude ||\n previous.zoom !== next.zoom;\n\n if (!hasChanged) {\n return previous;\n }\n\n const {\n speed = 0.8,\n curve = 1.2,\n bearing = 0,\n easing = (t: number) => 1 - Math.pow(1 - t, 3)\n } = flyToOptions;\n\n mapRef.current?.flyTo({\n center: [next.longitude, next.latitude],\n zoom: next.zoom,\n speed,\n curve,\n bearing,\n easing,\n essential: true\n });\n\n return next;\n });\n }, [flyToOptions, viewState?.latitude, viewState?.longitude, viewState?.zoom]);\n\n const handleMoveStart = React.useCallback(() => {\n isUserInteracting.current = true;\n }, []);\n\n const handleMove = React.useCallback(\n (event: ViewStateChangeEvent) => {\n const nextViewState = event.viewState;\n setInternalViewState({\n latitude: nextViewState.latitude,\n longitude: nextViewState.longitude,\n zoom: nextViewState.zoom\n });\n\n onViewStateChange?.({\n latitude: Number(nextViewState.latitude.toFixed(6)),\n longitude: Number(nextViewState.longitude.toFixed(6)),\n zoom: Number(nextViewState.zoom.toFixed(2))\n });\n },\n [onViewStateChange]\n );\n\n const handleMoveEnd = React.useCallback(\n (event: ViewStateChangeEvent) => {\n isUserInteracting.current = false;\n\n if (!onMoveEnd) {\n return;\n }\n\n const map = event.target;\n const nextCenter = map.getCenter();\n const nextZoom = map.getZoom();\n const bounds = map.getBounds();\n\n onMoveEnd(\n {\n lat: Number(nextCenter.lat.toFixed(6)),\n lng: Number(nextCenter.lng.toFixed(6))\n },\n Number(nextZoom.toFixed(2)),\n bounds\n );\n },\n [onMoveEnd]\n );\n\n const handleMapClick = React.useCallback(\n (event: { lngLat: { lng: number; lat: number } }) => {\n if (!onClick) {\n return;\n }\n\n onClick({ latitude: event.lngLat.lat, longitude: event.lngLat.lng });\n },\n [onClick]\n );\n\n const normalizedMarkers = React.useMemo(\n () => normalizeMarkers(markers),\n [markers]\n );\n\n const markerElements = React.useMemo(\n () =>\n normalizedMarkers.map((marker) => (\n <Marker\n key={marker.id}\n longitude={marker.lng}\n latitude={marker.lat}\n draggable={marker.draggable}\n onDragStart={() => {\n isMarkerDragging.current = true;\n }}\n onDrag={(event) => {\n if (!mapRef.current) {\n return;\n }\n\n const nextLngLat = (event as { lngLat?: { lng?: number; lat?: number } }).lngLat;\n if (!nextLngLat || nextLngLat.lng === undefined || nextLngLat.lat === undefined) {\n return;\n }\n const draggedLng = nextLngLat.lng;\n const draggedLat = nextLngLat.lat;\n\n if (dragAnimationFrame.current) {\n cancelAnimationFrame(dragAnimationFrame.current);\n }\n\n dragAnimationFrame.current = requestAnimationFrame(() => {\n if (!mapRef.current) {\n return;\n }\n\n const bounds = mapRef.current.getBounds();\n const viewportWidth = bounds.getEast() - bounds.getWest();\n const viewportHeight = bounds.getNorth() - bounds.getSouth();\n\n const edgePadding = 0.1;\n const westThreshold = bounds.getWest() + viewportWidth * edgePadding;\n const eastThreshold = bounds.getEast() - viewportWidth * edgePadding;\n const southThreshold = bounds.getSouth() + viewportHeight * edgePadding;\n const northThreshold = bounds.getNorth() - viewportHeight * edgePadding;\n\n const nearWestEdge = draggedLng < westThreshold;\n const nearEastEdge = draggedLng > eastThreshold;\n const nearSouthEdge = draggedLat < southThreshold;\n const nearNorthEdge = draggedLat > northThreshold;\n\n if (!nearWestEdge && !nearEastEdge && !nearSouthEdge && !nearNorthEdge) {\n return;\n }\n\n let panLng = draggedLng;\n let panLat = draggedLat;\n const offsetAmount = 0.2;\n\n if (nearWestEdge) {\n panLng = draggedLng - viewportWidth * offsetAmount;\n }\n if (nearEastEdge) {\n panLng = draggedLng + viewportWidth * offsetAmount;\n }\n if (nearSouthEdge) {\n panLat = draggedLat - viewportHeight * offsetAmount;\n }\n if (nearNorthEdge) {\n panLat = draggedLat + viewportHeight * offsetAmount;\n }\n\n mapRef.current?.easeTo({\n center: [panLng, panLat],\n duration: 200\n });\n });\n }}\n onDragEnd={(event) => {\n isMarkerDragging.current = false;\n\n if (dragAnimationFrame.current) {\n cancelAnimationFrame(dragAnimationFrame.current);\n dragAnimationFrame.current = null;\n }\n\n if (!onMarkerDrag) {\n return;\n }\n\n const nextLngLat = (event as { lngLat?: { lng?: number; lat?: number } }).lngLat;\n if (!nextLngLat || nextLngLat.lng === undefined || nextLngLat.lat === undefined) {\n return;\n }\n\n onMarkerDrag(marker.id ?? null, {\n latitude: nextLngLat.lat,\n longitude: nextLngLat.lng\n });\n }}\n >\n {marker.element\n ? typeof marker.element === \"function\"\n ? marker.element()\n : marker.element\n : <DefaultMarker marker={marker} />}\n </Marker>\n )),\n [normalizedMarkers, onMarkerDrag]\n );\n\n const resolvedMapStyleUrl = React.useMemo(() => {\n if (styleUrl) {\n return appendStadiaApiKey(styleUrl, stadiaApiKey);\n }\n\n if (mapStyle) {\n return getMapLibreStyleUrl(mapStyle, stadiaApiKey);\n }\n\n return getMapLibreStyleUrl(\"osm-bright\", stadiaApiKey);\n }, [mapStyle, stadiaApiKey, styleUrl]);\n\n return (\n <div\n className={joinClassNames(\"relative w-full h-full\", className)}\n style={{ width: \"100%\", height: \"100%\", ...style }}\n >\n <Map\n ref={mapRef}\n {...internalViewState}\n mapStyle={resolvedMapStyleUrl}\n onMoveStart={handleMoveStart}\n onMove={handleMove}\n onMoveEnd={handleMoveEnd}\n onClick={handleMapClick}\n attributionControl={false}\n trackResize\n dragRotate={false}\n touchZoomRotate={false}\n >\n {showGeolocateControl ? (\n <GeolocateControl position={geolocateControlPosition} />\n ) : null}\n\n {showNavigationControl ? (\n <NavigationControl position={navigationControlPosition} />\n ) : null}\n\n {markerElements}\n\n {children}\n </Map>\n </div>\n );\n}\n\nexport const DTMapLibreMap = MapLibre;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type MapCoordinate = {
|
|
4
|
+
latitude: number;
|
|
5
|
+
longitude: number;
|
|
6
|
+
};
|
|
7
|
+
type MapViewState = {
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
zoom: number;
|
|
11
|
+
};
|
|
12
|
+
type MapControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
13
|
+
type MapLibreFlyToOptions = {
|
|
14
|
+
speed?: number;
|
|
15
|
+
curve?: number;
|
|
16
|
+
easing?: (t: number) => number;
|
|
17
|
+
bearing?: number;
|
|
18
|
+
};
|
|
19
|
+
type MapLibreMarker = {
|
|
20
|
+
id: string | number;
|
|
21
|
+
lat: number;
|
|
22
|
+
lng: number;
|
|
23
|
+
element?: (() => React.ReactNode) | React.ReactNode;
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
color?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
draggable?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type BasicMarkerInput = {
|
|
30
|
+
id?: string | number;
|
|
31
|
+
latitude: number;
|
|
32
|
+
longitude: number;
|
|
33
|
+
color?: string;
|
|
34
|
+
draggable?: boolean;
|
|
35
|
+
label?: string;
|
|
36
|
+
element?: (() => React.ReactNode) | React.ReactNode;
|
|
37
|
+
onClick?: () => void;
|
|
38
|
+
};
|
|
39
|
+
type MapLibreProps = {
|
|
40
|
+
stadiaApiKey: string;
|
|
41
|
+
viewState?: Partial<MapViewState>;
|
|
42
|
+
onViewStateChange?: (state: Partial<MapViewState>) => void;
|
|
43
|
+
mapStyle?: string;
|
|
44
|
+
center?: {
|
|
45
|
+
lat: number;
|
|
46
|
+
lng: number;
|
|
47
|
+
};
|
|
48
|
+
zoom?: number;
|
|
49
|
+
styleUrl?: string;
|
|
50
|
+
markers?: (MapLibreMarker | BasicMarkerInput)[];
|
|
51
|
+
onMoveEnd?: (center: {
|
|
52
|
+
lat: number;
|
|
53
|
+
lng: number;
|
|
54
|
+
}, zoom: number, bounds: unknown) => void;
|
|
55
|
+
onClick?: (coord: MapCoordinate) => void;
|
|
56
|
+
onMarkerDrag?: (markerId: string | number | null, coord: MapCoordinate) => void;
|
|
57
|
+
className?: string;
|
|
58
|
+
style?: React.CSSProperties;
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
showNavigationControl?: boolean;
|
|
61
|
+
showGeolocateControl?: boolean;
|
|
62
|
+
navigationControlPosition?: MapControlPosition;
|
|
63
|
+
geolocateControlPosition?: MapControlPosition;
|
|
64
|
+
flyToOptions?: MapLibreFlyToOptions;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type { BasicMarkerInput, MapControlPosition, MapCoordinate, MapLibreFlyToOptions, MapLibreMarker, MapLibreProps, MapViewState };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type MapCoordinate = {
|
|
4
|
+
latitude: number;
|
|
5
|
+
longitude: number;
|
|
6
|
+
};
|
|
7
|
+
type MapViewState = {
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
zoom: number;
|
|
11
|
+
};
|
|
12
|
+
type MapControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
13
|
+
type MapLibreFlyToOptions = {
|
|
14
|
+
speed?: number;
|
|
15
|
+
curve?: number;
|
|
16
|
+
easing?: (t: number) => number;
|
|
17
|
+
bearing?: number;
|
|
18
|
+
};
|
|
19
|
+
type MapLibreMarker = {
|
|
20
|
+
id: string | number;
|
|
21
|
+
lat: number;
|
|
22
|
+
lng: number;
|
|
23
|
+
element?: (() => React.ReactNode) | React.ReactNode;
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
color?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
draggable?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type BasicMarkerInput = {
|
|
30
|
+
id?: string | number;
|
|
31
|
+
latitude: number;
|
|
32
|
+
longitude: number;
|
|
33
|
+
color?: string;
|
|
34
|
+
draggable?: boolean;
|
|
35
|
+
label?: string;
|
|
36
|
+
element?: (() => React.ReactNode) | React.ReactNode;
|
|
37
|
+
onClick?: () => void;
|
|
38
|
+
};
|
|
39
|
+
type MapLibreProps = {
|
|
40
|
+
stadiaApiKey: string;
|
|
41
|
+
viewState?: Partial<MapViewState>;
|
|
42
|
+
onViewStateChange?: (state: Partial<MapViewState>) => void;
|
|
43
|
+
mapStyle?: string;
|
|
44
|
+
center?: {
|
|
45
|
+
lat: number;
|
|
46
|
+
lng: number;
|
|
47
|
+
};
|
|
48
|
+
zoom?: number;
|
|
49
|
+
styleUrl?: string;
|
|
50
|
+
markers?: (MapLibreMarker | BasicMarkerInput)[];
|
|
51
|
+
onMoveEnd?: (center: {
|
|
52
|
+
lat: number;
|
|
53
|
+
lng: number;
|
|
54
|
+
}, zoom: number, bounds: unknown) => void;
|
|
55
|
+
onClick?: (coord: MapCoordinate) => void;
|
|
56
|
+
onMarkerDrag?: (markerId: string | number | null, coord: MapCoordinate) => void;
|
|
57
|
+
className?: string;
|
|
58
|
+
style?: React.CSSProperties;
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
showNavigationControl?: boolean;
|
|
61
|
+
showGeolocateControl?: boolean;
|
|
62
|
+
navigationControlPosition?: MapControlPosition;
|
|
63
|
+
geolocateControlPosition?: MapControlPosition;
|
|
64
|
+
flyToOptions?: MapLibreFlyToOptions;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type { BasicMarkerInput, MapControlPosition, MapCoordinate, MapLibreFlyToOptions, MapLibreMarker, MapLibreProps, MapViewState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/getMapLibreStyleUrl.ts
|
|
4
|
+
var MAPLIBRE_DEFAULT_STYLE_URL = "https://demotiles.maplibre.org/style.json";
|
|
5
|
+
var DEFAULT_STADIA_STYLE_URL = "https://tiles.stadiamaps.com/styles/osm_bright.json";
|
|
6
|
+
var STYLE_MAP = {
|
|
7
|
+
default: DEFAULT_STADIA_STYLE_URL,
|
|
8
|
+
"alidade-smooth": "https://tiles.stadiamaps.com/styles/alidade_smooth.json",
|
|
9
|
+
"alidade-smooth-dark": "https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json",
|
|
10
|
+
"maplibre-default": MAPLIBRE_DEFAULT_STYLE_URL,
|
|
11
|
+
"osm-bright": "https://tiles.stadiamaps.com/styles/osm_bright.json",
|
|
12
|
+
"stadia-outdoors": "https://tiles.stadiamaps.com/styles/outdoors.json",
|
|
13
|
+
"stamen-toner": "https://tiles.stadiamaps.com/styles/stamen_toner.json",
|
|
14
|
+
"stamen-terrain": "https://tiles.stadiamaps.com/styles/stamen_terrain.json",
|
|
15
|
+
"stamen-watercolor": "https://tiles.stadiamaps.com/styles/stamen_watercolor.json"
|
|
16
|
+
};
|
|
17
|
+
var HTTP_URL_REGEX = /^https?:\/\//i;
|
|
18
|
+
function isStadiaMapsUrl(url) {
|
|
19
|
+
try {
|
|
20
|
+
const parsed = new URL(url);
|
|
21
|
+
return parsed.hostname === "tiles.stadiamaps.com";
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function assertStadiaApiKey(stadiaApiKey) {
|
|
27
|
+
if (!stadiaApiKey.trim()) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"A non-empty stadiaApiKey is required for Stadia Maps style URLs."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function appendStadiaApiKey(styleUrl, stadiaApiKey) {
|
|
34
|
+
if (!isStadiaMapsUrl(styleUrl)) {
|
|
35
|
+
return styleUrl;
|
|
36
|
+
}
|
|
37
|
+
assertStadiaApiKey(stadiaApiKey);
|
|
38
|
+
const parsed = new URL(styleUrl);
|
|
39
|
+
if (!parsed.searchParams.has("api_key")) {
|
|
40
|
+
parsed.searchParams.set("api_key", stadiaApiKey);
|
|
41
|
+
}
|
|
42
|
+
return parsed.toString();
|
|
43
|
+
}
|
|
44
|
+
function getMapLibreStyleUrl(value, stadiaApiKey) {
|
|
45
|
+
if (!value || typeof value !== "string") {
|
|
46
|
+
return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);
|
|
47
|
+
}
|
|
48
|
+
if (STYLE_MAP[value]) {
|
|
49
|
+
return appendStadiaApiKey(STYLE_MAP[value], stadiaApiKey);
|
|
50
|
+
}
|
|
51
|
+
if (HTTP_URL_REGEX.test(value)) {
|
|
52
|
+
return appendStadiaApiKey(value, stadiaApiKey);
|
|
53
|
+
}
|
|
54
|
+
return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.DEFAULT_STADIA_STYLE_URL = DEFAULT_STADIA_STYLE_URL;
|
|
58
|
+
exports.MAPLIBRE_DEFAULT_STYLE_URL = MAPLIBRE_DEFAULT_STYLE_URL;
|
|
59
|
+
exports.appendStadiaApiKey = appendStadiaApiKey;
|
|
60
|
+
exports.getMapLibreStyleUrl = getMapLibreStyleUrl;
|
|
61
|
+
//# sourceMappingURL=getMapLibreStyleUrl.cjs.map
|
|
62
|
+
//# sourceMappingURL=getMapLibreStyleUrl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getMapLibreStyleUrl.ts"],"names":[],"mappings":";;;AAAA,IAAM,0BAAA,GAA6B;AACnC,IAAM,wBAAA,GACJ;AAEF,IAAM,SAAA,GAAoC;AAAA,EACxC,OAAA,EAAS,wBAAA;AAAA,EACT,gBAAA,EAAkB,yDAAA;AAAA,EAClB,qBAAA,EAAuB,8DAAA;AAAA,EACvB,kBAAA,EAAoB,0BAAA;AAAA,EACpB,YAAA,EAAc,qDAAA;AAAA,EACd,iBAAA,EAAmB,mDAAA;AAAA,EACnB,cAAA,EAAgB,uDAAA;AAAA,EAChB,gBAAA,EAAkB,yDAAA;AAAA,EAClB,mBAAA,EAAqB;AACvB,CAAA;AAEA,IAAM,cAAA,GAAiB,eAA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YAAY,CAAA;AAAA,EAC/C;AAEA,EAAA,OAAO,kBAAA,CAAmB,0BAA0B,YAAY,CAAA;AAClE","file":"getMapLibreStyleUrl.cjs","sourcesContent":["const MAPLIBRE_DEFAULT_STYLE_URL = \"https://demotiles.maplibre.org/style.json\";\nconst DEFAULT_STADIA_STYLE_URL =\n \"https://tiles.stadiamaps.com/styles/osm_bright.json\";\n\nconst STYLE_MAP: Record<string, string> = {\n default: DEFAULT_STADIA_STYLE_URL,\n \"alidade-smooth\": \"https://tiles.stadiamaps.com/styles/alidade_smooth.json\",\n \"alidade-smooth-dark\": \"https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json\",\n \"maplibre-default\": MAPLIBRE_DEFAULT_STYLE_URL,\n \"osm-bright\": \"https://tiles.stadiamaps.com/styles/osm_bright.json\",\n \"stadia-outdoors\": \"https://tiles.stadiamaps.com/styles/outdoors.json\",\n \"stamen-toner\": \"https://tiles.stadiamaps.com/styles/stamen_toner.json\",\n \"stamen-terrain\": \"https://tiles.stadiamaps.com/styles/stamen_terrain.json\",\n \"stamen-watercolor\": \"https://tiles.stadiamaps.com/styles/stamen_watercolor.json\"\n};\n\nconst HTTP_URL_REGEX = /^https?:\\/\\//i;\n\nexport type MapLibreBuiltInStyle = keyof typeof STYLE_MAP;\n\nfunction isStadiaMapsUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.hostname === \"tiles.stadiamaps.com\";\n } catch {\n return false;\n }\n}\n\nfunction assertStadiaApiKey(stadiaApiKey: string): void {\n if (!stadiaApiKey.trim()) {\n throw new Error(\n \"A non-empty stadiaApiKey is required for Stadia Maps style URLs.\"\n );\n }\n}\n\nexport function appendStadiaApiKey(\n styleUrl: string,\n stadiaApiKey: string\n): string {\n if (!isStadiaMapsUrl(styleUrl)) {\n return styleUrl;\n }\n\n assertStadiaApiKey(stadiaApiKey);\n\n const parsed = new URL(styleUrl);\n if (!parsed.searchParams.has(\"api_key\")) {\n parsed.searchParams.set(\"api_key\", stadiaApiKey);\n }\n\n return parsed.toString();\n}\n\nexport function getMapLibreStyleUrl(\n value: string | undefined,\n stadiaApiKey: string\n): string {\n if (!value || typeof value !== \"string\") {\n return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);\n }\n\n if (STYLE_MAP[value]) {\n return appendStadiaApiKey(STYLE_MAP[value], stadiaApiKey);\n }\n\n if (HTTP_URL_REGEX.test(value)) {\n return appendStadiaApiKey(value, stadiaApiKey);\n }\n\n return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, stadiaApiKey);\n}\n\nexport { DEFAULT_STADIA_STYLE_URL, MAPLIBRE_DEFAULT_STYLE_URL };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const MAPLIBRE_DEFAULT_STYLE_URL = "https://demotiles.maplibre.org/style.json";
|
|
2
|
+
declare const DEFAULT_STADIA_STYLE_URL = "https://tiles.stadiamaps.com/styles/osm_bright.json";
|
|
3
|
+
declare const STYLE_MAP: Record<string, string>;
|
|
4
|
+
type MapLibreBuiltInStyle = keyof typeof STYLE_MAP;
|
|
5
|
+
declare function appendStadiaApiKey(styleUrl: string, stadiaApiKey: string): string;
|
|
6
|
+
declare function getMapLibreStyleUrl(value: string | undefined, stadiaApiKey: string): string;
|
|
7
|
+
|
|
8
|
+
export { DEFAULT_STADIA_STYLE_URL, MAPLIBRE_DEFAULT_STYLE_URL, type MapLibreBuiltInStyle, appendStadiaApiKey, getMapLibreStyleUrl };
|