Skip to content

Commit

Permalink
remove yellow pointer when streetview is active
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Nov 27, 2024
1 parent faacee2 commit d0ba270
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
17 changes: 14 additions & 3 deletions src/composables/map/location-info.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function useLocationInfo() {
let holdTimeoutId: number | undefined = undefined
let startPixel: Coordinate | null = null
const { infoOpen } = storeToRefs(useAppStore())
const { locationInfo, ignoreLeftClick } = storeToRefs(useInfoStore())
const { locationInfo, hidePointer } = storeToRefs(useInfoStore())

const infoFeatureLayer = new VectorLayer({
source: new VectorSource({
Expand All @@ -37,9 +37,20 @@ export default function useLocationInfo() {
setInfoStyle(infoFeatureLayer)
map.addLayer(infoFeatureLayer)

watch(hidePointer, doHide => {
if (doHide) {
infoFeatureLayer.getSource()?.clear()
} else {
if (locationInfo.value) {
const feature = new Feature(new Point(locationInfo.value))
infoFeatureLayer.getSource()?.addFeature(feature)
}
}
})

watch(locationInfo, location => {
infoFeatureLayer.getSource()?.clear()
if (location) {
if (location && !hidePointer.value) {
infoOpen.value = true
const feature = new Feature(new Point(location))
infoFeatureLayer.getSource()?.addFeature(feature)
Expand Down Expand Up @@ -77,7 +88,7 @@ export default function useLocationInfo() {
(event as MapBrowserEvent<PointerEvent>).originalEvent.button === 0
) {
// if left mouse click
if (!ignoreLeftClick.value) {
if (!hidePointer.value) {
locationInfo.value = undefined
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/composables/map/street-view.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function useStreeView() {
const { infoOpen } = storeToRefs(useAppStore())
const {
locationInfo,
ignoreLeftClick,
hidePointer,
isStreetviewActive,
noDataAtLocation,
panoPositionChanging,
Expand Down Expand Up @@ -176,13 +176,13 @@ export default function useStreeView() {
svf.directions.forEach((f: SvDirectionFeature) =>
svFeatureLayer.getSource()?.addFeature(f)
)
ignoreLeftClick.value = true
hidePointer.value = true
map.addInteraction(selectFeature)
map.on('pointermove', handleHover)
} else {
map.un('pointermove', handleHover)
map.removeInteraction(selectFeature)
ignoreLeftClick.value = false
hidePointer.value = false
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/stores/info.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Coordinate } from 'ol/coordinate'

export const useInfoStore = defineStore('info', () => {
const locationInfo: Ref<Coordinate | undefined> = ref(undefined)
const ignoreLeftClick: Ref<boolean> = ref(false)
const hidePointer: Ref<boolean> = ref(false)
const isStreetviewActive: Ref<boolean> = ref(false)
const noDataAtLocation = ref(true)
const panoPositionChanging: Ref<boolean> = ref(false)
const svFeature: Ref<SvFeature | undefined> = ref(undefined)

return {
locationInfo,
ignoreLeftClick,
hidePointer,
isStreetviewActive,
noDataAtLocation,
panoPositionChanging,
Expand Down

0 comments on commit d0ba270

Please sign in to comment.