class LeafletMap{constructor(){this.tileLayerUrl="https://{s}.tile.osm.org/{z}/{x}/{y}.png",this.tileLayerOptions={attribution:'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>',maxZoom:18}}init(){this.initBasicMap(),this.initShapeMap(),this.initDraggableMap(),this.initUserLocation(),this.initCustomIcons(),this.initLayerControl(),this.initGeoJsonMap()}addTileLayer(e){L.tileLayer(this.tileLayerUrl,this.tileLayerOptions).addTo(e)}initBasicMap(){var e=document.getElementById("basicMap");e&&(e=L.map(e).setView([42.35,-71.08],10),this.addTileLayer(e))}initShapeMap(){var e,a=document.getElementById("shapeMap");a&&(a=L.map(a).setView([51.5,-.09],12),e=L.icon({iconUrl:"assets/images/leaflet/marker-icon.png",shadowUrl:"assets/images/leaflet/marker-shadow.png"}),L.marker([51.5,-.09],{icon:e}).addTo(a),L.circle([51.508,-.11],{color:"red",fillColor:"#f03",fillOpacity:.5,radius:500}).addTo(a),L.polygon([[51.509,-.08],[51.503,-.06],[51.51,-.047]]).addTo(a),this.addTileLayer(a))}initDraggableMap(){var e,a=document.getElementById("dragMap");a&&(a=L.map(a).setView([48.817152,2.455],12),e=L.icon({iconUrl:"assets/images/leaflet/marker-icon.png",shadowUrl:"assets/images/leaflet/marker-shadow.png"}),L.marker([48.817152,2.455],{draggable:!0,icon:e}).addTo(a).bindPopup("<b>You're here!</b>").openPopup(),this.addTileLayer(a))}initUserLocation(){var e=document.getElementById("userLocation");if(e){let a=L.map(e).setView([42.35,-71.08],10);a.locate({setView:!0,maxZoom:16}),a.on("locationfound",e=>{L.marker(e.latlng).addTo(a).bindPopup(`You are somewhere around ${Math.round(e.accuracy)} meters from this point`).openPopup(),L.circle(e.latlng,e.accuracy).addTo(a)}),this.addTileLayer(a)}}initCustomIcons(){var e,a=document.getElementById("customIcons");a&&(a=L.map(a).setView([51.5,-.09],10),e=e=>L.icon({iconUrl:`assets/images/leaflet/leaf-${e}.png`,shadowUrl:"assets/images/leaflet/leaf-shadow.png",iconSize:[38,95],shadowSize:[50,64],iconAnchor:[22,94],shadowAnchor:[4,62],popupAnchor:[-3,-76]}),L.marker([51.5,-.09],{icon:e("red")}).addTo(a),L.marker([51.4,-.51],{icon:e("green")}).addTo(a),L.marker([51.49,-.45],{icon:e("orange")}).addTo(a),this.addTileLayer(a))}initLayerControl(){var e,a,t,i,o=document.getElementById("layerControl");o&&(i=L.icon({iconUrl:"assets/images/leaflet/marker-icon.png",shadowUrl:"assets/images/leaflet/marker-shadow.png"}),e=L.marker([39.61,-105.02],{icon:i}).bindPopup("This is Littleton, CO."),a=L.marker([39.74,-104.99],{icon:i}).bindPopup("This is Denver, CO."),t=L.marker([39.73,-104.8],{icon:i}).bindPopup("This is Aurora, CO."),i=L.marker([39.77,-105.23],{icon:i}).bindPopup("This is Golden, CO."),e=L.layerGroup([e,a,t,i]),a=L.tileLayer(this.tileLayerUrl,this.tileLayerOptions),t=L.tileLayer("http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg",{attribution:this.tileLayerOptions.attribution,maxZoom:18}),i=L.map(o,{center:[39.73,-104.99],zoom:10,layers:[a,e]}),L.control.layers({Street:a,Watercolor:t},{Cities:e}).addTo(i))}initGeoJsonMap(){var e=document.getElementById("geoJson");if(e&&"undefined"!=typeof statesData){e=L.map(e).setView([44.2669,-72.576],3);let a=e=>1e3<e?"#800026":500<e?"#BD0026":200<e?"#E31A1C":100<e?"#FC4E2A":50<e?"#FD8D3C":20<e?"#FEB24C":10<e?"#FED976":"#FFEDA0";L.geoJson(statesData,{style:e=>({fillColor:a(e.properties.density),weight:2,opacity:1,color:"white",dashArray:"3",fillOpacity:.7})}).addTo(e),this.addTileLayer(e)}}}document.addEventListener("DOMContentLoaded",()=>{(new LeafletMap).init()});