{"version":3,"file":"leaflet-kmz.js","sources":["../src/utils.js","../src/KMZLayer.js","../src/KMZMarker.js","../src/KMZImageOverlay.js"],"sourcesContent":["// import JSZip from 'jszip';\r\n// import * as toGeoJSON from '@tmcw/togeojson';\r\n\r\nexport function loadFile(url) {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tlet xhr = new XMLHttpRequest();\r\n\t\txhr.open('GET', url);\r\n\t\txhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\r\n\t\txhr.responseType = \"arraybuffer\";\r\n\t\txhr.onload = () => {\r\n\t\t\tif (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {\r\n\t\t\t\tresolve(xhr.response || xhr.responseText);\r\n\t\t\t} else {\r\n\t\t\t\tconsole.warn(\"Error \" + xhr.status + \" while fetching remote file: \" + url);\r\n\t\t\t}\r\n\t\t};\r\n\t\txhr.onerror = () => reject(\"Error \" + xhr.status + \" while fetching remote file: \" + url);\r\n\t\txhr.send();\r\n\t});\r\n}\r\n\r\nexport function getKmlDoc(files) {\r\n\treturn files[\"doc.kml\"] ? \"doc.kml\" : getKmlFiles(Object.keys(files))[0];\r\n}\r\n\r\nexport function getKmlFiles(files) {\r\n\treturn files.filter((file) => isKmlFile(file));\r\n}\r\n\r\nexport function getImageFiles(files) {\r\n\treturn files.filter((file) => isImageFile(file));\r\n}\r\n\r\nexport function getFileExt(filename) {\r\n\treturn filename.split('.').pop().toLowerCase().replace('jpg', 'jpeg');\r\n}\r\n\r\nexport function getFileName(url) {\r\n\treturn url.split('/').pop();\r\n}\r\n\r\nexport function getMimeType(filename, ext) {\r\n\tvar mime = 'text/plain';\r\n\tif (/\\.(jpe?g|png|gif|bmp)$/i.test(filename)) {\r\n\t\tmime = 'image/' + ext;\r\n\t} else if (/\\.kml$/i.test(filename)) {\r\n\t\tmime = 'text/plain';\r\n\t}\r\n\treturn mime;\r\n}\r\n\r\nexport function isImageFile(filename) {\r\n\treturn /\\.(jpe?g|png|gif|bmp)$/i.test(filename);\r\n}\r\n\r\nexport function isKmlFile(filename) {\r\n\treturn /.*\\.kml/.test(filename);\r\n}\r\n\r\n/**\r\n * It checks if a given file begins with PK, if so it's zipped\r\n *\r\n * @link https://en.wikipedia.org/wiki/List_of_file_signatures\r\n */\r\nexport function isZipped(file) {\r\n\treturn 'PK' === String.fromCharCode(new Uint8Array(file, 0, 1), new Uint8Array(file, 1, 1));\r\n}\r\n\r\nexport function lazyLoader(urls, promise) {\r\n\treturn promise instanceof Promise ? promise : Promise.all(urls.map(url => loadJS(url)))\r\n}\r\n\r\nexport function loadJS(url) {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tlet tag = document.createElement(\"script\");\r\n\t\ttag.addEventListener('load', resolve.bind(url), { once: true });\r\n\t\ttag.src = url;\r\n\t\tdocument.head.appendChild(tag);\r\n\t});\r\n}\r\n\r\nexport function parseLatLonBox(xml) {\r\n\tlet box = L.latLngBounds([\r\n\t\txml.getElementsByTagName('south')[0].childNodes[0].nodeValue,\r\n\t\txml.getElementsByTagName('west')[0].childNodes[0].nodeValue\r\n\t], [\r\n\t\txml.getElementsByTagName('north')[0].childNodes[0].nodeValue,\r\n\t\txml.getElementsByTagName('east')[0].childNodes[0].nodeValue\r\n\t]);\r\n\tlet rotation = xml.getElementsByTagName('rotation')[0];\r\n\tif (rotation !== undefined) {\r\n\t\trotation = parseFloat(rotation.childNodes[0].nodeValue);\r\n\t}\r\n\treturn [box, rotation];\r\n}\r\n\r\nexport function parseGroundOverlay(xml, props) {\r\n\tlet [bounds, rotation] = parseLatLonBox(xml.getElementsByTagName('LatLonBox')[0]);\r\n\tlet href = xml.getElementsByTagName('href')[0];\r\n\tlet color = xml.getElementsByTagName('color')[0];\r\n\tlet icon = xml.getElementsByTagName('Icon')[0];\r\n\tlet options = {};\r\n\tif (!href && icon) {\r\n\t\thref = icon.getElementsByTagName('href')[0];\r\n\t}\r\n\thref = href.childNodes[0].nodeValue;\r\n\thref = props.icons[href] || href;\r\n\tif (color) {\r\n\t\tcolor = color.childNodes[0].nodeValue;\r\n\t\toptions.opacity = parseInt(color.substring(0, 2), 16) / 255.0;\r\n\t\toptions.color = '#' + color.substring(6, 8) + color.substring(4, 6) + color.substring(2, 4);\r\n\t}\r\n\tif (rotation) {\r\n\t\toptions.rotation = rotation;\r\n\t}\r\n\treturn new L.KMZImageOverlay(href, bounds, { opacity: options.opacity, angle: options.rotation });\r\n}\r\n\r\nexport function toGeoJSON(data, props) {\r\n\tvar xml = data instanceof XMLDocument ? data : toXML(data);\r\n\tvar json = window.toGeoJSON.kml(xml);\r\n\tjson.properties = L.extend({}, json.properties, props || {});\r\n\treturn json;\r\n}\r\n\r\nexport function toXML(data) {\r\n\tvar text = data instanceof ArrayBuffer ? String.fromCharCode.apply(null, new Uint8Array(data)) : data;\r\n\treturn (new DOMParser()).parseFromString(text, 'text/xml');\r\n}\r\n\r\nexport function unzip(folder) {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\twindow.JSZip.loadAsync(folder)\r\n\t\t\t.then((zip) => {\r\n\r\n\t\t\t\t// Parse KMZ files.\r\n\t\t\t\tvar files = Object.keys(zip.files)\r\n\t\t\t\t\t.map((name) => {\r\n\t\t\t\t\t\tvar entry = zip.files[name];\r\n\t\t\t\t\t\tif (isImageFile(name)) {\r\n\t\t\t\t\t\t\tvar ext = getFileExt(name);\r\n\t\t\t\t\t\t\tvar mime = getMimeType(name, ext);\r\n\t\t\t\t\t\t\treturn entry\r\n\t\t\t\t\t\t\t\t.async(\"base64\")\r\n\t\t\t\t\t\t\t\t.then((value) => [name, 'data:' + mime + ';base64,' + value]);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn entry\r\n\t\t\t\t\t\t\t.async(\"text\")\r\n\t\t\t\t\t\t\t.then((value) => [name, value]); // [ fileName, stringValue ]\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t// Return KMZ files.\r\n\t\t\t\tPromise.all(files).then((list) =>\r\n\t\t\t\t\tresolve(list.reduce((obj, item) => {\r\n\t\t\t\t\t\tobj[item[0]] = item[1]; // { fileName: stringValue }\r\n\t\t\t\t\t\treturn obj;\r\n\t\t\t\t\t}, {}))\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t});\r\n}\r\n","import * as _ from './utils';\r\n\r\nexport const KMZLayer = L.KMZLayer = L.FeatureGroup.extend({\r\n\toptions: {\r\n\t\tinteractive: true,\r\n\t\tballon: true,\r\n\t\tbindPopup: true,\r\n\t\tbindTooltip: true,\r\n\t\tpreferCanvas: false,\r\n\t},\r\n\r\n\tinitialize: function(kmzUrl, options) {\r\n\t\tL.extend(this.options, options);\r\n\r\n\t\tif (L.Browser.mobile) this.options.bindTooltip = false;\r\n\r\n\t\tthis._layers = {};\r\n\r\n\t\tif (kmzUrl) this.load(kmzUrl);\r\n\t},\r\n\r\n\tadd: function(kmzUrl) {\r\n\t\tthis.load(kmzUrl);\r\n\t},\r\n\r\n\tload: function(kmzUrl) {\r\n\t\tL.KMZLayer._jsPromise = _.lazyLoader(this._requiredJSModules(), L.KMZLayer._jsPromise)\r\n\t\t\t.then(() => this._load(kmzUrl));\r\n\t},\r\n\r\n\t_load: function(url) {\r\n\t\treturn _.loadFile(url).then((data) => this._parse(data, { name: _.getFileName(url), icons: {} }));\r\n\t},\r\n\r\n\t_parse: function(data, props) {\r\n\t\treturn _.isZipped(data) ? this._parseKMZ(data, props) : this._parseKML(data, props);\r\n\t},\r\n\r\n\t_parseKMZ: function(data, props) {\r\n\t\t_.unzip(data).then((kmzFiles) => {\r\n\t\t\tvar kmlDoc = _.getKmlDoc(kmzFiles);\r\n\t\t\tvar images = _.getImageFiles(Object.keys(kmzFiles));\r\n\r\n\t\t\tvar kmlString = kmzFiles[kmlDoc];\r\n\t\t\t// cache all images with their base64 encoding\r\n\t\t\tprops.icons = images.reduce((obj, item) => {\r\n\t\t\t\tobj[item] = kmzFiles[item];\r\n\t\t\t\treturn obj;\r\n\t\t\t}, {});\r\n\r\n\t\t\tthis._parseKML(kmlString, props);\r\n\t\t});\r\n\t},\r\n\r\n\t_parseKML: function(data, props) {\r\n\t\tvar xml = _.toXML(data, props);\r\n\t\tvar geojson = _.toGeoJSON(xml, props);\r\n\t\tvar layer = (this.options.geometryToLayer || this._geometryToLayer).call(this, geojson, xml);\r\n\t\tthis.addLayer(layer);\r\n\t\tthis.fire('load', { layer: layer, name: geojson.properties.name });\r\n\t},\r\n\r\n\t_geometryToLayer: function(data, xml) {\r\n\t\tvar preferCanvas = this._map ? this._map.options.preferCanvas : this.options.preferCanvas;\r\n\t\t// parse GeoJSON\r\n\t\tvar layer = L.geoJson(data, {\r\n\t\t\tpointToLayer: (feature, latlng) => {\r\n\t\t\t\tif (preferCanvas) {\r\n\t\t\t\t\treturn L.kmzMarker(latlng, {\r\n\t\t\t\t\t\ticonUrl: data.properties.icons[feature.properties.icon] || feature.properties.icon,\r\n\t\t\t\t\t\ticonSize: [28, 28],\r\n\t\t\t\t\t\ticonAnchor: [14, 14],\r\n\t\t\t\t\t\tinteractive: this.options.interactive,\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\t// TODO: handle L.svg renderer within the L.KMZMarker class?\r\n\t\t\t\treturn L.marker(latlng, {\r\n\t\t\t\t\ticon: L.icon({\r\n\t\t\t\t\t\ticonUrl: data.properties.icons[feature.properties.icon] || feature.properties.icon,\r\n\t\t\t\t\t\ticonSize: [28, 28],\r\n\t\t\t\t\t\ticonAnchor: [14, 14],\r\n\t\t\t\t\t}),\r\n\t\t\t\t\tinteractive: this.options.interactive,\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\tstyle: (feature) => {\r\n\t\t\t\tvar styles = {};\r\n\t\t\t\tvar prop = feature.properties;\r\n\r\n\t\t\t\tif (prop.stroke) {\r\n\t\t\t\t\tstyles.stroke = true;\r\n\t\t\t\t\tstyles.color = prop.stroke;\r\n\t\t\t\t}\r\n\t\t\t\tif (prop.fill) {\r\n\t\t\t\t\tstyles.fill = true;\r\n\t\t\t\t\tstyles.fillColor = prop.fill;\r\n\t\t\t\t}\r\n\t\t\t\tif (prop[\"stroke-opacity\"]) {\r\n\t\t\t\t\tstyles.opacity = prop[\"stroke-opacity\"];\r\n\t\t\t\t}\r\n\t\t\t\tif (prop[\"fill-opacity\"]) {\r\n\t\t\t\t\tstyles.fillOpacity = prop[\"fill-opacity\"];\r\n\t\t\t\t}\r\n\t\t\t\tif (prop[\"stroke-width\"]) {\r\n\t\t\t\t\tstyles.weight = prop[\"stroke-width\"] * 1.05;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn styles;\r\n\t\t\t},\r\n\t\t\tonEachFeature: (feature, layer) => {\r\n\t\t\t\tif (!this.options.ballon) return;\r\n\r\n\t\t\t\tvar prop = feature.properties;\r\n\t\t\t\tvar name = prop.name || \"\";\r\n\t\t\t\tvar desc = prop.description || \"\";\r\n\r\n\t\t\t\tif (name || desc) {\r\n\t\t\t\t\tif (this.options.bindPopup) {\r\n\t\t\t\t\t\tlayer.bindPopup('
' + '' + name + '' + '
' + desc + '
');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (this.options.bindTooltip) {\r\n\t\t\t\t\t\tlayer.bindTooltip('' + name + '', {\r\n\t\t\t\t\t\t\tdirection: 'auto',\r\n\t\t\t\t\t\t\tsticky: true,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tinteractive: this.options.interactive,\r\n\t\t});\r\n\t\t// parse GroundOverlays\r\n\t\tlet el = xml.getElementsByTagName('GroundOverlay');\r\n\t\tfor (let l, k = 0; k < el.length; k++) {\r\n\t\t\tl = _.parseGroundOverlay(el[k], data.properties);\r\n\t\t\tif (l) {\r\n\t\t\t\tlayer.addLayer(l);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn layer;\r\n\t},\r\n\r\n\t_requiredJSModules: function() {\r\n\t\tvar urls = [];\r\n\t\tvar host = 'https://unpkg.com/';\r\n\r\n\t\tif (typeof window.JSZip !== 'function') {\r\n\t\t\turls.push(host + 'jszip@3.5.0/dist/jszip.min.js');\r\n\t\t}\r\n\t\tif (typeof window.toGeoJSON !== 'object') {\r\n\t\t\turls.push(host + '@tmcw/togeojson@4.1.0/dist/togeojson.umd.js');\r\n\t\t}\r\n\r\n\t\treturn urls;\r\n\t},\r\n});\r\n\r\nL.kmzLayer = function(url, options) {\r\n\treturn new L.KMZLayer(url, options);\r\n};\r\n","/**\r\n * Optimized leaflet canvas renderer to load numerous markers\r\n *\r\n * @link https://stackoverflow.com/a/51852641\r\n * @link https://stackoverflow.com/a/43019740\r\n *\r\n */\r\nL.KMZMarker = L.CircleMarker.extend({\r\n\t// initialize: function(latlng, options) {\r\n\t// \tL.CircleMarker.prototype.initialize.call(this, latlng, options);\r\n\t// },\r\n\t_updatePath: function() {\r\n\t\tvar renderer = this._renderer;\r\n\t\tvar icon = this._icon;\r\n\t\tvar layer = this;\r\n\r\n\t\tif (!renderer._drawing || layer._empty()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// if (icon.complete)\r\n\t\tif (icon) {\r\n\t\t\ticon.drawImage();\r\n\t\t} else {\r\n\t\t\ticon = this._icon = new Image(this.options.iconSize[0], this.options.iconSize[1]);\r\n\t\t\ticon.anchor = [icon.width / 2.0, icon.height / 2.0];\r\n\t\t\ticon.onload = icon.drawImage = () => {\r\n\t\t\t\tvar p = layer._point.subtract(icon.anchor);\r\n\t\t\t\tvar ctx = renderer._ctx;\r\n\r\n\t\t\t\tctx.drawImage(icon, p.x, p.y, icon.width, icon.height);\r\n\r\n\t\t\t\t// Removed in Leaflet 1.4.0\r\n\t\t\t\t// if (renderer._drawnLayers) renderer._drawnLayers[layer._leaflet_id] = layer;\r\n\t\t\t\t// else renderer._layers[layer._leaflet_id] = layer;\r\n\t\t\t};\r\n\t\t\ticon.src = this.options.iconUrl;\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.kmzMarker = function(ll, opts) {\r\n\treturn new L.KMZMarker(ll, opts);\r\n};\r\n\r\nexport var KMZMarker = L.KMZMarker;\r\n","/**\r\n * Copyright (c) 2011-2015, Pavel Shramov, Bruno Bergot - MIT licence\r\n *\r\n * adapted from: https://github.com/windycom/leaflet-kml/L.KML.js\r\n */\r\nL.KMZImageOverlay = L.ImageOverlay.extend({\r\n\toptions: {\r\n\t\tangle: 0\r\n\t},\r\n\t_reset: function() {\r\n\t\tL.ImageOverlay.prototype._reset.call(this);\r\n\t\tthis._rotate();\r\n\t},\r\n\t_animateZoom: function(e) {\r\n\t\tL.ImageOverlay.prototype._animateZoom.call(this, e);\r\n\t\tthis._rotate();\r\n\t},\r\n\t_rotate: function() {\r\n\t\tif (L.DomUtil.TRANSFORM) {\r\n\t\t\t// use the CSS transform rule if available\r\n\t\t\tthis._image.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)';\r\n\t\t} else if (L.Browser.ie) {\r\n\t\t\t// fallback for IE6, IE7, IE8\r\n\t\t\tvar rad = this.options.angle * (Math.PI / 180),\r\n\t\t\t\tcostheta = Math.cos(rad),\r\n\t\t\t\tsintheta = Math.sin(rad);\r\n\t\t\tthis._image.style.filter += ' progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\\'auto expand\\', M11=' +\r\n\t\t\t\tcostheta + ', M12=' + (-sintheta) + ', M21=' + sintheta + ', M22=' + costheta + ')';\r\n\t\t}\r\n\t},\r\n\tgetBounds: function() {\r\n\t\treturn this._bounds;\r\n\t}\r\n});\r\n"],"names":["getKmlDoc","files","filter","file","test","getKmlFiles","Object","keys","getFileName","url","split","pop","isImageFile","filename","lazyLoader","urls","promise","Promise","all","map","resolve","reject","tag","document","createElement","addEventListener","bind","once","src","head","appendChild","loadJS","parseGroundOverlay","xml","props","bounds","rotation","box","L","latLngBounds","getElementsByTagName","childNodes","nodeValue","undefined","parseFloat","parseLatLonBox","href","color","icon","options","icons","opacity","parseInt","substring","KMZImageOverlay","angle","toXML","data","text","ArrayBuffer","String","fromCharCode","apply","Uint8Array","DOMParser","parseFromString","KMZLayer","FeatureGroup","extend","interactive","ballon","bindPopup","bindTooltip","preferCanvas","initialize","kmzUrl","this","Browser","mobile","_layers","load","add","_jsPromise","_.lazyLoader","_requiredJSModules","then","_load","xhr","XMLHttpRequest","open","setRequestHeader","responseType","onload","readyState","status","console","warn","response","responseText","onerror","send","_.loadFile","_parse","name","_.getFileName","_parseKMZ","_parseKML","folder","window","JSZip","loadAsync","zip","entry","ext","toLowerCase","replace","mime","getMimeType","async","value","list","reduce","obj","item","kmzFiles","kmlDoc","_.getKmlDoc","images","kmlString","_.toXML","geojson","XMLDocument","json","toGeoJSON","kml","properties","_.toGeoJSON","layer","geometryToLayer","_geometryToLayer","call","addLayer","fire","_map","geoJson","pointToLayer","feature","latlng","kmzMarker","iconUrl","iconSize","iconAnchor","marker","style","styles","prop","stroke","fill","fillColor","fillOpacity","weight","onEachFeature","desc","description","direction","sticky","el","l","k","length","_.parseGroundOverlay","host","push","kmzLayer","KMZMarker","CircleMarker","_updatePath","renderer","_renderer","_icon","_drawing","_empty","drawImage","Image","anchor","width","height","p","_point","subtract","_ctx","x","y","ll","opts","ImageOverlay","_reset","prototype","_rotate","_animateZoom","e","DomUtil","TRANSFORM","_image","ie","rad","Math","PI","costheta","cos","sintheta","sin","getBounds","_bounds"],"mappings":"4MAqBO,SAASA,EAAUC,GACzB,OAAOA,EAAM,WAAa,UAGpB,SAAqBA,GAC3B,OAAOA,EAAMC,QAAQC,GA8Bd,UAAUC,KA9BuBD,KAJFE,CAAYC,OAAOC,KAAKN,IAAQ,GAehE,SAASO,EAAYC,GAC3B,OAAOA,EAAIC,MAAM,KAAKC,MAahB,SAASC,EAAYC,GAC3B,MAAO,0BAA0BT,KAAKS,GAgBhC,SAASC,EAAWC,EAAMC,GAChC,OAAOA,aAAmBC,QAAUD,EAAUC,QAAQC,IAAIH,EAAKI,KAAIV,GAG7D,SAAgBA,GACtB,OAAO,IAAIQ,SAAQ,CAACG,EAASC,KAC5B,IAAIC,EAAMC,SAASC,c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