Skip to content

Commit 9fff80d

Browse files
committed
Add pigs
1 parent e7f613f commit 9fff80d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

app/public/js/locations_map.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function addSource(name, source) {
66
});
77
}
88

9-
const isCow = ['==', ['get', 'type'], 'Venue'];
10-
const isPig = ['==', ['get', 'type'], 'Attraction'];
9+
const isCow = ['==', ['get', 'species'], 'dairy cattle'];
10+
const isPig = ['==', ['get', 'species'], 'pig'];
1111

1212
function addLayer(source) {
1313
if (map.getLayer('points')) {
@@ -18,7 +18,7 @@ function addLayer(source) {
1818
type: 'symbol',
1919
source,
2020
layout: {
21-
'icon-image': ['case', isCow, 'cow', isPig, 'pig', 'cow'],
21+
'icon-image': ['case', isCow, 'cow', isPig, 'pig', 'none'],
2222
'icon-size': 0.15,
2323
'icon-overlap': 'always'
2424
},
@@ -29,7 +29,8 @@ function addLayer(source) {
2929
let popups = null;
3030
const icons = {
3131
cow: '/img/cow.svg',
32-
pig: '/img/pig.svg'
32+
pig: '/img/pig.svg',
33+
none: '/img/none.svg'
3334
};
3435

3536
function initMap() {
@@ -59,11 +60,13 @@ function initMap() {
5960
if (popups) {
6061
popups.remove();
6162
}
62-
popups = new maplibregl.Popup()
63-
.setHTML(`<div class="popup-info"> ${content}</div>`)
64-
.setLngLat(feature.geometry.coordinates);
63+
if (feature.properties.species){
64+
popups = new maplibregl.Popup()
65+
.setHTML(`<div class="popup-info"> ${content}</div>`)
66+
.setLngLat(feature.geometry.coordinates);
6567

66-
popups.addTo(map);
68+
popups.addTo(map);
69+
}
6770
});
6871

6972
map.on('load', function () {

0 commit comments

Comments
 (0)