{"version":3,"file":"js/custom/modals/select-location.js","mappings":";;;;;;AAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,8BAA8B,EAAE,yBAAyB,EAAE,EAAE,EAAE,EAAE,EAAE;AACnE,iCAAiC;AACjC,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,mBAAmB,4DAA4D,oBAAoB;AAC7I;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA,CAAC","sources":["webpack://metronic/../demo1/src/js/custom/modals/select-location.js"],"sourcesContent":["\"use strict\";\r\n\r\n// Class definition\r\nvar KTModalSelectLocation = function () {\r\n // Private variables\r\n var locationSelectTarget;\r\n var locationSelectButton;\r\n\r\n var modal;\r\n var selectedlocation = '';\r\n var mapInitialized = false;\r\n\r\n // Private functions\r\n var initMap = function() {\r\n // Check if Leaflet is included\r\n if (!L) {\r\n return;\r\n }\r\n\r\n // Define Map Location\r\n var leaflet = L.map('kt_modal_select_location_map', {\r\n center: [40.725, -73.985],\r\n zoom: 30\r\n });\r\n\r\n // Init Leaflet Map. For more info check the plugin's documentation: https://leafletjs.com/\r\n L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\r\n attribution: '© OpenStreetMap contributors'\r\n }).addTo(leaflet);\r\n\r\n // Set Geocoding\r\n var geocodeService;\r\n if (typeof L.esri.Geocoding === 'undefined') {\r\n geocodeService = L.esri.geocodeService();\r\n } else {\r\n geocodeService = L.esri.Geocoding.geocodeService();\r\n }\r\n\r\n // Define Marker Layer\r\n var markerLayer = L.layerGroup().addTo(leaflet);\r\n\r\n // Set Custom SVG icon marker\r\n var leafletIcon = L.divIcon({\r\n html: ``,\r\n bgPos: [10, 10],\r\n iconAnchor: [20, 37],\r\n popupAnchor: [0, -37],\r\n className: 'leaflet-marker'\r\n });\r\n\r\n // Map onClick Action\r\n leaflet.on('click', function (e) {\r\n geocodeService.reverse().latlng(e.latlng).run(function (error, result) {\r\n if (error) {\r\n return;\r\n }\r\n markerLayer.clearLayers();\r\n selectedlocation = result.address.Match_addr;\r\n L.marker(result.latlng, { icon: leafletIcon }).addTo(markerLayer).bindPopup(result.address.Match_addr, { closeButton: false }).openPopup();\r\n\r\n // Show popup confirmation. For more info check the plugin's official documentation: https://sweetalert2.github.io/\r\n Swal.fire({\r\n html: '
Your selected - \"' + selectedlocation + '\".
' + 'Click on the \"Apply\" button to select this location.',\r\n icon: \"success\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n }).then(function (result) {\r\n // Confirmed\r\n });\r\n });\r\n });\r\n }\r\n\r\n var handleSelection = function() {\r\n locationSelectButton.addEventListener('click', function() {\r\n if (locationSelectTarget) {\r\n if (locationSelectTarget.value) {\r\n locationSelectTarget.value = selectedlocation;\r\n } else {\r\n locationSelectTarget.innerHTML = selectedlocation;\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Public methods\r\n return {\r\n init: function () {\r\n // Elements\r\n\t\t\tmodal = document.querySelector('#kt_modal_select_location');\r\n\r\n\t\t\tif (!modal) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n \r\n locationSelectTarget = document.querySelector('#kt_modal_select_location_target');\r\n locationSelectButton = document.querySelector('#kt_modal_select_location_button');\r\n\r\n handleSelection();\r\n \r\n modal.addEventListener('shown.bs.modal', function () {\r\n if (!mapInitialized) {\r\n initMap();\r\n mapInitialized = true;\r\n } \r\n });\r\n }\r\n }\r\n}();\r\n\r\n// On document ready\r\nKTUtil.onDOMContentLoaded(function() {\r\n KTModalSelectLocation.init();\r\n});\r\n"],"names":[],"sourceRoot":""}