feat(map): add server-side h3 clustering and hover highlight
All checks were successful
Build Docker Image / build (push) Successful in 4m55s
All checks were successful
Build Docker Image / build (push) Successful in 4m55s
- Add useClusteredNodes composable for fetching clustered nodes - Update CatalogMap to support server-side clustering mode - Add bounds-change event for fetching clusters on map move/zoom - Add hover event to HubCard for marker highlighting - Update hubs/map page to use new clustering system
This commit is contained in:
48
app/composables/useClusteredNodes.ts
Normal file
48
app/composables/useClusteredNodes.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { GetClusteredNodesDocument } from './graphql/public/geo-generated'
|
||||
import type { ClusterPointType } from './graphql/public/geo-generated'
|
||||
|
||||
export interface MapBounds {
|
||||
west: number
|
||||
south: number
|
||||
east: number
|
||||
north: number
|
||||
zoom: number
|
||||
}
|
||||
|
||||
export function useClusteredNodes(transportType?: Ref<string | undefined>) {
|
||||
const { $geoClient } = useNuxtApp()
|
||||
|
||||
const clusteredNodes = ref<ClusterPointType[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
const fetchClusters = async (bounds: MapBounds) => {
|
||||
loading.value = true
|
||||
try {
|
||||
const { data } = await $geoClient.query({
|
||||
query: GetClusteredNodesDocument,
|
||||
variables: {
|
||||
west: bounds.west,
|
||||
south: bounds.south,
|
||||
east: bounds.east,
|
||||
north: bounds.north,
|
||||
zoom: Math.floor(bounds.zoom),
|
||||
transportType: transportType?.value
|
||||
},
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
|
||||
clusteredNodes.value = (data?.clusteredNodes ?? []).filter(Boolean) as ClusterPointType[]
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch clustered nodes:', error)
|
||||
clusteredNodes.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
clusteredNodes,
|
||||
loading,
|
||||
fetchClusters
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user