Skip to content

Commit

Permalink
Add leaflet marker clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Sep 19, 2023
1 parent bdff946 commit 3036237
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 32 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"axios": "^1.4.0",
"js-yaml": "^4.1.0",
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
"markdown-it-anchor": "^8.6.7",
"pinia": "^2.1.6",
"unhead": "^1.3.4",
Expand Down
20 changes: 18 additions & 2 deletions src/components/Map/VMap.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { makeTileFromConfiguration } from './utils/makeTileFromConfiguration'
import '@geoman-io/leaflet-geoman-free'
import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'
import 'leaflet.markercluster/dist/leaflet.markercluster'
import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
delete L.Icon.Default.prototype._getIconUrl
Expand Down Expand Up @@ -94,6 +97,16 @@ const props = defineProps({
prefix: {
type: [String, Boolean],
default: false
},
cluster: {
type: Boolean,
default: true
},
maxClusterRadius: {
type: Number,
default: 20
}
})
Expand Down Expand Up @@ -155,7 +168,8 @@ onMounted(() => {
center: props.center,
zoom: props.zoom,
worldCopyJump: true,
dragging: props.dragging
dragging: props.dragging,
maxZoom: props.maxZoom
}
if (props.disableZoom) {
Expand All @@ -169,7 +183,9 @@ onMounted(() => {
}
drawnItems = new L.FeatureGroup()
geoJSONGroup = new L.FeatureGroup()
geoJSONGroup = props.cluster
? new L.markerClusterGroup({ maxClusterRadius: props.maxClusterRadius })
: new L.FeatureGroup()
mapObject = L.map(leafletMap.value, options)
mapObject.attributionControl.setPrefix(props.prefix)
Expand Down
29 changes: 0 additions & 29 deletions src/modules/otus/utils/files.js

This file was deleted.

1 change: 0 additions & 1 deletion src/modules/otus/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './files'
export * from './isRankGroup'
export * from './makeGeoJSONFeature'
export * from './removeDuplicateShapes'

0 comments on commit 3036237

Please sign in to comment.