Skip to content

Commit

Permalink
very wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJoss committed Jun 26, 2024
1 parent 9004978 commit b64b05f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/modules/map/components/openlayers/CompassButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script setup>
import { onMounted, onUnmounted, ref } from 'vue'
import { useStore } from 'vuex'
const autoRotate = ref(false)
const store = useStore()
onMounted(() => {
window.addEventListener('deviceorientation', handleOrientation)
})
onUnmounted(() => {
window.removeEventListener('deviceorientation', handleOrientation)
})
function handleOrientation(event) {
console.error(autoRotate.value, event.alpha, (event.alpha / 180) * Math.PI)
if (autoRotate.value) {
store.dispatch('setRotation', (event.alpha / 180) * Math.PI)
}
}
function rotate() {
autoRotate.value = !autoRotate.value
}
</script>

<template>
<div>
<button class="p-0" @click="rotate">
{{ autoRotate ? 'AUTO-ROTATE ENABLED' : 'AUTO-ROTATE DISABLED' }}
</button>
</div>
</template>
2 changes: 2 additions & 0 deletions src/modules/map/components/toolbox/MapToolbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { computed, toRefs } from 'vue'
import { useStore } from 'vuex'
import CompassButton from '@/modules/map/components/openlayers/CompassButton.vue'
import OpenLayersCompassButton from '@/modules/map/components/openlayers/OpenLayersCompassButton.vue'
import FullScreenButton from '@/modules/map/components/toolbox/FullScreenButton.vue'
import GeolocButton from '@/modules/map/components/toolbox/GeolocButton.vue'
Expand Down Expand Up @@ -54,6 +55,7 @@ const is3dActive = computed(() => store.state.cesium.active)
<ZoomButtons v-if="!isFullscreenMode" />
<Toggle3dButton v-if="toggle3dButton && !isFullscreenMode" />
<OpenLayersCompassButton v-if="compassButton && !is3dActive && !isFullscreenMode" />
<CompassButton />
<slot />
</div>
</template>
Expand Down

0 comments on commit b64b05f

Please sign in to comment.