{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./inst/htmlwidgets/bindings/lfx-heat-bindings.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","object","property","prototype","hasOwnProperty","p","s","getHeatmapIntensity","feature","intensityProperty","intensity","properties","addGenericGeoJSONHeatmap","widget","geojson","layerId","group","options","heatmapCoords","getHeatmapCoords","latlngs","JSON","parse","type","topoJsonFeatures","key","objects","topoToGeo","topojson","L","Util","isArray","concat","features","push","$","each","index","lat","lng","geometry","parseFloat","coordinates","coordinate","isEmptyObject","heatmapLayer","heatLayer","layerManager","addLayer","LeafletWidget","methods","addHeatmap","points","this","addGeoJSONHeatmap","self","utils","isURL","getJSON","geojsondata","addKMLHeatmap","kml","data","toGeoJSON","parseXML","addCSVHeatmap","csv","parserOptions","csv2geojson","err","addGPXHeatmap","gpx","removeHeatmap","removeLayer","clearHeatmap","clearLayers"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,OAAA,KAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,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AAAe,cAAA,SAAAC,EAAAzD,EAAAM,EAAAC,EAAAC,EAAAkD,GACA,IAAAZ,EAAAF,KACAJ,cAAAO,MAAAC,MAAAS,GACA/B,EAAAuB,QAAAQ,EAAA,SAAAJ,GACAM,wBACAN,EAAAK,MACA,SAAAE,EAAAV,GACA/C,EAAA2C,EACAI,EAAAlD,EAAAM,EAAAC,EAAAC,OAKAmD,wBACAF,EAAAC,MACA,SAAAE,EAAAV,GACA/C,EAAA2C,EACAI,EAAAlD,EAAAM,EAAAC,EAAAC,MAMAgC,cAAAC,QAAAoB,cAAA,SAAAC,EAAA9D,EAAAM,EAAAC,EAAAC,GACA,IAAAsC,EAAAF,KACA,GAAAJ,cAAAO,MAAAC,MAAAc,GACApC,EAAAuB,QAAAa,EAAA,SAAAT,GACA,IAAAH,EAAAI,UAAAQ,IACAtB,cAAAO,MAAAQ,SAAAF,IACAlD,EAAA2C,EACAI,EAAAlD,EAAAM,EAAAC,EAAAC,SAEG,CACH,IAAA0C,EAAAI,UAAAQ,IACAtB,cAAAO,MAAAQ,SAAAO,IACA3D,EAAA2C,EACAI,EAAAlD,EAAAM,EAAAC,EAAAC,KAIAgC,cAAAC,QAAAsB,cAAA,SAAAzD,GACAsC,KAAAN,aAAA0B,YAAA,UAAA1D,IAGAkC,cAAAC,QAAAwB,aAAA,WACArB,KAAAN,aAAA4B,YAAA","file":"lfx-heat-bindings.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/* global LeafletWidget, $, L, topojson, csv2geojson, toGeoJSON */\nLeafletWidget.methods.addHeatmap = function(points, layerId, group, options) {\n\n if(!$.isEmptyObject(points)) {\n var heatmapLayer = L.heatLayer(points, options);\n this.layerManager.addLayer(heatmapLayer, 'heatmap', layerId, group);\n }\n};\n\nfunction getHeatmapIntensity(feature, intensityProperty) {\n var intensity = null;\n if(feature) {\n if(typeof intensityProperty === 'string') {\n intensity = feature.properties[intensityProperty];\n } else if(typeof intensityProperty === 'function') {\n intensity = intensityProperty(feature);\n }\n }\n return intensity;\n}\n\nfunction getHeatmapCoords(geojson, intensityProperty) {\n\n var latlngs = [];\n if(typeof geojson === 'undefined' || geojson === null) {\n return latlngs;\n }\n\n if(typeof geojson === 'string') {\n geojson = JSON.parse(geojson);\n }\n\n // if input is a TopoJSON\n // iterate over each of its objects and add their coords\n if (geojson.type === 'Topology') {\n var topoJsonFeatures = [];\n for (var key in geojson.objects) {\n var topoToGeo = topojson.feature(geojson, geojson.objects[key]);\n if(L.Util.isArray(topoToGeo)) {\n topoJsonFeatures = topoJsonFeatures.concat(topoToGeo);\n } else if('features' in topoToGeo ) {\n topoJsonFeatures = topoJsonFeatures.concat(topoToGeo.features);\n } else {\n topoJsonFeatures.push(topoToGeo);\n }\n }\n return getHeatmapCoords(topoJsonFeatures, intensityProperty);\n }\n\n var features = L.Util.isArray(geojson) ? geojson : geojson.features;\n\n if(features) { // either a FeatureCollection or an Array of Features\n $.each(features, function(index, feature) {\n\n var lat = null, lng = null;\n\n // We're only interested in Points and Multipoints\n // every other geometry is a shape\n if(feature.geometry.type === 'Point') {\n lat = parseFloat(feature.geometry.coordinates[1]);\n lng = parseFloat(feature.geometry.coordinates[0]);\n\n if(lat && lng) {\n if(intensityProperty) {\n latlngs.push([lat, lng,\n getHeatmapIntensity(feature, intensityProperty)]);\n } else {\n latlngs.push([lat, lng]);\n }\n }\n } else if(feature.geometry.type === 'MultiPoint') {\n latlngs = latlngs.concat(\n getHeatmapCoords(feature, intensityProperty));\n }\n });\n } else if(geojson.type === 'Feature') { // Single GeoJSON Feature with MultiPoint dataset\n $.each(geojson.geometry.coordinates, function(index, coordinate){\n var lat = null, lng = null;\n lat = parseFloat(coordinate[1]);\n lng = parseFloat(coordinate[0]);\n if(lat && lng) {\n if(intensityProperty) {\n latlngs.push([lat, lng,\n getHeatmapIntensity(geojson, intensityProperty)]);\n } else {\n latlngs.push([lat, lng]);\n }\n }\n });\n }\n\n return latlngs;\n}\n\nfunction addGenericGeoJSONHeatmap( widget, geojson, intensityProperty, layerId, group, options) {\n var heatmapCoords = getHeatmapCoords(geojson, intensityProperty);\n\n if(!$.isEmptyObject(heatmapCoords)) {\n var heatmapLayer = L.heatLayer(heatmapCoords, options);\n widget.layerManager.addLayer(\n heatmapLayer, 'heatmap', layerId, group);\n }\n}\n\nLeafletWidget.methods.addGeoJSONHeatmap = function(geojson, intensityProperty, layerId, group, options) {\n var self = this;\n if(LeafletWidget.utils.isURL(geojson)) {\n $.getJSON(geojson, function(geojsondata){\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n });\n } else {\n addGenericGeoJSONHeatmap(self,\n geojson, intensityProperty, layerId, group, options);\n }\n};\n\nLeafletWidget.methods.addKMLHeatmap = function(kml, intensityProperty, layerId, group, options) {\n var self = this;\n if(LeafletWidget.utils.isURL(kml)) {\n $.getJSON(kml, function(data){\n var geojsondata = toGeoJSON.kml(\n LeafletWidget.utils.parseXML(data));\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n });\n } else {\n var geojsondata = toGeoJSON.kml(\n LeafletWidget.utils.parseXML(kml));\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n }\n};\n\nLeafletWidget.methods.addCSVHeatmap = function(csv, intensityProperty, layerId, group, options, parserOptions) {\n var self = this;\n if(LeafletWidget.utils.isURL(csv)) {\n $.getJSON(csv, function(data){\n csv2geojson.csv2geojson(\n data, parserOptions || {},\n function(err, geojsondata) {\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n }\n );\n });\n } else {\n csv2geojson.csv2geojson(\n csv, parserOptions || {},\n function(err, geojsondata) {\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n }\n );\n }\n};\n\nLeafletWidget.methods.addGPXHeatmap = function(gpx, intensityProperty, layerId, group, options) {\n var self = this;\n if(LeafletWidget.utils.isURL(gpx)) {\n $.getJSON(gpx, function(data){\n var geojsondata = toGeoJSON.gpx(\n LeafletWidget.utils.parseXML(data));\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n });\n } else {\n var geojsondata = toGeoJSON.gpx(\n LeafletWidget.utils.parseXML(gpx));\n addGenericGeoJSONHeatmap(self,\n geojsondata, intensityProperty, layerId, group, options);\n }\n};\n\nLeafletWidget.methods.removeHeatmap = function(layerId) {\n this.layerManager.removeLayer('heatmap', layerId);\n};\n\nLeafletWidget.methods.clearHeatmap = function() {\n this.layerManager.clearLayers('heatmap');\n};\n"],"sourceRoot":""}