diff --git a/public/opac/js/openStreetMap/openStreetMap.js b/public/opac/js/openStreetMap/openStreetMap.js index a6311c84c0e3110dfd2c3559600dff726365e9ac..02adc3fbc654efb0572f8cdf6f03d0ca4702fc63 100644 --- a/public/opac/js/openStreetMap/openStreetMap.js +++ b/public/opac/js/openStreetMap/openStreetMap.js @@ -24,6 +24,11 @@ var loadMap = function() { var container = widget.find('.leaflet_osm'); + container.innerHTML = ''; + + if(null != (initialized = L.DomUtil.get(container.attr('id')))) + initialized._leaflet_id = null; + var disable_zoom_animation = container.data('osm-disable-zoom-animation'); var map = L.map(container.attr('id'), @@ -37,7 +42,7 @@ if (1 == container.attr('data-osm-layer')) L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', - {attribution: '©<a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}) + {attribution: '©<a href="https://osm.org/copyright">OpenStreetMap</a> contributors'}) .addTo(map); var clusterize_markers = (undefined != L.markerClusterGroup); @@ -116,6 +121,14 @@ map.fitBounds(markers_group.getBounds(), {padding: [1, 1]}); } + var initBokehAnchors = function() { + if ( typeof initializePopups === 'function') + initializePopups(); + + if ( typeof setupAnchorsTarget === 'function') + setupAnchorsTarget(); + } + map.on('popupclose', function() { if (clusterize_markers || relative_zoom) return; @@ -125,20 +138,20 @@ map.on('popupopen', function(event) { - $('.leaflet-popup-content img').on('load', function() { + $('.leaflet-popup-content img').on('load', function(e) { event.popup.update(); - }) - - event.popup.update(); + }); + + widget.on('mouseover', function(e) { + if ( ! widget.find('.leaflet-popup-content a[data-popup]').length) + return; - if ( typeof initializePopups === 'function') - initializePopups(); + initBokehAnchors(); + }); - if ( typeof setupAnchorsTarget === 'function') - setupAnchorsTarget(); + initBokehAnchors(); }); - originalPosition(); if (relative_zoom) map.zoomIn(relative_zoom);