1class leafletMap{constructor(options){this.options=options;this.zoom=10;this.init()} 2init(){if(this.options.markers){this.center=this.getLatLngCenter(this.options.markers);if('zoom' in this.options){this.zoom=this.options.zoom}}else{throw new Error('No map markers provided')}} 3renderMap(){let wrapper=document.querySelector('#'+this.options.selector);if(wrapper){let child=wrapper.firstChild;if(child){child.remove()} 4const map_id='map-'+this.options.id;let container=document.createElement('div');container.setAttribute('id',map_id);container.style.height=this.options.height+'px';wrapper.appendChild(container);this.map=new L.Map(container);if('markers' in this.options){const markers=this.options.markers;this.createMap(this.center,this.zoom);for(let i=0;i<markers.length;i++){this.addMarker(markers[i])}}else{throw new Error('No markers provided')}}else{throw new Error('Cannot find map container '+this.options.selector)}} 5createMap(center,zoom){this.map.setView(center,zoom);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(this.map)} 6centerMap(){this.map.flyTo(this.center,this.zoom)} 7addMarker(options){L.marker([options.lat,options.lng],{title:options.title}).addTo(this.map)} 8getLatLngCenter(markers){if(markers.length>1){let sumX=0;let sumY=0;let sumZ=0;for(let i=0;i<markers.length;i++){const lat=this.degr2rad(markers[i].lat);const lng=this.degr2rad(markers[i].lng);sumX+=Math.cos(lat)*Math.cos(lng);sumY+=Math.cos(lat)*Math.sin(lng);sumZ+=Math.sin(lat)} 9let avgX=sumX/markers.length;let avgY=sumY/markers.length;let avgZ=sumZ/markers.length;const lng=Math.atan2(avgY,avgX);const hyp=Math.sqrt(avgX*avgX+avgY*avgY);const lat=Math.atan2(avgZ,hyp);return([this.rad2degr(lat),this.rad2degr(lng)])}else{return[markers[0].lat,markers[0].lng]}} 10rad2degr(rad){return rad*180/Math.PI} 11degr2rad(degr){return degr*Math.PI/180}}
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.