From 0926340269ccbb985adb8e80c415c8dbeddc505a Mon Sep 17 00:00:00 2001 From: flisowna Date: Mon, 31 Oct 2022 13:03:24 +0400 Subject: [PATCH] WIP mapViewStore --- packages/nc-gui/components/smartsheet/Map.vue | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Map.vue b/packages/nc-gui/components/smartsheet/Map.vue index d3188f3030..5a6f8030c2 100644 --- a/packages/nc-gui/components/smartsheet/Map.vue +++ b/packages/nc-gui/components/smartsheet/Map.vue @@ -20,6 +20,12 @@ const reloadViewDataHook = inject(ReloadViewDataHookInj) // const { loadData, formattedData: data } = useViewData(meta, view) const { formattedData, loadMapData } = useMapViewStoreOrThrow() +const markerRef = ref() +const myMapRef = ref() +// const latitude = formattedData.value +// const longitude = ref() +const markersRef = ref() + // watch(view, async (nextView) => { // if (nextView?.type === ViewTypes.MAP) { // // loadData() @@ -36,26 +42,26 @@ onMounted(async () => { }) watch(formattedData, () => { + markersRef.value?.clearLayers() formattedData.value?.forEach((row) => { // const [lat, long] = console.log('row', row) - const [lat, long] = row?.['geo'].split(';').map(parseFloat) + if (row?.geo == null) return + const [lat, long] = row?.geo.split(';').map(parseFloat) + // if (lat == null || long == null) { + // return + // } console.log('lat', lat) addMarker(lat, long) }) }) -const markerRef = ref() -const myMapRef = ref() -// const latitude = formattedData.value -// const longitude = ref() -const markersRef = ref() - reloadViewDataHook?.on(async () => { loadMapData() }) function addMarker(lat: number, long: number) { + // markersRef.value?.clearLayers() const markerNew = markerRef.value([lat, long]) console.log(markersRef.value) markersRef.value.addLayer(markerNew)