Skip to content

Commit

Permalink
Add markers colors for different type
Browse files Browse the repository at this point in the history
  • Loading branch information
José Luis Pereira committed Sep 10, 2022
1 parent 1071ee8 commit 3af023e
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/assets/css/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
--color-base-border: 203, 213, 225;
--color-base-content: 0, 0, 0;

--color-map-georeference-marker: 239, 68, 68;
--color-map-georeference: 239, 68, 68;
--color-map-asserted: 249, 115, 22;
--color-map-type-material: 51,136,255;
--color-map-collection-object: 51,136,255;
--color-map-type-material: 51, 136, 255;
--color-map-collection-object: 239, 68, 68;
}

.dark {
Expand Down
7 changes: 7 additions & 0 deletions src/components/Map/icons/AssertedDistribution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import L from 'leaflet'

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

export const CollectionObject = L.divIcon({
className: 'bg-map-collection-object bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import L from 'leaflet'

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

export const TypeMaterial = L.divIcon({
className: 'bg-map-type-material bg-opacity-50 rounded-full',
iconSize: [8, 8],
iconAnchor: [4, 4]
})
4 changes: 4 additions & 0 deletions src/components/Map/icons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './AssertedDistribution'
export * from './CollectionObject'
export * from './Georeference'
export * from './TypeMaterial'
7 changes: 7 additions & 0 deletions src/components/Map/shapes/AssertedDistribution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const AssertedDistribution = ({
color: 'rgb(var(--color-map-asserted))',
weight: 1,
dashArray: '3',
dashOffset: '3',
fillOpacity: 0.5
})
5 changes: 5 additions & 0 deletions src/components/Map/shapes/CollectionObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const CollectionObject = ({
color: `rgb(var(--color-map-collection-object))`,
weight: 1,
fillOpacity: 0.5
})
5 changes: 5 additions & 0 deletions src/components/Map/shapes/TypeMaterial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const TypeMaterial = ({
color: `rgb(var(--color-map-type-material))`,
weight: 1,
fillOpacity: 0.5
})
3 changes: 3 additions & 0 deletions src/components/Map/shapes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './AssertedDistribution'
export * from './CollectionObject'
export * from './TypeMaterial'
39 changes: 11 additions & 28 deletions src/components/Map/utils/geojsonOptions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { squareMarker } from "../markers"
import L from 'leaflet'
import L, { Icon } from 'leaflet'
import * as Icons from '../icons'
import * as Shape from '../shapes'

export default ({
onEachFeature: (feature, layer) => {
Expand All @@ -13,35 +14,17 @@ export default ({
)
},

pointToLayer: (_, latLng) => {
return L.marker(latLng, { icon: squareMarker })
pointToLayer: (feature, latLng) => {
const type = feature.properties?.base.type

return L.marker(latLng, { icon: Icons[type] || Icon.Georeference })
},

style: (feature) => {
if (feature.properties?.base?.type === 'AssertedDistribution') {
return {
color: 'rgb(var(--color-map-asserted))',
weight: 1,
dashArray: '3',
dashOffset: '3',
fillOpacity: 0.5
}
}

if (feature.properties?.base?.type === 'TypeMaterial') {
return {
color: 'rgb(var(--color-map-type-material))',
weight: 1,
fillOpacity: 0.5
}
}

if (feature.properties?.base?.type === 'CollectionObject') {
return {
color: 'rgb(var(--color-map-collection-object))',
weight: 1,
fillOpacity: 0.5
}
const type = feature.properties?.base.type

if (Shape[type]) {
return Shape[type]
}
}
})
6 changes: 4 additions & 2 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ module.exports = {
},

map: {
georeference: withOpacity('--color-map-georeference-marker'),
asserted: withOpacity('--color-map-asserted')
georeference: withOpacity('--color-map-georeference'),
asserted: withOpacity('--color-map-asserted'),
'type-material': withOpacity('--color-map-type-material'),
'collection-object': withOpacity('--color-map-collection-object')
},

primary: {
Expand Down

0 comments on commit 3af023e

Please sign in to comment.