Skip to content

Commit

Permalink
Refactor geojson options
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Apr 18, 2023
1 parent 16f4a26 commit 2c17242
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/Map/VMap.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ onUnmounted(() => {
function setGeoJSON(geojson) {
if (geojson) {
L.geoJSON(geojson, {
...geojsonDefaultOptions,
...geojsonDefaultOptions(L),
...props.geojsonOptions
}).addTo(geoJSONGroup)
Expand Down
5 changes: 2 additions & 3 deletions src/components/Map/icons/AssertedDistribution.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import L from 'leaflet'

export const AssertedDistribution = L.divIcon({
export const AssertedDistribution = {
className: 'bg-map-asserted bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
}
6 changes: 2 additions & 4 deletions src/components/Map/icons/CollectionObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import L from 'leaflet'

export const CollectionObject = L.divIcon({
export const CollectionObject = {
className: 'bg-map-collection-object bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
}
6 changes: 2 additions & 4 deletions src/components/Map/icons/Georeference.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import L from 'leaflet'

export const Georeference = L.divIcon({
export const Georeference = {
className: 'bg-map-georeference bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
}
6 changes: 2 additions & 4 deletions src/components/Map/icons/TypeMaterial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import L from 'leaflet'

export const TypeMaterial = L.divIcon({
export const TypeMaterial = {
className: 'bg-map-type-material bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
}
9 changes: 6 additions & 3 deletions src/components/Map/utils/geojsonOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getRelevantType(base) {
return types[0]
}

export default {
export default (L) => ({
onEachFeature: (feature, layer) => {
const label = `
<div class="max-h-32 overflow-y-auto text-xs">
Expand Down Expand Up @@ -53,7 +53,10 @@ export default {

pointToLayer: (feature, latLng) => {
const type = getRelevantType(feature.properties.base)
const marker = L.marker(latLng, { icon: Icons[type] || Icon.Georeference })
const markerStyle = Icons[type] || Icon.Georeference
const marker = L.marker(latLng, {
icon: L.divIcon(markerStyle)
})

marker.pm.setOptions(DEFAULT_OPTIONS)

Expand All @@ -67,4 +70,4 @@ export default {
return Shape[type]
}
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ const props = defineProps({
taxonId: {
type: [Number, String],
required: true
},
taxon: {
type: Object,
default: undefined
},
otu: {
type: Object,
default: undefined
}
})
Expand Down

0 comments on commit 2c17242

Please sign in to comment.