react-bkoi-gl 1.0.7 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +172 -18
  3. package/dist/index.cjs +671 -736
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +370 -0
  6. package/dist/index.d.ts +370 -2
  7. package/dist/index.js +1434 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/styles/index.d.ts +4 -0
  10. package/dist/styles/react-bkoi-gl.css +1 -1
  11. package/package.json +84 -36
  12. package/bkoi-gl/package.json +0 -6
  13. package/dist/components/attribution-control.d.ts +0 -11
  14. package/dist/components/attribution-control.js +0 -19
  15. package/dist/components/attribution-control.js.map +0 -1
  16. package/dist/components/fullscreen-control.d.ts +0 -14
  17. package/dist/components/fullscreen-control.js +0 -21
  18. package/dist/components/fullscreen-control.js.map +0 -1
  19. package/dist/components/geolocate-control.d.ts +0 -37
  20. package/dist/components/geolocate-control.js +0 -46
  21. package/dist/components/geolocate-control.js.map +0 -1
  22. package/dist/components/layer.d.ts +0 -17
  23. package/dist/components/layer.js +0 -99
  24. package/dist/components/layer.js.map +0 -1
  25. package/dist/components/map.d.ts +0 -23
  26. package/dist/components/map.js +0 -102
  27. package/dist/components/map.js.map +0 -1
  28. package/dist/components/marker.d.ts +0 -41
  29. package/dist/components/marker.js +0 -98
  30. package/dist/components/marker.js.map +0 -1
  31. package/dist/components/navigation-control.d.ts +0 -11
  32. package/dist/components/navigation-control.js +0 -19
  33. package/dist/components/navigation-control.js.map +0 -1
  34. package/dist/components/popup.d.ts +0 -33
  35. package/dist/components/popup.js +0 -79
  36. package/dist/components/popup.js.map +0 -1
  37. package/dist/components/scale-control.d.ts +0 -13
  38. package/dist/components/scale-control.js +0 -31
  39. package/dist/components/scale-control.js.map +0 -1
  40. package/dist/components/source.d.ts +0 -7
  41. package/dist/components/source.js +0 -97
  42. package/dist/components/source.js.map +0 -1
  43. package/dist/components/use-control.d.ts +0 -9
  44. package/dist/components/use-control.js +0 -31
  45. package/dist/components/use-control.js.map +0 -1
  46. package/dist/components/use-map.d.ts +0 -20
  47. package/dist/components/use-map.js +0 -54
  48. package/dist/components/use-map.js.map +0 -1
  49. package/dist/exports-bkoi-gl.cjs +0 -1512
  50. package/dist/exports-bkoi-gl.d.ts +0 -89
  51. package/dist/exports-bkoi-gl.js +0 -36
  52. package/dist/exports-bkoi-gl.js.map +0 -1
  53. package/dist/exports-mapbox.d.ts +0 -139
  54. package/dist/exports-mapbox.js +0 -36
  55. package/dist/exports-mapbox.js.map +0 -1
  56. package/dist/mapbox/create-ref.d.ts +0 -9
  57. package/dist/mapbox/create-ref.js +0 -64
  58. package/dist/mapbox/create-ref.js.map +0 -1
  59. package/dist/mapbox/mapbox.d.ts +0 -81
  60. package/dist/mapbox/mapbox.js +0 -476
  61. package/dist/mapbox/mapbox.js.map +0 -1
  62. package/dist/types/common.d.ts +0 -78
  63. package/dist/types/common.js +0 -2
  64. package/dist/types/common.js.map +0 -1
  65. package/dist/types/events-bkoi-gl.d.ts +0 -49
  66. package/dist/types/events-bkoi-gl.js +0 -2
  67. package/dist/types/events-bkoi-gl.js.map +0 -1
  68. package/dist/types/events-mapbox.d.ts +0 -49
  69. package/dist/types/events-mapbox.js +0 -2
  70. package/dist/types/events-mapbox.js.map +0 -1
  71. package/dist/types/events.d.ts +0 -39
  72. package/dist/types/events.js +0 -2
  73. package/dist/types/events.js.map +0 -1
  74. package/dist/types/index.d.ts +0 -70
  75. package/dist/types/index.js +0 -5
  76. package/dist/types/index.js.map +0 -1
  77. package/dist/types/lib.d.ts +0 -224
  78. package/dist/types/lib.js +0 -2
  79. package/dist/types/lib.js.map +0 -1
  80. package/dist/types/public.d.ts +0 -2
  81. package/dist/types/public.js +0 -2
  82. package/dist/types/public.js.map +0 -1
  83. package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
  84. package/dist/types/style-spec-bkoi-gl.js +0 -2
  85. package/dist/types/style-spec-bkoi-gl.js.map +0 -1
  86. package/dist/types/style-spec-mapbox.d.ts +0 -7
  87. package/dist/types/style-spec-mapbox.js +0 -2
  88. package/dist/types/style-spec-mapbox.js.map +0 -1
  89. package/dist/utils/apply-react-style.d.ts +0 -2
  90. package/dist/utils/apply-react-style.js +0 -16
  91. package/dist/utils/apply-react-style.js.map +0 -1
  92. package/dist/utils/assert.d.ts +0 -1
  93. package/dist/utils/assert.js +0 -6
  94. package/dist/utils/assert.js.map +0 -1
  95. package/dist/utils/deep-equal.d.ts +0 -15
  96. package/dist/utils/deep-equal.js +0 -46
  97. package/dist/utils/deep-equal.js.map +0 -1
  98. package/dist/utils/set-globals.d.ts +0 -22
  99. package/dist/utils/set-globals.js +0 -19
  100. package/dist/utils/set-globals.js.map +0 -1
  101. package/dist/utils/style-utils.d.ts +0 -2
  102. package/dist/utils/style-utils.js +0 -42
  103. package/dist/utils/style-utils.js.map +0 -1
  104. package/dist/utils/transform.d.ts +0 -26
  105. package/dist/utils/transform.js +0 -56
  106. package/dist/utils/transform.js.map +0 -1
  107. package/dist/utils/use-isomorphic-layout-effect.d.ts +0 -3
  108. package/dist/utils/use-isomorphic-layout-effect.js +0 -4
  109. package/dist/utils/use-isomorphic-layout-effect.js.map +0 -1
  110. package/src/components/attribution-control.ts +0 -32
  111. package/src/components/fullscreen-control.tsx +0 -37
  112. package/src/components/geolocate-control.ts +0 -90
  113. package/src/components/layer.ts +0 -133
  114. package/src/components/map.tsx +0 -155
  115. package/src/components/marker.ts +0 -137
  116. package/src/components/navigation-control.ts +0 -29
  117. package/src/components/popup.ts +0 -116
  118. package/src/components/scale-control.ts +0 -46
  119. package/src/components/source.ts +0 -158
  120. package/src/components/use-control.ts +0 -64
  121. package/src/components/use-map.tsx +0 -69
  122. package/src/exports-bkoi-gl.ts +0 -156
  123. package/src/exports-mapbox.ts +0 -159
  124. package/src/index.ts +0 -2
  125. package/src/mapbox/create-ref.ts +0 -118
  126. package/src/mapbox/mapbox.ts +0 -742
  127. package/src/types/common.ts +0 -94
  128. package/src/types/events-bkoi-gl.ts +0 -78
  129. package/src/types/events-mapbox.ts +0 -76
  130. package/src/types/events.ts +0 -73
  131. package/src/types/index.ts +0 -93
  132. package/src/types/lib.ts +0 -279
  133. package/src/types/public.ts +0 -9
  134. package/src/types/style-spec-bkoi-gl.ts +0 -81
  135. package/src/types/style-spec-mapbox.ts +0 -80
  136. package/src/utils/apply-react-style.ts +0 -20
  137. package/src/utils/assert.ts +0 -5
  138. package/src/utils/deep-equal.ts +0 -61
  139. package/src/utils/set-globals.ts +0 -57
  140. package/src/utils/style-utils.ts +0 -59
  141. package/src/utils/transform.ts +0 -86
  142. package/src/utils/use-isomorphic-layout-effect.ts +0 -7
@@ -1,476 +0,0 @@
1
- import { transformToViewState, applyViewStateToTransform, cloneTransform, syncProjection } from "../utils/transform.js";
2
- import { normalizeStyle } from "../utils/style-utils.js";
3
- import { deepEqual } from "../utils/deep-equal.js";
4
- const DEFAULT_STYLE = {
5
- version: 8,
6
- sources: {},
7
- layers: []
8
- };
9
- const pointerEvents = {
10
- mousedown: 'onMouseDown',
11
- mouseup: 'onMouseUp',
12
- mouseover: 'onMouseOver',
13
- mousemove: 'onMouseMove',
14
- click: 'onClick',
15
- dblclick: 'onDblClick',
16
- mouseenter: 'onMouseEnter',
17
- mouseleave: 'onMouseLeave',
18
- mouseout: 'onMouseOut',
19
- contextmenu: 'onContextMenu',
20
- touchstart: 'onTouchStart',
21
- touchend: 'onTouchEnd',
22
- touchmove: 'onTouchMove',
23
- touchcancel: 'onTouchCancel'
24
- };
25
- const cameraEvents = {
26
- movestart: 'onMoveStart',
27
- move: 'onMove',
28
- moveend: 'onMoveEnd',
29
- dragstart: 'onDragStart',
30
- drag: 'onDrag',
31
- dragend: 'onDragEnd',
32
- zoomstart: 'onZoomStart',
33
- zoom: 'onZoom',
34
- zoomend: 'onZoomEnd',
35
- rotatestart: 'onRotateStart',
36
- rotate: 'onRotate',
37
- rotateend: 'onRotateEnd',
38
- pitchstart: 'onPitchStart',
39
- pitch: 'onPitch',
40
- pitchend: 'onPitchEnd'
41
- };
42
- const otherEvents = {
43
- wheel: 'onWheel',
44
- boxzoomstart: 'onBoxZoomStart',
45
- boxzoomend: 'onBoxZoomEnd',
46
- boxzoomcancel: 'onBoxZoomCancel',
47
- resize: 'onResize',
48
- load: 'onLoad',
49
- render: 'onRender',
50
- idle: 'onIdle',
51
- remove: 'onRemove',
52
- data: 'onData',
53
- styledata: 'onStyleData',
54
- sourcedata: 'onSourceData',
55
- error: 'onError'
56
- };
57
- const settingNames = ['minZoom', 'maxZoom', 'minPitch', 'maxPitch', 'maxBounds', 'projection', 'renderWorldCopies'];
58
- const handlerNames = ['scrollZoom', 'boxZoom', 'dragRotate', 'dragPan', 'keyboard', 'doubleClickZoom', 'touchZoomRotate', 'touchPitch'];
59
- export default class Mapbox {
60
- _map = null;
61
- _internalUpdate = false;
62
- _inRender = false;
63
- _hoveredFeatures = null;
64
- _deferredEvents = {
65
- move: false,
66
- zoom: false,
67
- pitch: false,
68
- rotate: false
69
- };
70
- static savedMaps = [];
71
- constructor(MapClass, props, container) {
72
- this._MapClass = MapClass;
73
- this.props = props;
74
- this._initialize(container);
75
- }
76
- get map() {
77
- return this._map;
78
- }
79
- get transform() {
80
- return this._renderTransform;
81
- }
82
- setProps(props) {
83
- const oldProps = this.props;
84
- this.props = props;
85
- const settingsChanged = this._updateSettings(props, oldProps);
86
- if (settingsChanged) {
87
- this._createShadowTransform(this._map);
88
- }
89
- const sizeChanged = this._updateSize(props);
90
- const viewStateChanged = this._updateViewState(props, true);
91
- this._updateStyle(props, oldProps);
92
- this._updateStyleComponents(props, oldProps);
93
- this._updateHandlers(props, oldProps);
94
- if (settingsChanged || sizeChanged || viewStateChanged && !this._map.isMoving()) {
95
- this.redraw();
96
- }
97
- }
98
- static reuse(props, container) {
99
- const that = Mapbox.savedMaps.pop();
100
- if (!that) {
101
- return null;
102
- }
103
- const map = that.map;
104
- const oldContainer = map.getContainer();
105
- container.className = oldContainer.className;
106
- while (oldContainer.childNodes.length > 0) {
107
- container.appendChild(oldContainer.childNodes[0]);
108
- }
109
- map._container = container;
110
- const resizeObserver = map._resizeObserver;
111
- if (resizeObserver) {
112
- resizeObserver.disconnect();
113
- resizeObserver.observe(container);
114
- }
115
- that.setProps({
116
- ...props,
117
- styleDiffing: false
118
- });
119
- map.resize();
120
- const {
121
- initialViewState
122
- } = props;
123
- if (initialViewState) {
124
- if (initialViewState.bounds) {
125
- map.fitBounds(initialViewState.bounds, {
126
- ...initialViewState.fitBoundsOptions,
127
- duration: 0
128
- });
129
- } else {
130
- that._updateViewState(initialViewState, false);
131
- }
132
- }
133
- if (map.isStyleLoaded()) {
134
- map.fire('load');
135
- } else {
136
- map.once('styledata', () => map.fire('load'));
137
- }
138
- map._update();
139
- return that;
140
- }
141
- _initialize(container) {
142
- const {
143
- props
144
- } = this;
145
- const {
146
- mapStyle = DEFAULT_STYLE
147
- } = props;
148
- const mapOptions = {
149
- ...props,
150
- ...props.initialViewState,
151
- accessToken: props.mapboxAccessToken || getAccessTokenFromEnv() || null,
152
- container,
153
- style: normalizeStyle(mapStyle)
154
- };
155
- const viewState = mapOptions.initialViewState || mapOptions.viewState || mapOptions;
156
- Object.assign(mapOptions, {
157
- center: [viewState.longitude || 0, viewState.latitude || 0],
158
- zoom: viewState.zoom || 0,
159
- pitch: viewState.pitch || 0,
160
- bearing: viewState.bearing || 0
161
- });
162
- if (props.gl) {
163
- const getContext = HTMLCanvasElement.prototype.getContext;
164
- HTMLCanvasElement.prototype.getContext = () => {
165
- HTMLCanvasElement.prototype.getContext = getContext;
166
- return props.gl;
167
- };
168
- }
169
- const map = new this._MapClass(mapOptions);
170
- if (viewState.padding) {
171
- map.setPadding(viewState.padding);
172
- }
173
- if (props.cursor) {
174
- map.getCanvas().style.cursor = props.cursor;
175
- }
176
- this._createShadowTransform(map);
177
- const renderMap = map._render;
178
- map._render = arg => {
179
- this._inRender = true;
180
- renderMap.call(map, arg);
181
- this._inRender = false;
182
- };
183
- const runRenderTaskQueue = map._renderTaskQueue.run;
184
- map._renderTaskQueue.run = arg => {
185
- runRenderTaskQueue.call(map._renderTaskQueue, arg);
186
- this._onBeforeRepaint();
187
- };
188
- map.on('render', () => this._onAfterRepaint());
189
- const fireEvent = map.fire;
190
- map.fire = this._fireEvent.bind(this, fireEvent);
191
- map.on('resize', () => {
192
- this._renderTransform.resize(map.transform.width, map.transform.height);
193
- });
194
- map.on('styledata', () => {
195
- this._updateStyleComponents(this.props, {});
196
- syncProjection(map.transform, this._renderTransform);
197
- });
198
- map.on('sourcedata', () => this._updateStyleComponents(this.props, {}));
199
- for (const eventName in pointerEvents) {
200
- map.on(eventName, this._onPointerEvent);
201
- }
202
- for (const eventName in cameraEvents) {
203
- map.on(eventName, this._onCameraEvent);
204
- }
205
- for (const eventName in otherEvents) {
206
- map.on(eventName, this._onEvent);
207
- }
208
- this._map = map;
209
- }
210
- recycle() {
211
- const container = this.map.getContainer();
212
- const children = container.querySelector('[mapboxgl-children]');
213
- children?.remove();
214
- Mapbox.savedMaps.push(this);
215
- }
216
- destroy() {
217
- this._map.remove();
218
- }
219
- redraw() {
220
- const map = this._map;
221
- if (!this._inRender && map.style) {
222
- if (map._frame) {
223
- map._frame.cancel();
224
- map._frame = null;
225
- }
226
- map._render();
227
- }
228
- }
229
- _createShadowTransform(map) {
230
- const renderTransform = cloneTransform(map.transform);
231
- map.painter.transform = renderTransform;
232
- this._renderTransform = renderTransform;
233
- }
234
- _updateSize(nextProps) {
235
- const {
236
- viewState
237
- } = nextProps;
238
- if (viewState) {
239
- const map = this._map;
240
- if (viewState.width !== map.transform.width || viewState.height !== map.transform.height) {
241
- map.resize();
242
- return true;
243
- }
244
- }
245
- return false;
246
- }
247
- _updateViewState(nextProps, triggerEvents) {
248
- if (this._internalUpdate) {
249
- return false;
250
- }
251
- const map = this._map;
252
- const tr = this._renderTransform;
253
- const {
254
- zoom,
255
- pitch,
256
- bearing
257
- } = tr;
258
- const isMoving = map.isMoving();
259
- if (isMoving) {
260
- tr.cameraElevationReference = 'sea';
261
- }
262
- const changed = applyViewStateToTransform(tr, {
263
- ...transformToViewState(map.transform),
264
- ...nextProps
265
- });
266
- if (isMoving) {
267
- tr.cameraElevationReference = 'ground';
268
- }
269
- if (changed && triggerEvents) {
270
- const deferredEvents = this._deferredEvents;
271
- deferredEvents.move = true;
272
- deferredEvents.zoom ||= zoom !== tr.zoom;
273
- deferredEvents.rotate ||= bearing !== tr.bearing;
274
- deferredEvents.pitch ||= pitch !== tr.pitch;
275
- }
276
- if (!isMoving) {
277
- applyViewStateToTransform(map.transform, nextProps);
278
- }
279
- return changed;
280
- }
281
- _updateSettings(nextProps, currProps) {
282
- const map = this._map;
283
- let changed = false;
284
- for (const propName of settingNames) {
285
- if (propName in nextProps && !deepEqual(nextProps[propName], currProps[propName])) {
286
- changed = true;
287
- const setter = map[`set${propName[0].toUpperCase()}${propName.slice(1)}`];
288
- setter?.call(map, nextProps[propName]);
289
- }
290
- }
291
- return changed;
292
- }
293
- _updateStyle(nextProps, currProps) {
294
- if (nextProps.cursor !== currProps.cursor) {
295
- this._map.getCanvas().style.cursor = nextProps.cursor || '';
296
- }
297
- if (nextProps.mapStyle !== currProps.mapStyle) {
298
- const {
299
- mapStyle = DEFAULT_STYLE,
300
- styleDiffing = true
301
- } = nextProps;
302
- const options = {
303
- diff: styleDiffing
304
- };
305
- if ('localIdeographFontFamily' in nextProps) {
306
- options.localIdeographFontFamily = nextProps.localIdeographFontFamily;
307
- }
308
- this._map.setStyle(normalizeStyle(mapStyle), options);
309
- return true;
310
- }
311
- return false;
312
- }
313
- _updateStyleComponents(nextProps, currProps) {
314
- const map = this._map;
315
- let changed = false;
316
- if (map.isStyleLoaded()) {
317
- if ('light' in nextProps && map.setLight && !deepEqual(nextProps.light, currProps.light)) {
318
- changed = true;
319
- map.setLight(nextProps.light);
320
- }
321
- if ('fog' in nextProps && map.setFog && !deepEqual(nextProps.fog, currProps.fog)) {
322
- changed = true;
323
- map.setFog(nextProps.fog);
324
- }
325
- if ('terrain' in nextProps && map.setTerrain && !deepEqual(nextProps.terrain, currProps.terrain)) {
326
- if (!nextProps.terrain || map.getSource(nextProps.terrain.source)) {
327
- changed = true;
328
- map.setTerrain(nextProps.terrain);
329
- }
330
- }
331
- }
332
- return changed;
333
- }
334
- _updateHandlers(nextProps, currProps) {
335
- const map = this._map;
336
- let changed = false;
337
- for (const propName of handlerNames) {
338
- const newValue = nextProps[propName] ?? true;
339
- const oldValue = currProps[propName] ?? true;
340
- if (!deepEqual(newValue, oldValue)) {
341
- changed = true;
342
- if (newValue) {
343
- map[propName].enable(newValue);
344
- } else {
345
- map[propName].disable();
346
- }
347
- }
348
- }
349
- return changed;
350
- }
351
- _onEvent = e => {
352
- const cb = this.props[otherEvents[e.type]];
353
- if (cb) {
354
- cb(e);
355
- } else if (e.type === 'error') {
356
- console.error(e.error);
357
- }
358
- };
359
- _queryRenderedFeatures(point) {
360
- const map = this._map;
361
- const tr = map.transform;
362
- const {
363
- interactiveLayerIds = []
364
- } = this.props;
365
- try {
366
- map.transform = this._renderTransform;
367
- return map.queryRenderedFeatures(point, {
368
- layers: interactiveLayerIds.filter(map.getLayer.bind(map))
369
- });
370
- } catch {
371
- return [];
372
- } finally {
373
- map.transform = tr;
374
- }
375
- }
376
- _updateHover(e) {
377
- const {
378
- props
379
- } = this;
380
- const shouldTrackHoveredFeatures = props.interactiveLayerIds && (props.onMouseMove || props.onMouseEnter || props.onMouseLeave);
381
- if (shouldTrackHoveredFeatures) {
382
- const eventType = e.type;
383
- const wasHovering = this._hoveredFeatures?.length > 0;
384
- const features = this._queryRenderedFeatures(e.point);
385
- const isHovering = features.length > 0;
386
- if (!isHovering && wasHovering) {
387
- e.type = 'mouseleave';
388
- this._onPointerEvent(e);
389
- }
390
- this._hoveredFeatures = features;
391
- if (isHovering && !wasHovering) {
392
- e.type = 'mouseenter';
393
- this._onPointerEvent(e);
394
- }
395
- e.type = eventType;
396
- } else {
397
- this._hoveredFeatures = null;
398
- }
399
- }
400
- _onPointerEvent = e => {
401
- if (e.type === 'mousemove' || e.type === 'mouseout') {
402
- this._updateHover(e);
403
- }
404
- const cb = this.props[pointerEvents[e.type]];
405
- if (cb) {
406
- if (this.props.interactiveLayerIds && e.type !== 'mouseover' && e.type !== 'mouseout') {
407
- e.features = this._hoveredFeatures || this._queryRenderedFeatures(e.point);
408
- }
409
- cb(e);
410
- delete e.features;
411
- }
412
- };
413
- _onCameraEvent = e => {
414
- if (!this._internalUpdate) {
415
- const cb = this.props[cameraEvents[e.type]];
416
- if (cb) {
417
- cb(e);
418
- }
419
- }
420
- if (e.type in this._deferredEvents) {
421
- this._deferredEvents[e.type] = false;
422
- }
423
- };
424
- _fireEvent(baseFire, event, properties) {
425
- const map = this._map;
426
- const tr = map.transform;
427
- const eventType = typeof event === 'string' ? event : event.type;
428
- if (eventType === 'move') {
429
- this._updateViewState(this.props, false);
430
- }
431
- if (eventType in cameraEvents) {
432
- if (typeof event === 'object') {
433
- event.viewState = transformToViewState(tr);
434
- }
435
- if (this._map.isMoving()) {
436
- map.transform = this._renderTransform;
437
- baseFire.call(map, event, properties);
438
- map.transform = tr;
439
- return map;
440
- }
441
- }
442
- baseFire.call(map, event, properties);
443
- return map;
444
- }
445
- _onBeforeRepaint() {
446
- const map = this._map;
447
- this._internalUpdate = true;
448
- for (const eventType in this._deferredEvents) {
449
- if (this._deferredEvents[eventType]) {
450
- map.fire(eventType);
451
- }
452
- }
453
- this._internalUpdate = false;
454
- const tr = this._map.transform;
455
- map.transform = this._renderTransform;
456
- this._onAfterRepaint = () => {
457
- syncProjection(this._renderTransform, tr);
458
- map.transform = tr;
459
- };
460
- }
461
- }
462
- function getAccessTokenFromEnv() {
463
- let accessToken = null;
464
- if (typeof location !== 'undefined') {
465
- const match = /access_token=([^&\/]*)/.exec(location.search);
466
- accessToken = match && match[1];
467
- }
468
- try {
469
- accessToken = accessToken || process.env.MapboxAccessToken;
470
- } catch {}
471
- try {
472
- accessToken = accessToken || process.env.REACT_APP_MAPBOX_ACCESS_TOKEN;
473
- } catch {}
474
- return accessToken;
475
- }
476
- //# sourceMappingURL=mapbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapbox.js","names":["transformToViewState","applyViewStateToTransform","cloneTransform","syncProjection","normalizeStyle","deepEqual","DEFAULT_STYLE","version","sources","layers","pointerEvents","mousedown","mouseup","mouseover","mousemove","click","dblclick","mouseenter","mouseleave","mouseout","contextmenu","touchstart","touchend","touchmove","touchcancel","cameraEvents","movestart","move","moveend","dragstart","drag","dragend","zoomstart","zoom","zoomend","rotatestart","rotate","rotateend","pitchstart","pitch","pitchend","otherEvents","wheel","boxzoomstart","boxzoomend","boxzoomcancel","resize","load","render","idle","remove","data","styledata","sourcedata","error","settingNames","handlerNames","Mapbox","_map","_internalUpdate","_inRender","_hoveredFeatures","_deferredEvents","savedMaps","constructor","MapClass","props","container","_MapClass","_initialize","map","transform","_renderTransform","setProps","oldProps","settingsChanged","_updateSettings","_createShadowTransform","sizeChanged","_updateSize","viewStateChanged","_updateViewState","_updateStyle","_updateStyleComponents","_updateHandlers","isMoving","redraw","reuse","that","pop","oldContainer","getContainer","className","childNodes","length","appendChild","_container","resizeObserver","_resizeObserver","disconnect","observe","styleDiffing","initialViewState","bounds","fitBounds","fitBoundsOptions","duration","isStyleLoaded","fire","once","_update","mapStyle","mapOptions","accessToken","mapboxAccessToken","getAccessTokenFromEnv","style","viewState","Object","assign","center","longitude","latitude","bearing","gl","getContext","HTMLCanvasElement","prototype","padding","setPadding","cursor","getCanvas","renderMap","_render","arg","call","runRenderTaskQueue","_renderTaskQueue","run","_onBeforeRepaint","on","_onAfterRepaint","fireEvent","_fireEvent","bind","width","height","eventName","_onPointerEvent","_onCameraEvent","_onEvent","recycle","children","querySelector","push","destroy","_frame","cancel","renderTransform","painter","nextProps","triggerEvents","tr","cameraElevationReference","changed","deferredEvents","currProps","propName","setter","toUpperCase","slice","options","diff","localIdeographFontFamily","setStyle","setLight","light","setFog","fog","setTerrain","terrain","getSource","source","newValue","oldValue","enable","disable","e","cb","type","console","_queryRenderedFeatures","point","interactiveLayerIds","queryRenderedFeatures","filter","getLayer","_updateHover","shouldTrackHoveredFeatures","onMouseMove","onMouseEnter","onMouseLeave","eventType","wasHovering","features","isHovering","baseFire","event","properties","location","match","exec","search","process","env","MapboxAccessToken","REACT_APP_MAPBOX_ACCESS_TOKEN"],"sources":["../../src/mapbox/mapbox.ts"],"sourcesContent":["import {\n transformToViewState,\n applyViewStateToTransform,\n cloneTransform,\n syncProjection\n} from '../utils/transform';\nimport {normalizeStyle} from '../utils/style-utils';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type {\n Transform,\n ViewState,\n ViewStateChangeEvent,\n Point,\n PointLike,\n PaddingOptions,\n MapStyle,\n ImmutableLike,\n LngLatBoundsLike,\n Callbacks,\n MapEvent,\n ErrorEvent,\n MapMouseEvent,\n MapGeoJSONFeature,\n MapInstance,\n MapInstanceInternal\n} from '../types';\n\nexport type MapboxProps<\n StyleT extends MapStyle = MapStyle,\n CallbacksT extends Callbacks = {}\n> = Partial<ViewState> &\n CallbacksT & {\n // Init options\n mapboxAccessToken?: string;\n\n /** Camera options used when constructing the Map instance */\n initialViewState?: Partial<ViewState> & {\n /** The initial bounds of the map. If bounds is specified, it overrides longitude, latitude and zoom options. */\n bounds?: LngLatBoundsLike;\n /** A fitBounds options object to use only when setting the bounds option. */\n fitBoundsOptions?: {\n offset?: PointLike;\n minZoom?: number;\n maxZoom?: number;\n padding?: number | PaddingOptions;\n };\n };\n\n /** If provided, render into an external WebGL context */\n gl?: WebGLRenderingContext;\n\n /** For external controller to override the camera state */\n viewState?: ViewState & {\n width: number;\n height: number;\n };\n\n // Styling\n\n /** Mapbox style */\n mapStyle?: string | StyleT | ImmutableLike<StyleT>;\n /** Enable diffing when the map style changes\n * @default true\n */\n styleDiffing?: boolean;\n /** The fog property of the style. Must conform to the Fog Style Specification .\n * If `undefined` is provided, removes the fog from the map. */\n fog?: StyleT['fog'];\n /** Light properties of the map. */\n light?: StyleT['light'];\n /** Terrain property of the style. Must conform to the Terrain Style Specification .\n * If `undefined` is provided, removes terrain from the map. */\n terrain?: StyleT['terrain'];\n\n /** Default layers to query on pointer events */\n interactiveLayerIds?: string[];\n /** CSS cursor */\n cursor?: string;\n };\n\nconst DEFAULT_STYLE = {version: 8, sources: {}, layers: []} as MapStyle;\n\nconst pointerEvents = {\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mouseover: 'onMouseOver',\n mousemove: 'onMouseMove',\n click: 'onClick',\n dblclick: 'onDblClick',\n mouseenter: 'onMouseEnter',\n mouseleave: 'onMouseLeave',\n mouseout: 'onMouseOut',\n contextmenu: 'onContextMenu',\n touchstart: 'onTouchStart',\n touchend: 'onTouchEnd',\n touchmove: 'onTouchMove',\n touchcancel: 'onTouchCancel'\n};\nconst cameraEvents = {\n movestart: 'onMoveStart',\n move: 'onMove',\n moveend: 'onMoveEnd',\n dragstart: 'onDragStart',\n drag: 'onDrag',\n dragend: 'onDragEnd',\n zoomstart: 'onZoomStart',\n zoom: 'onZoom',\n zoomend: 'onZoomEnd',\n rotatestart: 'onRotateStart',\n rotate: 'onRotate',\n rotateend: 'onRotateEnd',\n pitchstart: 'onPitchStart',\n pitch: 'onPitch',\n pitchend: 'onPitchEnd'\n};\nconst otherEvents = {\n wheel: 'onWheel',\n boxzoomstart: 'onBoxZoomStart',\n boxzoomend: 'onBoxZoomEnd',\n boxzoomcancel: 'onBoxZoomCancel',\n resize: 'onResize',\n load: 'onLoad',\n render: 'onRender',\n idle: 'onIdle',\n remove: 'onRemove',\n data: 'onData',\n styledata: 'onStyleData',\n sourcedata: 'onSourceData',\n error: 'onError'\n};\nconst settingNames = [\n 'minZoom',\n 'maxZoom',\n 'minPitch',\n 'maxPitch',\n 'maxBounds',\n 'projection',\n 'renderWorldCopies'\n];\nconst handlerNames = [\n 'scrollZoom',\n 'boxZoom',\n 'dragRotate',\n 'dragPan',\n 'keyboard',\n 'doubleClickZoom',\n 'touchZoomRotate',\n 'touchPitch'\n];\n\n/**\n * A wrapper for mapbox-gl's Map class\n */\nexport default class Mapbox<\n StyleT extends MapStyle = MapStyle,\n CallbacksT extends Callbacks = {},\n MapT extends MapInstance = MapInstance\n> {\n private _MapClass: {new (options: any): MapInstance};\n // mapboxgl.Map instance\n private _map: MapInstanceInternal<MapT> = null;\n // User-supplied props\n props: MapboxProps<StyleT, CallbacksT>;\n\n // Mapbox map is stateful.\n // During method calls/user interactions, map.transform is mutated and\n // deviate from user-supplied props.\n // In order to control the map reactively, we shadow the transform\n // with the one below, which reflects the view state resolved from\n // both user-supplied props and the underlying state\n private _renderTransform: Transform;\n\n // Internal states\n private _internalUpdate: boolean = false;\n private _inRender: boolean = false;\n private _hoveredFeatures: MapGeoJSONFeature[] = null;\n private _deferredEvents: {\n move: boolean;\n zoom: boolean;\n pitch: boolean;\n rotate: boolean;\n } = {\n move: false,\n zoom: false,\n pitch: false,\n rotate: false\n };\n\n static savedMaps: Mapbox[] = [];\n\n constructor(\n MapClass: {new (options: any): MapInstance},\n props: MapboxProps<StyleT, CallbacksT>,\n container: HTMLDivElement\n ) {\n this._MapClass = MapClass;\n this.props = props;\n this._initialize(container);\n }\n\n get map(): MapT {\n return this._map;\n }\n\n get transform(): Transform {\n return this._renderTransform;\n }\n\n setProps(props: MapboxProps<StyleT, CallbacksT>) {\n const oldProps = this.props;\n this.props = props;\n\n const settingsChanged = this._updateSettings(props, oldProps);\n if (settingsChanged) {\n this._createShadowTransform(this._map);\n }\n const sizeChanged = this._updateSize(props);\n const viewStateChanged = this._updateViewState(props, true);\n this._updateStyle(props, oldProps);\n this._updateStyleComponents(props, oldProps);\n this._updateHandlers(props, oldProps);\n\n // If 1) view state has changed to match props and\n // 2) the props change is not triggered by map events,\n // it's driven by an external state change. Redraw immediately\n if (settingsChanged || sizeChanged || (viewStateChanged && !this._map.isMoving())) {\n this.redraw();\n }\n }\n\n static reuse<StyleT extends MapStyle, CallbacksT extends Callbacks, MapT extends MapInstance>(\n props: MapboxProps<StyleT, CallbacksT>,\n container: HTMLDivElement\n ): Mapbox<StyleT, CallbacksT, MapT> {\n const that = Mapbox.savedMaps.pop() as Mapbox<StyleT, CallbacksT, MapT>;\n if (!that) {\n return null;\n }\n\n const map = that.map;\n // When reusing the saved map, we need to reparent the map(canvas) and other child nodes\n // intoto the new container from the props.\n // Step 1: reparenting child nodes from old container to new container\n const oldContainer = map.getContainer();\n container.className = oldContainer.className;\n while (oldContainer.childNodes.length > 0) {\n container.appendChild(oldContainer.childNodes[0]);\n }\n // Step 2: replace the internal container with new container from the react component\n // @ts-ignore\n map._container = container;\n\n // With maplibre-gl as mapLib, map uses ResizeObserver to observe when its container resizes.\n // When reusing the saved map, we need to disconnect the observer and observe the new container.\n // Step 3: telling the ResizeObserver to disconnect and observe the new container\n // @ts-ignore\n const resizeObserver = map._resizeObserver;\n if (resizeObserver) {\n resizeObserver.disconnect();\n resizeObserver.observe(container);\n }\n\n // Step 4: apply new props\n that.setProps({...props, styleDiffing: false});\n map.resize();\n const {initialViewState} = props;\n if (initialViewState) {\n if (initialViewState.bounds) {\n map.fitBounds(initialViewState.bounds, {...initialViewState.fitBoundsOptions, duration: 0});\n } else {\n that._updateViewState(initialViewState, false);\n }\n }\n\n // Simulate load event\n if (map.isStyleLoaded()) {\n map.fire('load');\n } else {\n map.once('styledata', () => map.fire('load'));\n }\n\n // Force reload\n // @ts-ignore\n map._update();\n return that;\n }\n\n /* eslint-disable complexity,max-statements */\n _initialize(container: HTMLDivElement) {\n const {props} = this;\n const {mapStyle = DEFAULT_STYLE} = props;\n const mapOptions = {\n ...props,\n ...props.initialViewState,\n accessToken: props.mapboxAccessToken || getAccessTokenFromEnv() || null,\n container,\n style: normalizeStyle(mapStyle)\n };\n\n const viewState = mapOptions.initialViewState || mapOptions.viewState || mapOptions;\n Object.assign(mapOptions, {\n center: [viewState.longitude || 0, viewState.latitude || 0],\n zoom: viewState.zoom || 0,\n pitch: viewState.pitch || 0,\n bearing: viewState.bearing || 0\n });\n\n if (props.gl) {\n // eslint-disable-next-line\n const getContext = HTMLCanvasElement.prototype.getContext;\n // Hijack canvas.getContext to return our own WebGLContext\n // This will be called inside the mapboxgl.Map constructor\n // @ts-expect-error\n HTMLCanvasElement.prototype.getContext = () => {\n // Unhijack immediately\n HTMLCanvasElement.prototype.getContext = getContext;\n return props.gl;\n };\n }\n\n const map = new this._MapClass(mapOptions) as MapInstanceInternal<MapT>;\n // Props that are not part of constructor options\n if (viewState.padding) {\n map.setPadding(viewState.padding);\n }\n if (props.cursor) {\n map.getCanvas().style.cursor = props.cursor;\n }\n this._createShadowTransform(map);\n\n // Hack\n // Insert code into map's render cycle\n const renderMap = map._render;\n map._render = (arg: number) => {\n this._inRender = true;\n renderMap.call(map, arg);\n this._inRender = false;\n };\n const runRenderTaskQueue = map._renderTaskQueue.run;\n map._renderTaskQueue.run = (arg: number) => {\n runRenderTaskQueue.call(map._renderTaskQueue, arg);\n this._onBeforeRepaint();\n };\n map.on('render', () => this._onAfterRepaint());\n // Insert code into map's event pipeline\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const fireEvent = map.fire;\n map.fire = this._fireEvent.bind(this, fireEvent);\n\n // add listeners\n map.on('resize', () => {\n this._renderTransform.resize(map.transform.width, map.transform.height);\n });\n map.on('styledata', () => {\n this._updateStyleComponents(this.props, {});\n // Projection can be set in stylesheet\n syncProjection(map.transform, this._renderTransform);\n });\n map.on('sourcedata', () => this._updateStyleComponents(this.props, {}));\n for (const eventName in pointerEvents) {\n map.on(eventName, this._onPointerEvent);\n }\n for (const eventName in cameraEvents) {\n map.on(eventName, this._onCameraEvent);\n }\n for (const eventName in otherEvents) {\n map.on(eventName, this._onEvent);\n }\n this._map = map;\n }\n /* eslint-enable complexity,max-statements */\n\n recycle() {\n // Clean up unnecessary elements before storing for reuse.\n const container = this.map.getContainer();\n const children = container.querySelector('[mapboxgl-children]');\n children?.remove();\n\n Mapbox.savedMaps.push(this);\n }\n\n destroy() {\n this._map.remove();\n }\n\n // Force redraw the map now. Typically resize() and jumpTo() is reflected in the next\n // render cycle, which is managed by Mapbox's animation loop.\n // This removes the synchronization issue caused by requestAnimationFrame.\n redraw() {\n const map = this._map as any;\n // map._render will throw error if style does not exist\n // https://github.com/mapbox/mapbox-gl-js/blob/fb9fc316da14e99ff4368f3e4faa3888fb43c513\n // /src/ui/map.js#L1834\n if (!this._inRender && map.style) {\n // cancel the scheduled update\n if (map._frame) {\n map._frame.cancel();\n map._frame = null;\n }\n // the order is important - render() may schedule another update\n map._render();\n }\n }\n\n _createShadowTransform(map: any) {\n const renderTransform = cloneTransform(map.transform);\n map.painter.transform = renderTransform;\n\n this._renderTransform = renderTransform;\n }\n\n /* Trigger map resize if size is controlled\n @param {object} nextProps\n @returns {bool} true if size has changed\n */\n _updateSize(nextProps: MapboxProps<StyleT>): boolean {\n // Check if size is controlled\n const {viewState} = nextProps;\n if (viewState) {\n const map = this._map;\n if (viewState.width !== map.transform.width || viewState.height !== map.transform.height) {\n map.resize();\n return true;\n }\n }\n return false;\n }\n\n // Adapted from map.jumpTo\n /* Update camera to match props\n @param {object} nextProps\n @param {bool} triggerEvents - should fire camera events\n @returns {bool} true if anything is changed\n */\n _updateViewState(nextProps: MapboxProps<StyleT>, triggerEvents: boolean): boolean {\n if (this._internalUpdate) {\n return false;\n }\n const map = this._map;\n\n const tr = this._renderTransform;\n // Take a snapshot of the transform before mutation\n const {zoom, pitch, bearing} = tr;\n const isMoving = map.isMoving();\n\n if (isMoving) {\n // All movement of the camera is done relative to the sea level\n tr.cameraElevationReference = 'sea';\n }\n const changed = applyViewStateToTransform(tr, {\n ...transformToViewState(map.transform),\n ...nextProps\n });\n if (isMoving) {\n // Reset camera reference\n tr.cameraElevationReference = 'ground';\n }\n\n if (changed && triggerEvents) {\n const deferredEvents = this._deferredEvents;\n // Delay DOM control updates to the next render cycle\n deferredEvents.move = true;\n deferredEvents.zoom ||= zoom !== tr.zoom;\n deferredEvents.rotate ||= bearing !== tr.bearing;\n deferredEvents.pitch ||= pitch !== tr.pitch;\n }\n\n // Avoid manipulating the real transform when interaction/animation is ongoing\n // as it would interfere with Mapbox's handlers\n if (!isMoving) {\n applyViewStateToTransform(map.transform, nextProps);\n }\n\n return changed;\n }\n\n /* Update camera constraints and projection settings to match props\n @param {object} nextProps\n @param {object} currProps\n @returns {bool} true if anything is changed\n */\n _updateSettings(nextProps: MapboxProps<StyleT>, currProps: MapboxProps<StyleT>): boolean {\n const map = this._map;\n let changed = false;\n for (const propName of settingNames) {\n if (propName in nextProps && !deepEqual(nextProps[propName], currProps[propName])) {\n changed = true;\n const setter = map[`set${propName[0].toUpperCase()}${propName.slice(1)}`];\n setter?.call(map, nextProps[propName]);\n }\n }\n return changed;\n }\n\n /* Update map style to match props\n @param {object} nextProps\n @param {object} currProps\n @returns {bool} true if style is changed\n */\n _updateStyle(nextProps: MapboxProps<StyleT>, currProps: MapboxProps<StyleT>): boolean {\n if (nextProps.cursor !== currProps.cursor) {\n this._map.getCanvas().style.cursor = nextProps.cursor || '';\n }\n if (nextProps.mapStyle !== currProps.mapStyle) {\n const {mapStyle = DEFAULT_STYLE, styleDiffing = true} = nextProps;\n const options: any = {\n diff: styleDiffing\n };\n if ('localIdeographFontFamily' in nextProps) {\n // @ts-ignore Mapbox specific prop\n options.localIdeographFontFamily = nextProps.localIdeographFontFamily;\n }\n this._map.setStyle(normalizeStyle(mapStyle), options);\n return true;\n }\n return false;\n }\n\n /* Update fog, light and terrain to match props\n @param {object} nextProps\n @param {object} currProps\n @returns {bool} true if anything is changed\n */\n _updateStyleComponents(nextProps: MapboxProps<StyleT>, currProps: MapboxProps<StyleT>): boolean {\n const map = this._map;\n let changed = false;\n if (map.isStyleLoaded()) {\n if ('light' in nextProps && map.setLight && !deepEqual(nextProps.light, currProps.light)) {\n changed = true;\n map.setLight(nextProps.light);\n }\n if ('fog' in nextProps && map.setFog && !deepEqual(nextProps.fog, currProps.fog)) {\n changed = true;\n map.setFog(nextProps.fog);\n }\n if (\n 'terrain' in nextProps &&\n map.setTerrain &&\n !deepEqual(nextProps.terrain, currProps.terrain)\n ) {\n if (!nextProps.terrain || map.getSource(nextProps.terrain.source)) {\n changed = true;\n map.setTerrain(nextProps.terrain);\n }\n }\n }\n return changed;\n }\n\n /* Update interaction handlers to match props\n @param {object} nextProps\n @param {object} currProps\n @returns {bool} true if anything is changed\n */\n _updateHandlers(nextProps: MapboxProps<StyleT>, currProps: MapboxProps<StyleT>): boolean {\n const map = this._map;\n let changed = false;\n for (const propName of handlerNames) {\n const newValue = nextProps[propName] ?? true;\n const oldValue = currProps[propName] ?? true;\n if (!deepEqual(newValue, oldValue)) {\n changed = true;\n if (newValue) {\n map[propName].enable(newValue);\n } else {\n map[propName].disable();\n }\n }\n }\n return changed;\n }\n\n _onEvent = (e: MapEvent<MapT>) => {\n // @ts-ignore\n const cb = this.props[otherEvents[e.type]];\n if (cb) {\n cb(e);\n } else if (e.type === 'error') {\n console.error((e as ErrorEvent<MapT>).error); // eslint-disable-line\n }\n };\n\n private _queryRenderedFeatures(point: Point) {\n const map = this._map;\n const tr = map.transform;\n const {interactiveLayerIds = []} = this.props;\n try {\n map.transform = this._renderTransform;\n return map.queryRenderedFeatures(point, {\n layers: interactiveLayerIds.filter(map.getLayer.bind(map))\n });\n } catch {\n // May fail if style is not loaded\n return [];\n } finally {\n map.transform = tr;\n }\n }\n\n _updateHover(e: MapMouseEvent<MapT>) {\n const {props} = this;\n const shouldTrackHoveredFeatures =\n props.interactiveLayerIds && (props.onMouseMove || props.onMouseEnter || props.onMouseLeave);\n\n if (shouldTrackHoveredFeatures) {\n const eventType = e.type;\n const wasHovering = this._hoveredFeatures?.length > 0;\n const features = this._queryRenderedFeatures(e.point);\n const isHovering = features.length > 0;\n\n if (!isHovering && wasHovering) {\n e.type = 'mouseleave';\n this._onPointerEvent(e);\n }\n this._hoveredFeatures = features;\n if (isHovering && !wasHovering) {\n e.type = 'mouseenter';\n this._onPointerEvent(e);\n }\n e.type = eventType;\n } else {\n this._hoveredFeatures = null;\n }\n }\n\n _onPointerEvent = (e: MapMouseEvent<MapT> | MapMouseEvent<MapT>) => {\n if (e.type === 'mousemove' || e.type === 'mouseout') {\n this._updateHover(e);\n }\n\n // @ts-ignore\n const cb = this.props[pointerEvents[e.type]];\n if (cb) {\n if (this.props.interactiveLayerIds && e.type !== 'mouseover' && e.type !== 'mouseout') {\n e.features = this._hoveredFeatures || this._queryRenderedFeatures(e.point);\n }\n cb(e);\n delete e.features;\n }\n };\n\n _onCameraEvent = (e: ViewStateChangeEvent<MapT>) => {\n if (!this._internalUpdate) {\n // @ts-ignore\n const cb = this.props[cameraEvents[e.type]];\n if (cb) {\n cb(e);\n }\n }\n if (e.type in this._deferredEvents) {\n this._deferredEvents[e.type] = false;\n }\n };\n\n _fireEvent(baseFire: Function, event: string | MapEvent<MapT>, properties?: object) {\n const map = this._map;\n const tr = map.transform;\n\n const eventType = typeof event === 'string' ? event : event.type;\n if (eventType === 'move') {\n this._updateViewState(this.props, false);\n }\n if (eventType in cameraEvents) {\n if (typeof event === 'object') {\n (event as unknown as ViewStateChangeEvent<MapT>).viewState = transformToViewState(tr);\n }\n if (this._map.isMoving()) {\n // Replace map.transform with ours during the callbacks\n map.transform = this._renderTransform;\n baseFire.call(map, event, properties);\n map.transform = tr;\n\n return map;\n }\n }\n baseFire.call(map, event, properties);\n\n return map;\n }\n\n // All camera manipulations are complete, ready to repaint\n _onBeforeRepaint() {\n const map = this._map;\n\n // If there are camera changes driven by props, invoke camera events so that DOM controls are synced\n this._internalUpdate = true;\n for (const eventType in this._deferredEvents) {\n if (this._deferredEvents[eventType]) {\n map.fire(eventType);\n }\n }\n this._internalUpdate = false;\n\n const tr = this._map.transform;\n // Make sure camera matches the current props\n map.transform = this._renderTransform;\n\n this._onAfterRepaint = () => {\n // Mapbox transitions between non-mercator projection and mercator during render time\n // Copy it back to the other\n syncProjection(this._renderTransform, tr);\n // Restores camera state before render/load events are fired\n map.transform = tr;\n };\n }\n\n _onAfterRepaint: () => void;\n}\n\n/**\n * Access token can be provided via one of:\n * mapboxAccessToken prop\n * access_token query parameter\n * MapboxAccessToken environment variable\n * REACT_APP_MAPBOX_ACCESS_TOKEN environment variable\n * @returns access token\n */\nfunction getAccessTokenFromEnv(): string {\n let accessToken = null;\n\n /* global location, process */\n if (typeof location !== 'undefined') {\n const match = /access_token=([^&\\/]*)/.exec(location.search);\n accessToken = match && match[1];\n }\n\n // Note: This depends on bundler plugins (e.g. webpack) importing environment correctly\n try {\n accessToken = accessToken || process.env.MapboxAccessToken;\n } catch {\n // ignore\n }\n\n try {\n accessToken = accessToken || process.env.REACT_APP_MAPBOX_ACCESS_TOKEN;\n } catch {\n // ignore\n }\n\n return accessToken;\n}\n"],"mappings":"SACEA,oBAAoB,EACpBC,yBAAyB,EACzBC,cAAc,EACdC,cAAc;AAAA,SAERC,cAAc;AAAA,SACdC,SAAS;AA0EjB,MAAMC,aAAa,GAAG;EAACC,OAAO,EAAE,CAAC;EAAEC,OAAO,EAAE,CAAC,CAAC;EAAEC,MAAM,EAAE;AAAE,CAAa;AAEvE,MAAMC,aAAa,GAAG;EACpBC,SAAS,EAAE,aAAa;EACxBC,OAAO,EAAE,WAAW;EACpBC,SAAS,EAAE,aAAa;EACxBC,SAAS,EAAE,aAAa;EACxBC,KAAK,EAAE,SAAS;EAChBC,QAAQ,EAAE,YAAY;EACtBC,UAAU,EAAE,cAAc;EAC1BC,UAAU,EAAE,cAAc;EAC1BC,QAAQ,EAAE,YAAY;EACtBC,WAAW,EAAE,eAAe;EAC5BC,UAAU,EAAE,cAAc;EAC1BC,QAAQ,EAAE,YAAY;EACtBC,SAAS,EAAE,aAAa;EACxBC,WAAW,EAAE;AACf,CAAC;AACD,MAAMC,YAAY,GAAG;EACnBC,SAAS,EAAE,aAAa;EACxBC,IAAI,EAAE,QAAQ;EACdC,OAAO,EAAE,WAAW;EACpBC,SAAS,EAAE,a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,GAAG,IAAI;IAC3B,KAAK,MAAM+I,SAAS,IAAI,IAAI,CAAC5I,eAAe,EAAE;MAC5C,IAAI,IAAI,CAACA,eAAe,CAAC4I,SAAS,CAAC,EAAE;QACnCpI,GAAG,CAACsC,IAAI,CAAC8F,SAAS,CAAC;MACrB;IACF;IACA,IAAI,CAAC/I,eAAe,GAAG,KAAK;IAE5B,MAAMuG,EAAE,GAAG,IAAI,CAACxG,IAAI,CAACa,SAAS;IAE9BD,GAAG,CAACC,SAAS,GAAG,IAAI,CAACC,gBAAgB;IAErC,IAAI,CAACqE,eAAe,GAAG,MAAM;MAG3B1I,cAAc,CAAC,IAAI,CAACqE,gBAAgB,EAAE0F,EAAE,CAAC;MAEzC5F,GAAG,CAACC,SAAS,GAAG2F,EAAE;IACpB,CAAC;EACH;AAGF;AAUA,SAAS/C,qBAAqBA,CAAA,EAAW;EACvC,IAAIF,WAAW,GAAG,IAAI;EAGtB,IAAI,OAAOgG,QAAQ,KAAK,WAAW,EAAE;IACnC,MAAMC,KAAK,GAAG,wBAAwB,CAACC,IAAI,CAACF,QAAQ,CAACG,MAAM,CAAC;IAC5DnG,WAAW,GAAGiG,KAAK,IAAIA,KAAK,CAAC,CAAC,CAAC;EACjC;EAGA,IAAI;IACFjG,WAAW,GAAGA,WAAW,IAAIoG,OAAO,CAACC,GAAG,CAACC,iBAAiB;EAC5D,CAAC,CAAC,MAAM,CAER;EAEA,IAAI;IACFtG,WAAW,GAAGA,WAAW,IAAIoG,OAAO,CAACC,GAAG,CAACE,6BAA6B;EACxE,CAAC,CAAC,MAAM,CAER;EAEA,OAAOvG,WAAW;AACpB","ignoreList":[]}
@@ -1,78 +0,0 @@
1
- import type GeoJSON from 'geojson';
2
- /** @mapbox/point-geometry */
3
- export interface Point {
4
- x: number;
5
- y: number;
6
- }
7
- export type PointLike = Point | [number, number];
8
- export interface LngLat {
9
- lng: number;
10
- lat: number;
11
- wrap(): LngLat;
12
- /** Return a LngLat as an array */
13
- toArray(): number[];
14
- /** Return a LngLat as a string */
15
- toString(): string;
16
- /** Returns the approximate distance between a pair of coordinates in meters
17
- * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) */
18
- distanceTo(lngLat: LngLat): number;
19
- }
20
- export type LngLatLike = [number, number] | LngLat | {
21
- lng: number;
22
- lat: number;
23
- } | {
24
- lon: number;
25
- lat: number;
26
- };
27
- export interface LngLatBounds {
28
- contains(lnglat: LngLatLike): boolean;
29
- setNorthEast(ne: LngLatLike): this;
30
- setSouthWest(sw: LngLatLike): this;
31
- extend(obj: LngLatLike | LngLatBoundsLike): this;
32
- getCenter(): LngLat;
33
- getSouthWest(): LngLat;
34
- getNorthEast(): LngLat;
35
- getNorthWest(): LngLat;
36
- getSouthEast(): LngLat;
37
- getWest(): number;
38
- getSouth(): number;
39
- getEast(): number;
40
- getNorth(): number;
41
- toArray(): number[][];
42
- toString(): string;
43
- isEmpty(): boolean;
44
- }
45
- export type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number] | LngLatLike;
46
- export type MapGeoJSONFeature = GeoJSON.Feature<GeoJSON.Geometry> & {
47
- layer: any;
48
- source: string;
49
- sourceLayer: string;
50
- state: {
51
- [key: string]: any;
52
- };
53
- };
54
- export type PaddingOptions = {
55
- top: number;
56
- bottom: number;
57
- left: number;
58
- right: number;
59
- };
60
- /** Describes the camera's state */
61
- export type ViewState = {
62
- /** Longitude at map center */
63
- longitude: number;
64
- /** Latitude at map center */
65
- latitude: number;
66
- /** Map zoom level */
67
- zoom: number;
68
- /** Map rotation bearing in degrees counter-clockwise from north */
69
- bearing: number;
70
- /** Map angle in degrees at which the camera is looking at the ground */
71
- pitch: number;
72
- /** Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. */
73
- padding: PaddingOptions;
74
- };
75
- export type ControlPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
76
- export interface ImmutableLike<T> {
77
- toJS: () => T;
78
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.js","names":[],"sources":["../../src/types/common.ts"],"sourcesContent":["import type GeoJSON from 'geojson';\n\n/* Data types that are compatible with both mapbox and maplibre. Not exposed to the end user. */\n\n/** @mapbox/point-geometry */\nexport interface Point {\n x: number;\n y: number;\n}\nexport type PointLike = Point | [number, number];\n\nexport interface LngLat {\n lng: number;\n lat: number;\n\n wrap(): LngLat;\n /** Return a LngLat as an array */\n toArray(): number[];\n /** Return a LngLat as a string */\n toString(): string;\n /** Returns the approximate distance between a pair of coordinates in meters\n * Uses the Haversine Formula (from R.W. Sinnott, \"Virtues of the Haversine\", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) */\n distanceTo(lngLat: LngLat): number;\n}\nexport type LngLatLike =\n | [number, number]\n | LngLat\n | {lng: number; lat: number}\n | {lon: number; lat: number};\n\nexport interface LngLatBounds {\n contains(lnglat: LngLatLike): boolean;\n setNorthEast(ne: LngLatLike): this;\n setSouthWest(sw: LngLatLike): this;\n extend(obj: LngLatLike | LngLatBoundsLike): this;\n\n getCenter(): LngLat;\n getSouthWest(): LngLat;\n getNorthEast(): LngLat;\n getNorthWest(): LngLat;\n getSouthEast(): LngLat;\n\n getWest(): number;\n getSouth(): number;\n getEast(): number;\n getNorth(): number;\n\n toArray(): number[][];\n toString(): string;\n isEmpty(): boolean;\n}\nexport type LngLatBoundsLike =\n | LngLatBounds\n | [LngLatLike, LngLatLike]\n | [number, number, number, number]\n | LngLatLike;\n\nexport type MapGeoJSONFeature = GeoJSON.Feature<GeoJSON.Geometry> & {\n layer: any;\n source: string;\n sourceLayer: string;\n state: {[key: string]: any};\n};\n\nexport type PaddingOptions = {\n top: number;\n bottom: number;\n left: number;\n right: number;\n};\n\n/* Public */\n\n/** Describes the camera's state */\nexport type ViewState = {\n /** Longitude at map center */\n longitude: number;\n /** Latitude at map center */\n latitude: number;\n /** Map zoom level */\n zoom: number;\n /** Map rotation bearing in degrees counter-clockwise from north */\n bearing: number;\n /** Map angle in degrees at which the camera is looking at the ground */\n pitch: number;\n /** Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. */\n padding: PaddingOptions;\n};\n\nexport type ControlPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n\nexport interface ImmutableLike<T> {\n toJS: () => T;\n}\n"],"mappings":"","ignoreList":[]}