|
|
@ -3,35 +3,44 @@ import 'leaflet/dist/leaflet.css' |
|
|
|
import L, { LatLng } from 'leaflet' |
|
|
|
import L, { LatLng } from 'leaflet' |
|
|
|
import 'leaflet.markercluster' |
|
|
|
import 'leaflet.markercluster' |
|
|
|
import { ViewTypes } from 'nocodb-sdk' |
|
|
|
import { ViewTypes } from 'nocodb-sdk' |
|
|
|
// import contextmenu from 'vue3-contextmenu' |
|
|
|
|
|
|
|
// import 'vue3-contextmenu/dist/vue3-contextmenu.css' |
|
|
|
|
|
|
|
import { IsGalleryInj, IsGridInj, IsMapInj, OpenNewRecordFormHookInj, onMounted, provide, ref } from '#imports' |
|
|
|
import { IsGalleryInj, IsGridInj, IsMapInj, OpenNewRecordFormHookInj, onMounted, provide, ref } from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
import type { Row as RowType } from '~/lib' |
|
|
|
import type { Row as RowType } from '~/lib' |
|
|
|
import { latLongToJoinedString } from '~~/utils/geoDataUtils' |
|
|
|
import { latLongToJoinedString } from '~~/utils/geoDataUtils' |
|
|
|
|
|
|
|
|
|
|
|
provide(IsGalleryInj, ref(false)) |
|
|
|
provide(IsGalleryInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
provide(IsGridInj, ref(false)) |
|
|
|
provide(IsGridInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
provide(IsMapInj, ref(true)) |
|
|
|
provide(IsMapInj, ref(true)) |
|
|
|
|
|
|
|
|
|
|
|
const route = useRoute() |
|
|
|
const route = useRoute() |
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter() |
|
|
|
const router = useRouter() |
|
|
|
|
|
|
|
|
|
|
|
const reloadViewDataHook = inject(ReloadViewDataHookInj) |
|
|
|
const reloadViewDataHook = inject(ReloadViewDataHookInj) |
|
|
|
|
|
|
|
|
|
|
|
const reloadViewMetaHook = inject(ReloadViewMetaHookInj) |
|
|
|
const reloadViewMetaHook = inject(ReloadViewMetaHookInj) |
|
|
|
|
|
|
|
|
|
|
|
const { formattedData, loadMapData, loadMapMeta, mapMetaData, geoDataFieldColumn, addEmptyRow, syncCount, paginationData } = |
|
|
|
const { formattedData, loadMapData, loadMapMeta, mapMetaData, geoDataFieldColumn, addEmptyRow, syncCount, paginationData } = |
|
|
|
useMapViewStoreOrThrow() |
|
|
|
useMapViewStoreOrThrow() |
|
|
|
|
|
|
|
|
|
|
|
const markersClusterGroupRef = ref<L.MarkerClusterGroup>() |
|
|
|
const markersClusterGroupRef = ref<L.MarkerClusterGroup>() |
|
|
|
|
|
|
|
|
|
|
|
const mapContainerRef = ref<HTMLElement>() |
|
|
|
const mapContainerRef = ref<HTMLElement>() |
|
|
|
|
|
|
|
|
|
|
|
const myMapRef = ref<L.Map>() |
|
|
|
const myMapRef = ref<L.Map>() |
|
|
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj, ref()) |
|
|
|
const meta = inject(MetaInj, ref()) |
|
|
|
|
|
|
|
|
|
|
|
const view = inject(ActiveViewInj, ref()) |
|
|
|
const view = inject(ActiveViewInj, ref()) |
|
|
|
|
|
|
|
|
|
|
|
const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook()) |
|
|
|
const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook()) |
|
|
|
|
|
|
|
|
|
|
|
const expandedFormDlg = ref(false) |
|
|
|
const expandedFormDlg = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const expandedFormRow = ref<RowType>() |
|
|
|
const expandedFormRow = ref<RowType>() |
|
|
|
|
|
|
|
|
|
|
|
const expandedFormRowState = ref<Record<string, any>>() |
|
|
|
const expandedFormRowState = ref<Record<string, any>>() |
|
|
|
const expandedFormClickedLatLongForNewRow = ref<[number, number]>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fallBackCenterLocation = { |
|
|
|
const fallBackCenterLocation = { |
|
|
|
lat: 51, |
|
|
|
lat: 51, |
|
|
@ -39,11 +48,11 @@ const fallBackCenterLocation = { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getMapZoomLocalStorageKey = (viewId: string) => { |
|
|
|
const getMapZoomLocalStorageKey = (viewId: string) => { |
|
|
|
return `mapView.zoom.${viewId}` |
|
|
|
return `mapView.${viewId}.zoom` |
|
|
|
} |
|
|
|
} |
|
|
|
const getMapCenterLocalStorageKey = (viewId: string) => `mapView.center.${viewId}` |
|
|
|
const getMapCenterLocalStorageKey = (viewId: string) => `mapView.${viewId}.center` |
|
|
|
|
|
|
|
|
|
|
|
const expandForm = (row: RowType, state?: Record<string, any>, clickedLatLongForNewRow?: [number, number]) => { |
|
|
|
const expandForm = (row: RowType, state?: Record<string, any>) => { |
|
|
|
const rowId = extractPkFromRow(row.row, meta.value!.columns!) |
|
|
|
const rowId = extractPkFromRow(row.row, meta.value!.columns!) |
|
|
|
if (rowId) { |
|
|
|
if (rowId) { |
|
|
|
router.push({ |
|
|
|
router.push({ |
|
|
@ -53,13 +62,9 @@ const expandForm = (row: RowType, state?: Record<string, any>, clickedLatLongFor |
|
|
|
}, |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
expandedFormClickedLatLongForNewRow.value = clickedLatLongForNewRow |
|
|
|
|
|
|
|
expandedFormRow.value = row |
|
|
|
expandedFormRow.value = row |
|
|
|
expandedFormRowState.value = state |
|
|
|
expandedFormRowState.value = state |
|
|
|
expandedFormDlg.value = true |
|
|
|
expandedFormDlg.value = true |
|
|
|
|
|
|
|
|
|
|
|
// const lat = state?.lat |
|
|
|
|
|
|
|
// const lng = state?.lng |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -85,7 +90,7 @@ const expandedFormOnRowIdDlg = computed({ |
|
|
|
|
|
|
|
|
|
|
|
const addMarker = (lat: number, long: number, row: RowType) => { |
|
|
|
const addMarker = (lat: number, long: number, row: RowType) => { |
|
|
|
if (markersClusterGroupRef.value == null) { |
|
|
|
if (markersClusterGroupRef.value == null) { |
|
|
|
throw new Error('Map is null') |
|
|
|
throw new Error('Marker cluster is null') |
|
|
|
} |
|
|
|
} |
|
|
|
const newMarker = L.marker([lat, long]).on('click', () => { |
|
|
|
const newMarker = L.marker([lat, long]).on('click', () => { |
|
|
|
expandForm(row) |
|
|
|
expandForm(row) |
|
|
@ -98,7 +103,6 @@ const resetZoomAndCenterBasedOnLocalStorage = () => { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
const initialZoomLevel = parseInt(localStorage.getItem(getMapZoomLocalStorageKey(mapMetaData.value.fk_view_id)) || '10') |
|
|
|
const initialZoomLevel = parseInt(localStorage.getItem(getMapZoomLocalStorageKey(mapMetaData.value.fk_view_id)) || '10') |
|
|
|
|
|
|
|
|
|
|
|
const initialCenterLocalStorageStr = localStorage.getItem(getMapCenterLocalStorageKey(mapMetaData.value.fk_view_id)) |
|
|
|
const initialCenterLocalStorageStr = localStorage.getItem(getMapCenterLocalStorageKey(mapMetaData.value.fk_view_id)) |
|
|
|
const initialCenter = initialCenterLocalStorageStr ? JSON.parse(initialCenterLocalStorageStr) : fallBackCenterLocation |
|
|
|
const initialCenter = initialCenterLocalStorageStr ? JSON.parse(initialCenterLocalStorageStr) : fallBackCenterLocation |
|
|
|
|
|
|
|
|
|
|
@ -142,13 +146,12 @@ onMounted(async () => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
myMap.on('contextmenu', async function (e) { |
|
|
|
myMap.on('contextmenu', async function (e) { |
|
|
|
const lat = e.latlng.lat |
|
|
|
const { lat, lng } = e.latlng |
|
|
|
const lng = e.latlng.lng |
|
|
|
|
|
|
|
const newRow = await addEmptyRow() |
|
|
|
const newRow = await addEmptyRow() |
|
|
|
if (geoDataFieldColumn.value?.title) { |
|
|
|
if (geoDataFieldColumn.value?.title) { |
|
|
|
newRow.row[geoDataFieldColumn.value.title] = latLongToJoinedString(lat, lng) |
|
|
|
newRow.row[geoDataFieldColumn.value.title] = latLongToJoinedString(lat, lng) |
|
|
|
} |
|
|
|
} |
|
|
|
expandForm(newRow, [lat, lng]) |
|
|
|
expandForm(newRow) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -205,13 +208,13 @@ const count = computed(() => paginationData.value.totalRows) |
|
|
|
<div id="mapContainer" ref="mapContainerRef"> |
|
|
|
<div id="mapContainer" ref="mapContainerRef"> |
|
|
|
<a-tooltip placement="bottom" class="tooltip"> |
|
|
|
<a-tooltip placement="bottom" class="tooltip"> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<span v-if="count > 1000"> You're over the limit. </span> |
|
|
|
<span v-if="count > 1000"> {{ $t('msg.info.map.overLimit') }} </span> |
|
|
|
<span v-else> You're getting close to the limit. </span> |
|
|
|
<span v-else-if="count > 900"> {{ $t('msg.info.map.closeLimit') }} </span> |
|
|
|
<span> The limit of markers shown in a Map View is 1000 records. </span> |
|
|
|
<span> {{ $t('msg.info.map.limitNumber') }} </span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<div v-if="count > 900" class="nc-warning-info flex min-w-32px h-32px items-center gap-1 px-2 bg-white"> |
|
|
|
<div v-if="count > 900" class="nc-warning-info flex min-w-32px h-32px items-center gap-1 px-2 bg-white"> |
|
|
|
<div>{{ count }} records</div> |
|
|
|
<div>{{ count }} {{ $t('objects.records') }}</div> |
|
|
|
<mdi-map-marker-alert /> |
|
|
|
<mdi-map-marker-alert /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-tooltip> |
|
|
|
</a-tooltip> |
|
|
|