@macrostrat/map-interface 0.3.0 → 1.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.
- package/CHANGELOG.md +13 -0
- package/package.json +16 -12
- package/src/container.ts +66 -31
- package/src/context-panel/index.ts +2 -1
- package/src/context-panel/main.module.sass +7 -6
- package/src/controls.ts +12 -1
- package/src/dev/main.module.sass +1 -1
- package/src/expansion-panel/main.module.sass +8 -4
- package/src/helpers.ts +2 -2
- package/src/location-info/hash-string.ts +102 -0
- package/src/location-info/index.ts +6 -4
- package/src/location-info/utils.ts +0 -20
- package/src/location-panel/header.ts +19 -6
- package/src/location-panel/index.ts +32 -5
- package/src/location-panel/main.module.sass +3 -3
- package/src/main.module.sass +169 -82
- package/src/map-view/index.ts +6 -4
- package/src/map-view/terrain.ts +8 -5
- package/dist/index.cjs +0 -1783
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -918
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -1774
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -235
- package/dist/types.d.ts.map +0 -1
- package/src/main.module.ref.styl +0 -407
- package/src/map-view/main.module.sass +0 -23
package/src/main.module.sass
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
.map-
|
|
1
|
+
.map-container
|
|
2
2
|
display: flex
|
|
3
3
|
flex-direction: column
|
|
4
4
|
position: relative
|
|
5
5
|
width: 100%
|
|
6
6
|
height: 100%
|
|
7
7
|
overflow: hidden
|
|
8
|
+
&.show-panel-outlines
|
|
9
|
+
.map-view-container
|
|
10
|
+
outline: 2px dotted dodgerblue
|
|
8
11
|
&.fit-viewport
|
|
9
12
|
height: 100vh
|
|
10
13
|
width: 100vw
|
|
@@ -32,7 +35,39 @@
|
|
|
32
35
|
&.map-is-global .globe-control
|
|
33
36
|
display: block
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
&.detail-panel-open
|
|
39
|
+
.zoom-control
|
|
40
|
+
opacity: 0
|
|
41
|
+
display: none
|
|
42
|
+
|
|
43
|
+
&.detail-panel-fixed
|
|
44
|
+
.detail-panel-holder
|
|
45
|
+
&>*
|
|
46
|
+
border-radius: unset
|
|
47
|
+
|
|
48
|
+
.detail-panel-holder
|
|
49
|
+
display: flex
|
|
50
|
+
flex-direction: column
|
|
51
|
+
min-height: 0
|
|
52
|
+
&>*
|
|
53
|
+
flex: 1
|
|
54
|
+
|
|
55
|
+
.map-control-stack
|
|
56
|
+
display: flex
|
|
57
|
+
flex-direction: column
|
|
58
|
+
width: 30em
|
|
59
|
+
margin-left: -30em
|
|
60
|
+
pointer-events: none
|
|
61
|
+
|
|
62
|
+
.main-row
|
|
63
|
+
flex: 1
|
|
64
|
+
display: flex
|
|
65
|
+
flex-direction: row
|
|
66
|
+
position: relative
|
|
67
|
+
max-height: 100%
|
|
68
|
+
min-height: 0
|
|
69
|
+
|
|
70
|
+
.map-ui
|
|
36
71
|
flex: 1
|
|
37
72
|
position: relative
|
|
38
73
|
display: flex
|
|
@@ -41,6 +76,23 @@
|
|
|
41
76
|
height: 100%
|
|
42
77
|
box-shadow: 0 0 10px 4px var(--card-shadow-color)
|
|
43
78
|
|
|
79
|
+
.map-view-container
|
|
80
|
+
flex-grow: 1
|
|
81
|
+
position: relative
|
|
82
|
+
overflow: hidden
|
|
83
|
+
|
|
84
|
+
.mapbox-map
|
|
85
|
+
position: absolute
|
|
86
|
+
top: 0
|
|
87
|
+
bottom: 0
|
|
88
|
+
left: 0
|
|
89
|
+
right: 0
|
|
90
|
+
&:global(.mapboxgl-map)
|
|
91
|
+
// override the default mapbox position: relative in all cases
|
|
92
|
+
position: absolute
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
44
96
|
.panel-card
|
|
45
97
|
padding: 10px
|
|
46
98
|
background-color: var(--panel-background-color)
|
|
@@ -49,14 +101,10 @@
|
|
|
49
101
|
& >:last-child
|
|
50
102
|
margin-bottom: 0
|
|
51
103
|
|
|
52
|
-
:global(.
|
|
104
|
+
:global(.bp5-dark) .panel-card
|
|
53
105
|
background-color: var(--panel-background-color)
|
|
54
106
|
|
|
55
107
|
.context-stack
|
|
56
|
-
display: flex
|
|
57
|
-
flex-direction: column
|
|
58
|
-
max-height: 100%
|
|
59
|
-
|
|
60
108
|
&>div
|
|
61
109
|
flex-shrink: 1
|
|
62
110
|
|
|
@@ -65,7 +113,8 @@
|
|
|
65
113
|
|
|
66
114
|
.context-stack,
|
|
67
115
|
.detail-stack
|
|
68
|
-
z-index:
|
|
116
|
+
z-index: 10
|
|
117
|
+
max-height: 100%
|
|
69
118
|
|
|
70
119
|
.panel-container
|
|
71
120
|
display: flex
|
|
@@ -104,29 +153,29 @@
|
|
|
104
153
|
overflow: hidden
|
|
105
154
|
text-align: right
|
|
106
155
|
|
|
107
|
-
& :global(.
|
|
156
|
+
& :global(.bp5-button-text)
|
|
108
157
|
transition: all 0.2s
|
|
109
158
|
transition-delay: 0.1s
|
|
110
159
|
|
|
111
|
-
.menu-card.narrow-card .panel-header:not(.minimal) &:global(.
|
|
160
|
+
.menu-card.narrow-card .panel-header:not(.minimal) &:global(.bp5-active) ~ & :global(.bp5-button-text)
|
|
112
161
|
width: 0
|
|
113
162
|
opacity: 0
|
|
114
163
|
margin-left: -7px
|
|
115
164
|
|
|
116
|
-
.context-panel-leave .menu-card .panel-header & :global(.
|
|
165
|
+
.context-panel-leave .menu-card .panel-header & :global(.bp5-button-text)
|
|
117
166
|
opacity: 0
|
|
118
167
|
width: 0
|
|
119
168
|
|
|
120
169
|
.narrow-card.narrow-enter .panel-header .buttons
|
|
121
170
|
margin-right: -500px
|
|
122
171
|
|
|
123
|
-
.panel-header.minimal .tab-button:not(:hover):not(:global(.
|
|
172
|
+
.panel-header.minimal .tab-button:not(:hover):not(:global(.bp5-active))
|
|
124
173
|
padding-left: 0
|
|
125
174
|
padding-right: 0
|
|
126
175
|
min-width: 30px
|
|
127
176
|
width: 30px
|
|
128
177
|
|
|
129
|
-
.panel-header.minimal .tab-button:not(:hover) :global(.
|
|
178
|
+
.panel-header.minimal .tab-button:not(:hover) :global(.bp5-button-text)
|
|
130
179
|
width: 0
|
|
131
180
|
opacity: 0
|
|
132
181
|
margin-left: -7px
|
|
@@ -135,7 +184,7 @@
|
|
|
135
184
|
margin-bottom: 0.5em
|
|
136
185
|
margin-top: 0.2em
|
|
137
186
|
|
|
138
|
-
.menu-card :global .
|
|
187
|
+
.menu-card :global .bp5-text ul,
|
|
139
188
|
.menu-card :global .text-panel ul
|
|
140
189
|
padding-left: 1em
|
|
141
190
|
|
|
@@ -144,7 +193,7 @@
|
|
|
144
193
|
flex-direction: column
|
|
145
194
|
margin-bottom: -8px
|
|
146
195
|
|
|
147
|
-
& .
|
|
196
|
+
& .bp5-button-group
|
|
148
197
|
margin-bottom: 4px
|
|
149
198
|
|
|
150
199
|
& hr
|
|
@@ -187,16 +236,16 @@
|
|
|
187
236
|
.mapboxgl-ctrl-logo
|
|
188
237
|
transform: scale(0.9) translate(-8px, 2px)
|
|
189
238
|
|
|
190
|
-
.
|
|
239
|
+
.bp5-dark .mapboxgl-ctrl-logo
|
|
191
240
|
filter: invert(100%)
|
|
192
241
|
|
|
193
242
|
.mapboxgl-ctrl-group button + button
|
|
194
243
|
border-top: 1px solid var(--panel-rule-color) !important
|
|
195
244
|
|
|
196
|
-
.
|
|
245
|
+
.bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon
|
|
197
246
|
filter: invert(40%)
|
|
198
247
|
|
|
199
|
-
.
|
|
248
|
+
.bp5-dark .mapboxgl-ctrl-group .mapboxgl-ctrl-icon:hover
|
|
200
249
|
filter: invert(50%)
|
|
201
250
|
|
|
202
251
|
.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon
|
|
@@ -208,9 +257,11 @@
|
|
|
208
257
|
.detail-stack
|
|
209
258
|
position: relative
|
|
210
259
|
|
|
211
|
-
.
|
|
212
|
-
|
|
213
|
-
|
|
260
|
+
.detail-panel-container, .map-right-controls
|
|
261
|
+
flex: 1
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
214
265
|
|
|
215
266
|
.zoom-control
|
|
216
267
|
transition: opacity 1s ease-in-out
|
|
@@ -219,41 +270,45 @@
|
|
|
219
270
|
top: 0
|
|
220
271
|
right: 0
|
|
221
272
|
|
|
222
|
-
.main-ui.searching .map-view-container
|
|
223
|
-
pointer-events: none
|
|
224
|
-
|
|
225
273
|
.map-controls
|
|
226
274
|
display: flex
|
|
227
275
|
flex-direction: row
|
|
228
276
|
justify-content: right
|
|
229
277
|
margin-bottom: 0
|
|
278
|
+
gap: 0.5em
|
|
279
|
+
|
|
280
|
+
:global(.map-control)
|
|
281
|
+
&>:global(.bp5-button)
|
|
282
|
+
padding: 0
|
|
283
|
+
transform: translate(-3.5px, -3.5px)
|
|
284
|
+
width: 22px !important
|
|
230
285
|
|
|
231
|
-
&>*
|
|
232
|
-
margin-left: 0.5em
|
|
233
286
|
|
|
234
287
|
.map-controls :global(.mapbox-control),
|
|
235
288
|
.map-controls :global(.map-control-wrapper),
|
|
236
|
-
.map-controls .map-control
|
|
237
|
-
|
|
238
|
-
|
|
289
|
+
.map-controls :global(.map-control)
|
|
290
|
+
max-height: 22px
|
|
291
|
+
height: 22px
|
|
239
292
|
border-radius: 4px
|
|
240
293
|
background-color: var(--panel-background-color)
|
|
241
294
|
box-shadow: 0 0 0 1px var(--card-shadow-color)
|
|
242
295
|
|
|
243
296
|
.map-controls :global(.mapbox-control) button,
|
|
244
297
|
.map-controls :global(.map-control-wrapper) button,
|
|
245
|
-
.map-controls .map-control button
|
|
246
|
-
|
|
298
|
+
.map-controls :global(.map-control) button
|
|
299
|
+
max-height: 22px
|
|
247
300
|
height: 22px
|
|
301
|
+
width: 22px
|
|
302
|
+
max-width: 22px
|
|
248
303
|
background-position: center center
|
|
249
304
|
padding: 0
|
|
250
|
-
background-color: var(--panel-background-color)
|
|
251
|
-
color: var(--text-color)
|
|
305
|
+
//background-color: var(--panel-background-color)
|
|
306
|
+
//color: var(--text-color)
|
|
252
307
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
background-color: var(--panel-background-color) !important
|
|
308
|
+
//.map-controls :global(.mapbox-control) button:hover,
|
|
309
|
+
//.map-controls :global(.map-control-wrapper) button:hover,
|
|
310
|
+
//.map-controls .map-control button:hover
|
|
311
|
+
// background-color: var(--panel-background-color) !important
|
|
257
312
|
|
|
258
313
|
.map-controls .map-scale-control
|
|
259
314
|
background: none
|
|
@@ -265,10 +320,13 @@
|
|
|
265
320
|
border-color: var(--secondary-text-color)
|
|
266
321
|
color: var(--secondary-text-color)
|
|
267
322
|
|
|
323
|
+
// .map-container.detail-panel-fixed
|
|
324
|
+
// right: 30em
|
|
325
|
+
|
|
268
326
|
/* For mobile phones, we want to make the most of screen space,
|
|
269
327
|
which in some cases means adding complications to the basic page. */
|
|
270
328
|
@media only screen and (max-width: 768px)
|
|
271
|
-
.
|
|
329
|
+
.map-container.detail-panel-enter .context-stack
|
|
272
330
|
height: 0
|
|
273
331
|
visibility: hidden
|
|
274
332
|
transition: height 0.5s ease-in-out
|
|
@@ -294,20 +352,25 @@
|
|
|
294
352
|
.detail-panel
|
|
295
353
|
border-radius: 0px
|
|
296
354
|
|
|
355
|
+
|
|
297
356
|
/* Desktop styling is necessarily much more complicated than mobile
|
|
298
357
|
to handle a two-column layout. */
|
|
299
358
|
@media screen and (min-width: 768px)
|
|
300
|
-
|
|
359
|
+
/* Make map fill page rather than containing div,
|
|
360
|
+
by unsetting map position */
|
|
361
|
+
// We should move this to another file.
|
|
362
|
+
.map-view-container
|
|
363
|
+
position: unset
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
.map-ui
|
|
301
367
|
flex-direction: row
|
|
302
368
|
padding: 1em 1em 2em
|
|
303
369
|
min-height: 80px
|
|
304
|
-
|
|
305
|
-
margin-right: 0.5em
|
|
306
|
-
&>*:last-child
|
|
307
|
-
margin-right: 0
|
|
370
|
+
gap: 0.5em
|
|
308
371
|
|
|
309
372
|
.context-stack
|
|
310
|
-
max-width: 34em
|
|
373
|
+
max-width: var(--map-context-stack-max-width, 34em)
|
|
311
374
|
min-width: 14em
|
|
312
375
|
transition: width 300ms ease
|
|
313
376
|
padding-bottom: 0.5em
|
|
@@ -316,6 +379,17 @@
|
|
|
316
379
|
display: flex
|
|
317
380
|
flex-direction: column
|
|
318
381
|
|
|
382
|
+
&.adaptive-width
|
|
383
|
+
width: var(--map-context-stack-width, none)
|
|
384
|
+
max-width: var(--map-context-stack-max-width, none)
|
|
385
|
+
transition: width 300ms ease
|
|
386
|
+
|
|
387
|
+
:global(.bp5-navbar)
|
|
388
|
+
//height: unset
|
|
389
|
+
//padding: 5px
|
|
390
|
+
h1, h2, h3
|
|
391
|
+
margin: 0
|
|
392
|
+
|
|
319
393
|
&>.spacer
|
|
320
394
|
flex-grow: 0
|
|
321
395
|
|
|
@@ -325,18 +399,14 @@
|
|
|
325
399
|
&>div
|
|
326
400
|
max-height: 100%
|
|
327
401
|
|
|
328
|
-
.main-ui.detail-panel-open .detail-stack
|
|
329
|
-
width: var(--map-detail-stack-width, 30em)
|
|
330
|
-
|
|
331
402
|
.detail-stack
|
|
332
|
-
width: 30em
|
|
333
|
-
pointer-events: none
|
|
403
|
+
width: var(--map-detail-stack-width, 30em)
|
|
334
404
|
display: flex
|
|
335
405
|
flex-direction: column
|
|
336
406
|
|
|
337
407
|
.context-stack, .detail-stack
|
|
338
408
|
pointer-events: none
|
|
339
|
-
z-index:
|
|
409
|
+
z-index: 10
|
|
340
410
|
|
|
341
411
|
&>div
|
|
342
412
|
pointer-events: all
|
|
@@ -356,56 +426,73 @@
|
|
|
356
426
|
.map-view-container
|
|
357
427
|
position: unset
|
|
358
428
|
|
|
359
|
-
|
|
360
|
-
transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease
|
|
361
|
-
|
|
362
|
-
.main-ui.detail-panel-from .detail-panel
|
|
363
|
-
opacity: 0
|
|
364
|
-
|
|
365
|
-
.main-ui.detail-panel-enter .detail-panel
|
|
366
|
-
opacity: 1
|
|
429
|
+
/** CSS Transitions **/
|
|
367
430
|
|
|
368
|
-
.
|
|
369
|
-
|
|
431
|
+
.map-container
|
|
432
|
+
// Context panel
|
|
433
|
+
.context-panel-holder
|
|
434
|
+
pointer-events: none
|
|
435
|
+
flex: 1
|
|
436
|
+
&>div
|
|
437
|
+
pointer-events: all
|
|
438
|
+
transition: opacity 0.8s ease //, height 0.8s ease, max-height 0.8s ease, padding 0.8s ease
|
|
370
439
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
440
|
+
&.context-panel-from .context-panel-holder>div
|
|
441
|
+
opacity: 0
|
|
442
|
+
&.context-panel-enter .context-panel-holder>div
|
|
443
|
+
opacity: 1
|
|
444
|
+
&.context-panel-leave .context-panel-holder>div
|
|
445
|
+
opacity: 0
|
|
377
446
|
|
|
378
|
-
|
|
379
|
-
|
|
447
|
+
// Detail panel (floating)
|
|
448
|
+
&.detail-panel-floating
|
|
449
|
+
// We assume that the relevant panel is the first child of the stack.
|
|
450
|
+
&.detail-panel-from .detail-panel-holder
|
|
451
|
+
opacity: 0
|
|
452
|
+
&.detail-panel-enter .detail-panel-holder
|
|
453
|
+
opacity: 1
|
|
454
|
+
&.detail-panel-leave .detail-panel-holder
|
|
455
|
+
opacity: 0
|
|
456
|
+
.detail-panel
|
|
457
|
+
transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease
|
|
458
|
+
|
|
459
|
+
// TODO: these styles have not been evaluated for mobile
|
|
460
|
+
&.detail-panel-fixed
|
|
461
|
+
.map-ui
|
|
462
|
+
transition: margin-right 0.8s ease
|
|
463
|
+
.detail-stack
|
|
464
|
+
transition: margin-right 0.8s ease
|
|
465
|
+
|
|
466
|
+
&.detail-panel-from .detail-panel-holder
|
|
467
|
+
margin-right: calc(-1 * var(--map-detail-stack-width, 30em))
|
|
468
|
+
&.detail-panel-enter .detail-panel-holder
|
|
469
|
+
margin-right: 0
|
|
470
|
+
&.detail-panel-leave .detail-panel-holder
|
|
471
|
+
margin-right: calc(-1 * var(--map-detail-stack-width, 30em))
|
|
380
472
|
|
|
381
|
-
.main-ui.context-panel-enter .context-panel-holder>div
|
|
382
|
-
opacity: 1
|
|
383
473
|
|
|
384
|
-
.main-ui.context-panel-leave .context-panel-holder>div
|
|
385
|
-
opacity: 0
|
|
386
474
|
// The max-height transition is a bit jerky because of panel padding.
|
|
387
475
|
// We could probably fix this by pulling the panel container itself into
|
|
388
476
|
// the class.
|
|
389
477
|
//max-height: 0
|
|
390
|
-
//padding:
|
|
478
|
+
//padding: 0i
|
|
391
479
|
|
|
392
480
|
@media only screen and (max-width: 768px)
|
|
393
|
-
.
|
|
481
|
+
.map-container .detail-stack
|
|
394
482
|
transition: opacity 0.8s ease, height 0.8s ease, max-height 0.8s ease
|
|
395
483
|
|
|
396
|
-
.
|
|
484
|
+
.map-container.detail-panel-from .detail-stack
|
|
397
485
|
max-height: 0
|
|
398
486
|
height: 0
|
|
399
487
|
|
|
400
|
-
.
|
|
401
|
-
max-height: 0
|
|
488
|
+
.map-container.detail-panel-leave .detail-stack
|
|
402
489
|
max-height: 0
|
|
403
490
|
|
|
404
|
-
.
|
|
491
|
+
.map-container.context-panel-from .context-panel
|
|
405
492
|
max-height: 0
|
|
406
493
|
height: 0
|
|
407
494
|
|
|
408
|
-
.
|
|
495
|
+
.map-container.context-panel-leave
|
|
409
496
|
.context-stack
|
|
410
497
|
.context-panel-holder
|
|
411
498
|
flex: 0
|
|
@@ -414,11 +501,11 @@
|
|
|
414
501
|
|
|
415
502
|
// Shift UI around to center elements if we're in the global view
|
|
416
503
|
@media only screen and (min-width: 768px)
|
|
417
|
-
.map-
|
|
504
|
+
.map-container.detail-panel-leave .map-view-container
|
|
418
505
|
margin-right: -14em
|
|
419
506
|
|
|
420
|
-
.map-
|
|
507
|
+
.map-container.map-is-global.detail-panel-leave .map-view-container
|
|
421
508
|
margin-right: -30em
|
|
422
509
|
|
|
423
|
-
.map-
|
|
510
|
+
.map-container.map-is-global.context-panel-leave .map-view-container
|
|
424
511
|
margin-left: -16em
|
package/src/map-view/index.ts
CHANGED
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
import classNames from "classnames";
|
|
13
13
|
import mapboxgl from "mapbox-gl";
|
|
14
14
|
import { useEffect, useRef, useCallback } from "react";
|
|
15
|
-
import styles from "
|
|
16
|
-
import rootStyles from "../main.module.sass";
|
|
15
|
+
import styles from "../main.module.sass";
|
|
17
16
|
import { enable3DTerrain } from "./terrain";
|
|
18
17
|
import {
|
|
19
18
|
MapLoadingReporter,
|
|
@@ -24,7 +23,7 @@ import {
|
|
|
24
23
|
import "mapbox-gl/dist/mapbox-gl.css";
|
|
25
24
|
import { getMapPadding } from "../utils";
|
|
26
25
|
|
|
27
|
-
const h = hyper.styled(
|
|
26
|
+
const h = hyper.styled(styles);
|
|
28
27
|
|
|
29
28
|
type MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, "container">;
|
|
30
29
|
|
|
@@ -44,6 +43,7 @@ export interface MapViewProps extends MapboxCoreOptions {
|
|
|
44
43
|
) => mapboxgl.Map;
|
|
45
44
|
onMapLoaded?: (map: mapboxgl.Map) => void;
|
|
46
45
|
onStyleLoaded?: (map: mapboxgl.Map) => void;
|
|
46
|
+
onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
@@ -52,6 +52,7 @@ export interface MapboxOptionsExt extends MapboxCoreOptions {
|
|
|
52
52
|
|
|
53
53
|
function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
|
|
54
54
|
const { mapPosition, ...rest } = args;
|
|
55
|
+
console.log("Initializing map (default)", args);
|
|
55
56
|
|
|
56
57
|
const map = new mapboxgl.Map({
|
|
57
58
|
container,
|
|
@@ -97,6 +98,7 @@ export function MapView(props: MapViewProps) {
|
|
|
97
98
|
projection,
|
|
98
99
|
onMapLoaded = null,
|
|
99
100
|
onStyleLoaded = null,
|
|
101
|
+
onMapMoved = null,
|
|
100
102
|
...rest
|
|
101
103
|
} = props;
|
|
102
104
|
if (enableTerrain) {
|
|
@@ -173,7 +175,7 @@ export function MapView(props: MapViewProps) {
|
|
|
173
175
|
h(MapLoadingReporter, {
|
|
174
176
|
ignoredSources: ["elevationMarker", "crossSectionEndpoints"],
|
|
175
177
|
}),
|
|
176
|
-
h(MapMovedReporter),
|
|
178
|
+
h(MapMovedReporter, { onMapMoved }),
|
|
177
179
|
h(MapResizeManager, { containerRef: ref }),
|
|
178
180
|
h(MapPaddingManager, { containerRef: ref, parentRef, infoMarkerPosition }),
|
|
179
181
|
h(MapTerrainManager, { mapUse3D, terrainSourceID }),
|
package/src/map-view/terrain.ts
CHANGED
|
@@ -5,19 +5,21 @@ export function enable3DTerrain(
|
|
|
5
5
|
shouldEnable: boolean,
|
|
6
6
|
sourceID: string | null = null
|
|
7
7
|
) {
|
|
8
|
-
let demSourceID = sourceID ?? getTerrainSourceID(map) ?? "mapbox-dem";
|
|
9
|
-
|
|
10
|
-
console.log("Enabling 3D terrain with source", demSourceID);
|
|
11
|
-
|
|
12
8
|
if (!map.style?._loaded) {
|
|
13
9
|
map.once("style.load", () => {
|
|
14
|
-
enable3DTerrain(map, shouldEnable,
|
|
10
|
+
enable3DTerrain(map, shouldEnable, sourceID);
|
|
15
11
|
});
|
|
16
12
|
return;
|
|
17
13
|
}
|
|
18
14
|
|
|
15
|
+
const currentTerrainSource = getTerrainSourceID(map);
|
|
16
|
+
let demSourceID = sourceID ?? currentTerrainSource ?? "mapbox-dem";
|
|
17
|
+
|
|
18
|
+
console.log("Enabling 3D terrain with source", demSourceID);
|
|
19
|
+
|
|
19
20
|
// Enable or disable terrain depending on our current desires...
|
|
20
21
|
const currentTerrain = map.getTerrain();
|
|
22
|
+
|
|
21
23
|
if (!shouldEnable) {
|
|
22
24
|
if (currentTerrain != null) map.setTerrain(null);
|
|
23
25
|
return;
|
|
@@ -48,6 +50,7 @@ export function enable3DTerrain(
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
map.setTerrain({ source: demSourceID, exaggeration: 1 });
|
|
53
|
+
console.log(map.getTerrain());
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
function getTerrainSourceID(map) {
|