correction map loaded trigger to display map icons
This commit is contained in:
parent
1d7dfe72c2
commit
bd07a046de
|
@ -29,7 +29,7 @@ import router from './router/router';
|
|||
|
||||
// } (Drupal));
|
||||
|
||||
(function (Drupal, drupalSettings) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
const CaravaneTheme = function () {
|
||||
const _is_front = drupalSettings.path.isFront
|
||||
console.log('drupalSettings', drupalSettings)
|
||||
|
@ -146,48 +146,50 @@ import router from './router/router';
|
|||
}
|
||||
|
||||
function setupEtapeMapPopup(store) {
|
||||
jQuery(document).bind('leaflet.map', function(event, map, lMap) {
|
||||
|
||||
//setTimeout(() => {
|
||||
const icons = document.querySelectorAll('.leaflet-map-divicon');
|
||||
for (let icon of icons) {
|
||||
const colorContainer = icon.querySelector('.couleur');
|
||||
const colorDiv = colorContainer.querySelector('div > div:nth-of-type(4)');
|
||||
const color = colorDiv.innerText.substring(colorDiv.innerText.indexOf('>') + 1, colorDiv.innerText.indexOf('<', colorDiv.innerText.indexOf('>') + 1)).trim();
|
||||
console.log(color);
|
||||
|
||||
Drupal.behaviors.customLeafletInteraction = {
|
||||
attach: function(context, settings) {
|
||||
$(context).on('leafletMapInit', function (e, settings, map, mapid, markers) {
|
||||
const icons = document.querySelectorAll('.leaflet-map-divicon');
|
||||
for (let icon of icons) {
|
||||
const colorContainer = icon.querySelector('.couleur');
|
||||
const colorDiv = colorContainer.querySelector('div > div:nth-of-type(4)');
|
||||
const color = colorDiv.innerText.substring(colorDiv.innerText.indexOf('>') + 1, colorDiv.innerText.indexOf('<', colorDiv.innerText.indexOf('>') + 1)).trim();
|
||||
console.log(color);
|
||||
|
||||
|
||||
const nid = icon.querySelector('.nid');
|
||||
const nidValue = nid.querySelector('div > div').innerText;
|
||||
const nid = icon.querySelector('.nid');
|
||||
const nidValue = nid.querySelector('div > div').innerText;
|
||||
|
||||
icon.addEventListener('click', function(event) {
|
||||
store.fetchEtapeData(nidValue);
|
||||
});
|
||||
|
||||
colorContainer.remove();
|
||||
nid.remove();
|
||||
const iconElements = icon.querySelectorAll('div');
|
||||
for (let iconElement of iconElements) {
|
||||
iconElement.style.backgroundColor = color;
|
||||
}
|
||||
icon.removeAttribute('title');
|
||||
|
||||
icon.addEventListener('mouseenter', function (event) {
|
||||
icon.style.transform = `${icon.style.transform} scale(1.1)`;
|
||||
const popup = document.querySelector('.leaflet-tooltip-center > div');
|
||||
popup.style.opacity = "1";
|
||||
});
|
||||
|
||||
icon.addEventListener('mouseleave', function (event) {
|
||||
icon.style.transform = icon.style.transform.split(' ')[0] + icon.style.transform.split(' ')[1] + icon.style.transform.split(' ')[2];
|
||||
})
|
||||
}
|
||||
|
||||
icon.addEventListener('click', function(event) {
|
||||
store.fetchEtapeData(nidValue);
|
||||
});
|
||||
|
||||
colorContainer.remove();
|
||||
nid.remove();
|
||||
const iconElements = icon.querySelectorAll('div');
|
||||
for (let iconElement of iconElements) {
|
||||
iconElement.style.backgroundColor = color;
|
||||
}
|
||||
icon.removeAttribute('title');
|
||||
|
||||
icon.addEventListener('mouseenter', function (event) {
|
||||
icon.style.transform = `${icon.style.transform} scale(1.1)`;
|
||||
const popup = document.querySelector('.leaflet-tooltip-center > div');
|
||||
popup.style.opacity = "1";
|
||||
});
|
||||
|
||||
icon.addEventListener('mouseleave', function (event) {
|
||||
icon.style.transform = icon.style.transform.split(' ')[0] + icon.style.transform.split(' ')[1] + icon.style.transform.split(' ')[2];
|
||||
})
|
||||
}
|
||||
// }, 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
||||
} // end CaravaneTheme()
|
||||
|
||||
CaravaneTheme()
|
||||
})(Drupal, drupalSettings)
|
||||
})(jQuery, Drupal, drupalSettings)
|
Loading…
Reference in New Issue