Fix globe center
This commit is contained in:
@@ -5,7 +5,6 @@ import { createApp } from 'vue';
|
|||||||
import Simplebar from 'simplebar-vue';
|
import Simplebar from 'simplebar-vue';
|
||||||
|
|
||||||
import Lightbox from '@scripts/lightbox';
|
import Lightbox from '@scripts/lightbox';
|
||||||
import { getOuterWidth } from '@scripts/common';
|
|
||||||
|
|
||||||
import SpotIcon from '@components/spotIcon';
|
import SpotIcon from '@components/spotIcon';
|
||||||
import SpotIconStack from '@components/spotIconStack';
|
import SpotIconStack from '@components/spotIconStack';
|
||||||
@@ -181,26 +180,27 @@ export default {
|
|||||||
if(this.map) this.map.remove();
|
if(this.map) this.map.remove();
|
||||||
this.map = new Map({
|
this.map = new Map({
|
||||||
container: 'map',
|
container: 'map',
|
||||||
bounds: this.getInitialMapBounds(),
|
|
||||||
aroundCenter: true,
|
aroundCenter: true,
|
||||||
fitBoundsOptions: {
|
|
||||||
padding: {
|
|
||||||
top: 20,
|
|
||||||
bottom: 20,
|
|
||||||
left: 20,
|
|
||||||
right: 20 + (this.feedPanelOpen?(getOuterWidth(this.$refs.feed)):0)
|
|
||||||
},
|
|
||||||
animate: false,
|
|
||||||
maxZoom: 15
|
|
||||||
},
|
|
||||||
style: {
|
style: {
|
||||||
version: 8,
|
version: 8,
|
||||||
projection: {type: 'globe'},
|
projection: {type: 'globe'},
|
||||||
|
sky: {
|
||||||
|
'sky-color': '#000000',
|
||||||
|
'horizon-color': '#ffffff',
|
||||||
|
'sky-horizon-blend': 0.35,
|
||||||
|
'atmosphere-blend': 0.8
|
||||||
|
},
|
||||||
sources: {},
|
sources: {},
|
||||||
layers: []
|
layers: []
|
||||||
},
|
},
|
||||||
attributionControl: false
|
attributionControl: false
|
||||||
});
|
});
|
||||||
|
this.updateMapPadding();
|
||||||
|
this.map.fitBounds(this.getInitialMapBounds(), {
|
||||||
|
padding: 20,
|
||||||
|
animate: false,
|
||||||
|
maxZoom: 15
|
||||||
|
});
|
||||||
this.map.addControl(new ScaleControl({unit: 'metric'}), 'bottom-right');
|
this.map.addControl(new ScaleControl({unit: 'metric'}), 'bottom-right');
|
||||||
|
|
||||||
//Get default basemap
|
//Get default basemap
|
||||||
@@ -299,7 +299,7 @@ export default {
|
|||||||
const $Marker = document.createElement('div');
|
const $Marker = document.createElement('div');
|
||||||
createApp(SpotIconStack, this.markerProps[oMarker.subtype]).mount($Marker);
|
createApp(SpotIconStack, this.markerProps[oMarker.subtype]).mount($Marker);
|
||||||
|
|
||||||
new Marker({element: $Marker, anchor: 'bottom'})
|
new Marker({element: $Marker, anchor: 'bottom', opacityWhenCovered: 0})
|
||||||
.setLngLat([oMarker.longitude, oMarker.latitude])
|
.setLngLat([oMarker.longitude, oMarker.latitude])
|
||||||
.addTo(this.map)
|
.addTo(this.map)
|
||||||
.getElement()
|
.getElement()
|
||||||
@@ -472,8 +472,6 @@ export default {
|
|||||||
this.setFeedUpdateTimer(this.refreshRate);
|
this.setFeedUpdateTimer(this.refreshRate);
|
||||||
},
|
},
|
||||||
panToBetweenPanels(oLngLat, iZoom, iAnimDuration=500) {
|
panToBetweenPanels(oLngLat, iZoom, iAnimDuration=500) {
|
||||||
const iXOffset = (this.settingsPanelOpen?getOuterWidth(this.$refs.settings):0) - (this.feedPanelOpen?getOuterWidth(this.$refs.feed):0);
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if(!this.map) {
|
if(!this.map) {
|
||||||
resolve();
|
resolve();
|
||||||
@@ -483,11 +481,25 @@ export default {
|
|||||||
this.map.easeTo({
|
this.map.easeTo({
|
||||||
center: oLngLat,
|
center: oLngLat,
|
||||||
zoom: iZoom,
|
zoom: iZoom,
|
||||||
offset: [iXOffset / 2, 0],
|
padding: this.getMapPadding(),
|
||||||
duration: iAnimDuration
|
duration: iAnimDuration
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getMapPadding() {
|
||||||
|
let bIsMobile = this.isMobile();
|
||||||
|
return {
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
left: (!bIsMobile && this.settingsPanelOpen)?this.$refs.settings.getBoundingClientRect().width:0,
|
||||||
|
right: (!bIsMobile && this.feedPanelOpen)?this.$refs.feed.getBoundingClientRect().width:0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
updateMapPadding(iDuration=0) {
|
||||||
|
const asPadding = this.getMapPadding();
|
||||||
|
if(iDuration > 0) this.map.easeTo({padding: asPadding, duration: iDuration});
|
||||||
|
else this.map.jumpTo({padding: asPadding});
|
||||||
|
},
|
||||||
isMarkerVisible(oLngLat){
|
isMarkerVisible(oLngLat){
|
||||||
return !!this.map && this.map.getBounds().contains(oLngLat);
|
return !!this.map && this.map.getBounds().contains(oLngLat);
|
||||||
},
|
},
|
||||||
@@ -503,19 +515,17 @@ export default {
|
|||||||
let bOldValue = this.feedPanelOpen;
|
let bOldValue = this.feedPanelOpen;
|
||||||
this.feedPanelOpen = (typeof bShow === 'object' || typeof bShow === 'undefined')?(!this.feedPanelOpen):bShow;
|
this.feedPanelOpen = (typeof bShow === 'object' || typeof bShow === 'undefined')?(!this.feedPanelOpen):bShow;
|
||||||
|
|
||||||
if(bOldValue != this.feedPanelOpen && !this.isMobile()) {
|
if(bOldValue != this.feedPanelOpen && !this.isMobile() && this.map) {
|
||||||
sMapAction = sMapAction || 'panTo';
|
sMapAction = sMapAction || 'panTo';
|
||||||
switch(sMapAction) {
|
switch(sMapAction) {
|
||||||
case 'none':
|
case 'none':
|
||||||
|
this.updateMapPadding();
|
||||||
break;
|
break;
|
||||||
case 'panTo':
|
case 'panTo':
|
||||||
this.map.panBy(
|
this.updateMapPadding(500);
|
||||||
[(this.feedPanelOpen?1:-1) * getOuterWidth(this.$refs.feed) / 2, 0],
|
|
||||||
{duration: 500}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'panToInstant':
|
case 'panToInstant':
|
||||||
this.map.panBy([(this.feedPanelOpen?1:-1) * getOuterWidth(this.$refs.feed) / 2, 0]);
|
this.updateMapPadding();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,19 +534,17 @@ export default {
|
|||||||
let bOldValue = this.settingsPanelOpen;
|
let bOldValue = this.settingsPanelOpen;
|
||||||
this.settingsPanelOpen = (typeof bShow === 'object' || typeof bShow === 'undefined')?(!this.settingsPanelOpen):bShow;
|
this.settingsPanelOpen = (typeof bShow === 'object' || typeof bShow === 'undefined')?(!this.settingsPanelOpen):bShow;
|
||||||
|
|
||||||
if(bOldValue != this.settingsPanelOpen && !this.isMobile()) {
|
if(bOldValue != this.settingsPanelOpen && !this.isMobile() && this.map) {
|
||||||
sMapAction = sMapAction || 'panTo';
|
sMapAction = sMapAction || 'panTo';
|
||||||
switch(sMapAction) {
|
switch(sMapAction) {
|
||||||
case 'none':
|
case 'none':
|
||||||
|
this.updateMapPadding();
|
||||||
break;
|
break;
|
||||||
case 'panTo':
|
case 'panTo':
|
||||||
this.map.panBy(
|
this.updateMapPadding(500);
|
||||||
[(this.settingsPanelOpen?-1:1) * getOuterWidth(this.$refs.settings) / 2, 0],
|
|
||||||
{duration: 500}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'panToInstant':
|
case 'panToInstant':
|
||||||
this.map.panBy([(this.settingsPanelOpen?-1:1) * getOuterWidth(this.$refs.settings) /2, 0]);
|
this.updateMapPadding();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,17 +31,3 @@ export function copyTextToClipboard(text) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOuterWidth(element) {
|
|
||||||
var style = getComputedStyle(element);
|
|
||||||
var width = element.offsetWidth; // Width without padding and border
|
|
||||||
width += parseInt(style.marginLeft) + parseInt(style.marginRight); // Add margins
|
|
||||||
|
|
||||||
// Check if the box-sizing is border-box (includes padding and border in the width)
|
|
||||||
if (style.boxSizing === 'border-box') {
|
|
||||||
width += parseInt(style.paddingLeft) + parseInt(style.paddingRight); // Add padding
|
|
||||||
width += parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth); // Add border
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,10 @@ $thumbnail-max-size: 60px;
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
.maplibregl-marker-covered {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.maplibregl-popup {
|
.maplibregl-popup {
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user