1markers = [] 2 3latlng = [50.115647, 8.70196522]; 4 5if(document.querySelector('#map')){ 6 7 var map = L.map('map', { 8 center: latlng, 9 zoom: 11, 10 zoomControl: false, 11 dragging: !L.Browser.mobile 12 }) 13 14 map.attributionControl.setPrefix('') 15 16 17 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { 18 maxZoom: 19, 19 attribution: '© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>' 20 }).addTo(map) 21 22 23 omsagMapIcon = L.icon(omsagMapIcon) 24 25 function randomMarker(){ 26 return [latlng[0] + Math.random() / 50, latlng[1] + Math.random() / 50] 27 } 28 29 function toggleOverlay(m){ 30 if(document.querySelector('#overlay').classList.contains('active') && document.querySelector('#overlay').getAttribute('markerID') == m.target.id){ 31 document.querySelector('#overlay').classList.remove('active') 32 return 33 } 34 35 document.querySelector('#overlay').setAttribute('markerID', m.target.id); 36 37 place = placeData[m.target.id] 38 39 addOrHideInfo('#overlay .type', place['Typ']) 40 addOrHideInfo('#overlay .name', place['Name']) 41 addOrHideInfo('#overlay .zipNplace', place.PLZ + ' ' + place.Ort) 42 addOrHideInfo('#overlay .street', place.Strasse + ' ' + place.Hausnummer) 43 addOrHideInfo('#overlay .tel', place['Telefon']) 44 addOrHideInfo('#overlay .fax', place['Telefax']) 45 addOrHideInfo('#overlay .website', place['Website']) 46 addOrHideInfo('#overlay .mail', place['E-Mail']) 47 48 document.querySelector('#overlay').classList.add('active') 49 } 50 51 function addOrHideInfo(selector, info){ 52 el = document.querySelector(selector) 53 54 if(!info){ 55 el.classList.add('hide') 56 return 57 } else { 58 el.classList.remove('hide') 59 } 60 61 el.innerHTML = info 62 63 if(selector.indexOf('.website') > 0) 64 el.innerHTML = '<a target="_blank" href="' + info + '">' + 'Webseite' + '</a>' 65 66 if(selector.indexOf('.mail') > 0) 67 el.innerHTML = '<a href="mailto:' + info + '">' + 'E-Mail' + '</a>' 68 69 if(selector.indexOf('.tel') > 0) 70 el.innerHTML = 'Tel: <a href="tel:' + info + '">' + info + '</a>' 71 72 if(selector.indexOf('.fax') > 0) 73 el.innerHTML = 'Fax: ' + info 74 } 75 76 for(var i in placeData){ 77 console.log('creating marker', placeData[i]) 78 marker = L.marker([placeData[i].lat, placeData[i].lon], { icon: omsagMapIcon }).addTo(map).on('click', toggleOverlay) 79 marker.id = i 80 81 markers.push(marker) 82 } 83 84 document.querySelector('#executeFilter').onclick = function(){ 85 let zip = document.querySelector('#cllZIP').value 86 let rad = document.querySelector('#cllRadius').value 87 let type = document.querySelector('#cclType').value 88 89 let lat = document.querySelector('#cllZIP').getAttribute('data-lat') 90 let lon = document.querySelector('#cllZIP').getAttribute('data-lon') 91 92 latlon = false 93 sourceLatLon = false 94 95 if(lat && lon){ 96 sourceLatLon = new L.LatLng(lat, lon); 97 } 98 99 if(document.querySelector('#cllZIP').value.toLowerCase() == 'deutschland') 100 rad = 400 101 102 103 104 for(var m in markers){ 105 marker = markers[m] 106 id = marker.id 107 108 map.addLayer(marker) 109 110 if(type) 111 if(placeData[id].Typ != type){ 112 map.removeLayer(marker) 113 } 114 115 if(zip && sourceLatLon){ 116 if(!rad) 117 rad = 5 118 119 if(sourceLatLon.distanceTo(marker._latlng) > rad * 1000) 120 map.removeLayer(marker) 121 } 122 } 123 } 124 125 126 document.querySelector('#cllZIP').onchange = function(){ 127 if(this.getAttribute('norefresh')){ 128 console.log('norefresh') 129 return; 130 } 131 132 getGeoCode(this.value) 133 } 134 135 function getGeoCode(query){ 136 fetch('https://nominatim.openstreetmap.org/search?format=json&q=' + query + ', Deutschland').then(function(response){ 137 if(!response.body) 138 return 139 140 response.json().then(function(entry){ 141 place = false 142 143 firstSearchClass = 'place' 144 secondSearchClass = 'boundary' 145 146 for(var i in entry){ 147 if(place) 148 continue 149 150 if(entry[i].class == firstSearchClass) 151 place = entry[i] 152 } 153 154 if(!place){ 155 for(var i in entry){ 156 if(place) 157 continue 158 159 if(entry[i].class == secondSearchClass) 160 place = entry[i] 161 } 162 } 163 164 field = document.querySelector('#cllZIP') 165 field.setAttribute("norefresh", 1) 166 167 if(!place){ 168 field.value = 'Ort konnte nicht gefunden werden!' 169 field.removeAttribute('norefresh') 170 field.removeAttribute('data-lat') 171 field.removeAttribute('data-lon') 172 return 173 } 174 175 if(place.display_name.toLowerCase() == 'deutschland') 176 map.setZoom(6) 177 else 178 map.setZoom(11) 179 180 map.flyTo([place.lat, place.lon]) 181 182 field.setAttribute("data-lat", place.lat) 183 field.setAttribute("data-lon", place.lon) 184 field.value = place.display_name 185 field.removeAttribute('norefresh') 186 187 document.querySelector('#executeFilter').onclick() 188 }) 189 190 191 }) 192} 193 194 jQuery(".placesWrapper").hide(); 195 jQuery( "div#placesList h3" ).click(function() { 196 jQuery(this).next(".placesWrapper").slideToggle(""); 197 jQuery(this).find("i").toggleClass("togglerotate"); 198}); 199 200 201jQuery(".close-overlay").click(function() { 202 jQuery("#overlay").removeClass("active"); 203}) 204 205 206 207}
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.