From 3938e11d04565d28a0de6d3dd68d2d0f80dc5818 Mon Sep 17 00:00:00 2001 From: jlpereira Date: Tue, 19 Sep 2023 17:43:42 -0300 Subject: [PATCH] Add clusters type --- src/components/Map/VMap.client.vue | 23 ++++++++++++++++++- .../components/Panel/PanelMap/PanelMap.vue | 6 +++-- .../PanelMap/clusters/CollectionObject.js | 8 +++++++ .../Panel/PanelMap/clusters/Mixed.js | 18 +++++++++++++++ .../Panel/PanelMap/clusters/TypeMaterial.js | 8 +++++++ .../Panel/PanelMap/clusters/index.js | 3 +++ .../PanelMap/clusters/makeClusterIconFor.js | 17 ++++++++++++++ .../PanelMap/{ => components}/CachedMap.vue | 0 .../components}/Search/ListResults.vue | 0 .../PanelMap/components}/Search/OtuSearch.vue | 2 +- .../PanelMap/components}/Search/SearchBar.vue | 0 11 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/modules/otus/components/Panel/PanelMap/clusters/CollectionObject.js create mode 100644 src/modules/otus/components/Panel/PanelMap/clusters/Mixed.js create mode 100644 src/modules/otus/components/Panel/PanelMap/clusters/TypeMaterial.js create mode 100644 src/modules/otus/components/Panel/PanelMap/clusters/index.js create mode 100644 src/modules/otus/components/Panel/PanelMap/clusters/makeClusterIconFor.js rename src/modules/otus/components/Panel/PanelMap/{ => components}/CachedMap.vue (100%) rename src/modules/otus/components/{ => Panel/PanelMap/components}/Search/ListResults.vue (100%) rename src/modules/otus/components/{ => Panel/PanelMap/components}/Search/OtuSearch.vue (98%) rename src/modules/otus/components/{ => Panel/PanelMap/components}/Search/SearchBar.vue (100%) diff --git a/src/components/Map/VMap.client.vue b/src/components/Map/VMap.client.vue index 311ed39..af4f396 100644 --- a/src/components/Map/VMap.client.vue +++ b/src/components/Map/VMap.client.vue @@ -107,6 +107,11 @@ const props = defineProps({ maxClusterRadius: { type: Number, default: 20 + }, + + clusterIconCreateFunction: { + type: Function, + default: undefined } }) @@ -155,6 +160,22 @@ watch( } ) +function makeClusterOptions() { + const opt = { + maxClusterRadius: props.maxClusterRadius + } + + if (props.clusterIconCreateFunction) { + Object.assign(opt, { + iconCreateFunction: (cluster) => { + return props.clusterIconCreateFunction({ L, cluster }) + } + }) + } + + return opt +} + onMounted(() => { const tiles = makeTileFromConfiguration(L, { maxZoom: props.maxZoom, @@ -184,7 +205,7 @@ onMounted(() => { drawnItems = new L.FeatureGroup() geoJSONGroup = props.cluster - ? new L.markerClusterGroup({ maxClusterRadius: props.maxClusterRadius }) + ? new L.markerClusterGroup(makeClusterOptions()) : new L.FeatureGroup() mapObject = L.map(leafletMap.value, options) diff --git a/src/modules/otus/components/Panel/PanelMap/PanelMap.vue b/src/modules/otus/components/Panel/PanelMap/PanelMap.vue index 7f010eb..36d9250 100644 --- a/src/modules/otus/components/Panel/PanelMap/PanelMap.vue +++ b/src/modules/otus/components/Panel/PanelMap/PanelMap.vue @@ -9,6 +9,7 @@ cluster :zoom="zoom" :geojson="store.distribution.geojson" + :cluster-icon-create-function="makeClusterIconFor" @geojson:ready="() => (isLoading = false)" /> @@ -61,8 +62,9 @@