1class OpenStreetMap2{element={};environment={};editable=!1;bounds={};allMarkers=[];categorizedMarkers={};poiCollections=[];map={};constructor(t,e){this.element=t,this.environment=e,this.editable=this.element.classList.contains("editMarker"),this.bounds=new L.LatLngBounds,this.preparePoiCollection(),this.setMapDimensions(),this.createMap(),this.setMarkersOnMap()}preparePoiCollection(){this.poiCollections=JSON.parse(this.element.getAttribute("data-pois")||"[]")}setMarkersOnMap(){this.isPOICollectionsEmpty()?this.createMarkerBasedOnDataAttributes():this.createMarkerBasedOnPOICollections()}isPOICollectionsEmpty(){return 0===this.poiCollections.length}createMarkerBasedOnDataAttributes(){var t=this.getAttributeAsFloat("data-latitude"),e=this.getAttributeAsFloat("data-longitude");isNaN(t)||isNaN(e)||this.createMarkerByLatLng(t,e)}getAttributeAsFloat(t){return parseFloat(this.element.getAttribute(t)||"")}createMarkerBasedOnPOICollections(){this.createPointByCollectionType(),1<this.countObjectProperties(this.categorizedMarkers)&&this.showSwitchableCategories(),this.adjustMapZoom()}adjustMapZoom(){this.shouldFitBounds()?this.map.fitBounds(this.bounds):this.map.panTo([this.poiCollections[0].latitude,this.poiCollections[0].longitude])}shouldFitBounds(){return!0!==this.getSettings().forceZoom&&null!==this.poiCollections&&(1<this.poiCollections.length||1===this.poiCollections.length&&("Area"===this.poiCollections[0].collectionType||"Route"===this.poiCollections[0].collectionType))}setMapDimensions(){this.element.style.height=this.normalizeDimension(this.getSettings().mapHeight),this.element.style.width=this.normalizeDimension(this.getSettings().mapWidth)}normalizeDimension(t){let e=String(t);return this.canBeInterpretedAsNumber(e)&&(e+="px"),e}createMap(){this.map=L.map(this.element,{center:[this.getExtConf().defaultLatitude,this.getExtConf().defaultLongitude],zoom:this.getSettings().zoom?this.getSettings().zoom:12,editable:this.editable,scrollWheelZoom:"0"!==this.getSettings().activateScrollWheel}),L.tileLayer(this.getSettings().mapTile,{attribution:this.getSettings().mapTileAttribution,maxZoom:20}).addTo(this.map)}groupCategories(){const i={};return this.poiCollections.forEach(t=>{t.categories.map(t=>String(t.uid)).filter(t=>this.getSettings().categories.includes(t)).forEach(e=>{i.hasOwnProperty(e)||(i[e]=t.categories.find(t=>String(t.uid)===e))})}),i}getCategoriesOfCheckboxesWithStatus(t,e){let i=[];return(e?Array.from(t.querySelectorAll("input:checked")):Array.from(t.querySelectorAll("input:not(:checked)"))).forEach(t=>{i.push(parseInt(t.value))}),i}getMarkersToChangeVisibilityFor(t,e,o){var r=[];if(0!==this.allMarkers.length){var s,a,n=this.getCategoriesOfCheckboxesWithStatus(e,o);for(let t=0;t<this.allMarkers.length;t++)if(0!==(a=(s=this.allMarkers[t]).poiCollection.categories).length){let i;for(let e=0;e<a.length;e++){i=!1;for(let t=0;t<n.length;t++)a[e].uid===n[t]&&(i=!0);if(i===o)break}i&&r.push(s.marker)}}return r}showSwitchableCategories(){var t,e=this.groupCategories();let o=document.createElement("form");for(t in o.classList.add("txMaps2Form"),o.setAttribute("id","txMaps2Form-"+this.getContentRecord().uid),e)e.hasOwnProperty(t)&&(o.appendChild(this.getCheckbox(e[t])),o.querySelector("#checkCategory_"+t)?.insertAdjacentHTML("afterend",`<span class="map-category">${e[t].title}</span>`));o.querySelectorAll("input").forEach(i=>{i.addEventListener("click",()=>{let e=i.checked;var t=i.value;this.getMarkersToChangeVisibilityFor(t,o,e).forEach(t=>{e?this.map.addLayer(t):this.map.removeLayer(t)})})}),this.element.insertAdjacentElement("afterend",o)}getCheckbox(t){var e=document.createElement("div");return e.classList.add("form-group"),e.innerHTML=` 2 <div class="checkbox"> 3 <label> 4 <input type="checkbox" class="checkCategory" id="checkCategory_${t.uid}" checked="checked" value="${t.uid}"> 5 </label> 6 </div>`,e}countObjectProperties(t){let e=0;for(var i in t)t.hasOwnProperty(i)&&e++;return e}createPointByCollectionType(){let i,o=0;null!==this.poiCollections&&this.poiCollections.length&&this.poiCollections.forEach(e
6=>{switch(""===e.strokeColor&&(e.strokeColor=this.getExtConf().strokeColor),""===e.strokeOpacity&&(e.strokeOpacity=this.getExtConf().strokeOpacity),""===e.strokeWeight&&(e.strokeWeight=this.getExtConf().strokeWeight),""===e.fillColor&&(e.fillColor=this.getExtConf().fillColor),""===e.fillOpacity&&(e.fillOpacity=this.getExtConf().fillOpacity),i=null,e.collectionType){case"Point":i=this.createMarker(e);break;case"Area":i=this.createArea(e);break;case"Route":i=this.createRoute(e);break;case"Radius":i=this.createRadius(e)}this.allMarkers.push({marker:i,poiCollection:e});for(let t=o=0;t<e.categories.length;t++)o=e.categories[t].uid,this.categorizedMarkers.hasOwnProperty(o)||(this.categorizedMarkers[o]=[]),this.categorizedMarkers[o].push(i)})}createMarkerByLatLng(t,e){t=L.marker([t,e]).addTo(this.map);this.bounds.extend(t.getLatLng())}createMarker(t){var e,i=L.marker([t.latitude,t.longitude],{draggable:this.editable}).addTo(this.map);return t.hasOwnProperty("markerIcon")&&""!==t.markerIcon&&(e=L.icon({iconUrl:t.markerIcon,iconSize:[t.markerIconWidth,t.markerIconHeight],iconAnchor:[t.markerIconAnchorPosX,t.markerIconAnchorPosY]}),i.setIcon(e)),this.bounds.extend(i.getLatLng()),this.editable?this.addEditListeners(this.element,i,t):this.addInfoWindow(i,t),i}createArea(t){let e=[];t.pois.forEach(t=>{t=[t.latitude,t.longitude];this.bounds.extend(t),e.push(t)});var i=L.polygon(e,{color:t.strokeColor,opacity:t.strokeOpacity,weight:t.strokeWeight,fillColor:t.fillColor,fillOpacity:t.fillOpacity}).addTo(this.map);return this.addInfoWindow(i,t),i}createRoute(t){let e=[];t.pois.forEach(t=>{t=[t.latitude,t.longitude];this.bounds.extend(t),e.push(t)});var i=L.polyline(e,{color:t.strokeColor,opacity:t.strokeOpacity,weight:t.strokeWeight,fillColor:t.fillColor,fillOpacity:t.fillOpacity}).addTo(this.map);return this.addInfoWindow(i,t),i}createRadius(t){var e=L.circle([t.latitude,t.longitude],{color:t.strokeColor,opacity:t.strokeOpacity,weight:t.strokeWeight,fillColor:t.fillColor,fillOpacity:t.fillOpacity,radius:t.radius}).addTo(this.map);return this.bounds.extend(e.getBounds()),this.addInfoWindow(e,t),e}addInfoWindow(e,t){e.addEventListener("click",()=>{fetch(this.environment.ajaxUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({poiCollection:t.uid})}).then(t=>t.json()).then(t=>{e.bindPopup(t.content).openPopup()}).catch(t=>console.error("Error:",t))})}addEditListeners(i,o,t){o.on("dragend",()=>{var t=o.getLatLng().lat.toFixed(6),e=o.getLatLng().lng.toFixed(6);i.previousElementSibling?.querySelector("input.latitude-"+this.getContentRecord().uid).setAttribute("value",t),i.previousElementSibling?.querySelector("input.longitude-"+this.getContentRecord().uid).setAttribute("value",e)}),this.map.on("click",t=>{o.setLatLng(t.latlng),i.previousElementSibling?.querySelector("input.latitude-"+this.getContentRecord().uid).setAttribute("value",t.latlng.lat.toFixed(6)),i.previousElementSibling?.querySelector("input.longitude-"+this.getContentRecord().uid).setAttribute("value",t.latlng.lng.toFixed(6))})}canBeInterpretedAsNumber(t){return"number"==typeof t||!isNaN(Number(t))}getContentRecord(){return this.environment.contentRecord}getExtConf(){return this.environment.extConf}getSettings(){return this.environment.settings}}let maps2OpenStreetMaps=[];document.querySelectorAll(".maps2").forEach(t=>{var e=void 0!==t.dataset.environment?t.dataset.environment:"{}",i=void 0!==t.dataset.override?t.dataset.override:"{}";const l=(...t)=>{let e={},i=!1,o=0;var r=t.length;for("[object Boolean]"===Object.prototype.toString.call(t[0])&&(i=t[0],o++);o<r;o++){var s,a=t[o],n=(s=void 0,a);for(s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i&&"[object Object]"===Object.prototype.toString.call(n[s])?e[s]=l(!0,e[s],n[s]):e[s]=n[s])}return e};maps2OpenStreetMaps.push(new OpenStreetMap2(t,l(!0,JSON.parse(e),JSON.parse(i))))}); 7//# sourceMappingURL=OpenStreetMap2.min.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.