1(function($){ 2 "use strict"; 3 4 /* Dicrectory Single Google Map */ 5 async function initMap() { 6 const ovaMap = document.getElementById("ova_dir_single_google_map"); 7 if (! ovaMap ) {return;} 8 const dataMap = JSON.parse(ovaMap.getAttribute('data-map')); 9 const latitude = parseFloat(dataMap.latitude); 10 const longitude = parseFloat(dataMap.longitude); 11 const zoom = parseInt(dataMap.zoom); 12 const map = new google.maps.Map(document.getElementById("ova_dir_single_google_map"), { 13 center: { lat: latitude, lng: longitude }, 14 zoom: zoom, 15 mapTypeControl: false, 16 }); 17 if ( latitude && longitude ) { 18 const marker = new google.maps.Marker({ 19 map, 20 anchorPoint: new google.maps.Point(0, -29), 21 position: { lat: latitude, lng: longitude }, 22 }); 23 } 24 } 25 26 /* Directory Archive Google Map */ 27 async function initMap2() { 28 const ovaMap = document.getElementById("ova_dir_archive_google_map"); 29 if (! ovaMap ) {return;} 30 const { AdvancedMarkerElement } = await google.maps.importLibrary("marker"); 31 const dataMap = JSON.parse(ovaMap.getAttribute('data-map')); 32 const latitude = parseFloat(dataMap.latitude); 33 const longitude = parseFloat(dataMap.longitude); 34 const zoom = parseInt(dataMap.zoom); 35 const properties = JSON.parse(ovaMap.getAttribute('data-properties')); 36 var markers = []; 37 var latitudes = []; 38 var longitudes = []; 39 if ( properties.length ) { 40 for (const property of properties) { 41 if ( property.position.lat != '' && property.position.lng != '' ) { 42 let latitude = parseFloat(property.position.lat); 43 let longitude = parseFloat(property.position.lng); 44 const marker = new google.maps.marker.AdvancedMarkerElement({ 45 content: buildContent(property), 46 position : { lat: latitude, lng: longitude }, 47 title: property.title, 48 }); 49 50 marker.addListener("click", () => { 51 toggleHighlight(marker, property); 52 }); 53 54 markers.push(marker); 55 latitudes.push(latitude); 56 longitudes.push(longitude); 57 } 58 } 59 60 } else { 61 const marker = new google.maps.marker.AdvancedMarkerElement({ 62 position : { lat: latitude, lng: longitude }, 63 }); 64 markers.push(marker); 65 } 66 67 var positionCenter = {}; 68 if ( latitudes.length > 0 && longitudes.length > 0 ) { 69 positionCenter = { lat: average(latitudes), lng: average(longitudes) }; 70 } else { 71 positionCenter = { lat: latitude, lng: longitude }; 72 } 73 const map = new google.maps.Map(document.getElementById("ova_dir_archive_google_map"), { 74 zoom: zoom, 75 center: positionCenter, 76 mapId: "ova_dir_archive_google_map", 77 }); 78 79 new markerClusterer.MarkerClusterer({ markers, map }); 80 81 function average(arr){ 82 const sum = arr.reduce((a, b) => a + b, 0); 83 const avg = (sum / arr.length) || 0; 84 return avg; 85 } 86 87 function toggleHighlight(markerView, property) { 88 if (markerView.content.classList.contains("highlight")) { 89 markerView.content.classList.remove("highlight"); 90 markerView.zIndex = null; 91 } else { 92 markerView.content.classList.add("highlight"); 93 markerView.zIndex = 1; 94 } 95 } 96 97 function buildContent(property) { 98 const content = document.createElement("div"); 99 100 content.classList.add("property"); 101 var categoryContent = ''; 102 if ( property.terms ) { 103 const terms = property.terms; 104 for (let i = 0; i < terms.length; i++) { 105 let separator = i + 1 < terms.length ? ', ' : ''; 106 categoryContent += `<a href="${terms[i].url}" title="${terms[i].name}">${terms[i].name}</a>${separator}`; 107 } 108 } 109 110 content.innerHTML = ` 111 <div class="avatar"> 112 <img src="${property.thumbnail}" alt="${property.image_alt}" /> 113 </div> 114 <div class="card"> 115 <a href="${property.url}" class="thumbnail" title="${property.title}"> 116 <img src="${property.thumbnail}" alt="${property.image_alt}" /> 117 </a> 118 <div class="content"> 119 <h2 class="title"> 120 <a href="${property.url}" title="${property.title}">${property.title}</a> 121 </h2> 122 <ul class="info"> 123 <li> 124 <i class="fas fa-map-marker-alt" aria-hidden="true"></i> 125 <div class="text">${property.address}</div class="text"> 126 </li> 127 <li> 128 <i class="far fa-folder" aria-hidden="true"></i><div class="text">${categoryContent}</div> 129 </li> 130 </ul> 131 </div> 132 </div> 133 `; 134 return content; 135 } 136 } 137 138 initMap(); 139 initMap2(); 140 if ( $('[data-fancybox="gallery"]').length ) { 141 Fancybox.bind('[data-fancybox="gallery"]', { 142 }); 143 } 144 145}) (jQuery);
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.