Skip to content
Snippets Groups Projects
Commit b5464422 authored by Olivia206's avatar Olivia206
Browse files

mask map

parent 6e8709b7
No related branches found
No related tags found
No related merge requests found
...@@ -3,14 +3,17 @@ const partnersMaps = document.querySelectorAll('.block-partners--map'); ...@@ -3,14 +3,17 @@ const partnersMaps = document.querySelectorAll('.block-partners--map');
class BlockPartners { class BlockPartners {
constructor (dom) { constructor (dom) {
this.dom = dom; this.dom = dom;
this.init(); this.init();
} }
init() { init() {
this.markers = [];
this.setMap = false;
this.content = this.dom.querySelector('#map'); this.content = this.dom.querySelector('#map');
this.partnersList = this.content.querySelectorAll('.organization'); this.partnersList = this.content.querySelectorAll('.organization');
this.classPartner = 'organization'; this.classPartner = 'organization';
this.markers = []; this.classHidden = 'not-active';
let map = L.map('map', { let map = L.map('map', {
scrollWheelZoom: false scrollWheelZoom: false
...@@ -19,25 +22,34 @@ class BlockPartners { ...@@ -19,25 +22,34 @@ class BlockPartners {
iconUrl: '/assets/images/map-marker.svg', iconUrl: '/assets/images/map-marker.svg',
iconSize: [17, 26], iconSize: [17, 26],
}); });
this.listen(map); this.setPartners(map);
this.getMapBounds(map);
}
listen (map) {
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
if (this.setMap) {
this.listen(map);
this.getMapBounds(map);
} else {
this.content.classList.add(this.classHidden);
this.content.setAttribute("aria-hidden", "true")
return;
}
}
setPartners (map) {
this.partnersList.forEach((partner) => { this.partnersList.forEach((partner) => {
let latitude = parseFloat(partner.getAttribute('data-latitude')), let latitude = parseFloat(partner.getAttribute('data-latitude')),
longitude = parseFloat(partner.getAttribute('data-longitude')), longitude = parseFloat(partner.getAttribute('data-longitude')),
mapLocation = [latitude, longitude]; mapLocation = [latitude, longitude];
if (!!latitude && !!longitude) { if (!!latitude && !!longitude) {
this.newMarker(map, mapLocation, partner); this.newMarker(map, mapLocation, partner);
this.setMap = true;
} }
}); });
} }
listen (map) {
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
}
newMarker(map, mapLocation, partner) { newMarker(map, mapLocation, partner) {
let marker = new L.marker(mapLocation, { let marker = new L.marker(mapLocation, {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
.map .map
height: 600px height: 600px
z-index: 1 z-index: 1
&.not-active
display: none
> .organization, > .organization,
.leaflet-popup-tip-container .leaflet-popup-tip-container
display: none display: none
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment