Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightning-maps

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightning-maps - npm Package Compare versions

Comparing version 0.0.1 to 0.0.4

2

docs/LightningMaps.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("LightningMaps",[],e):"object"==typeof exports?exports.LightningMaps=e():t.LightningMaps=e()}(window,function(){return function(t){var e={};function o(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)o.d(i,s,function(e){return t[e]}.bind(null,s));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2)}([function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,null,[{key:"lon2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(t+180)/360*Math.pow(2,e);return o?Math.floor(i):i}},{key:"lat2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(1-Math.log(Math.tan(t*Math.PI/180)+1/Math.cos(t*Math.PI/180))/Math.PI)/2*Math.pow(2,e);return o?Math.floor(i):i}},{key:"tile2lon",value:function(t,e){return t/Math.pow(2,e)*360-180}},{key:"tile2lat",value:function(t,e){var o=Math.PI-2*Math.PI*t/Math.pow(2,e);return 180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))}},{key:"tile2boundingBox",value:function(e,o,i){return{ne:[t.tile2lat(o,i),t.tile2lon(e+1,i)],sw:[t.tile2lat(o+1,i),t.tile2lon(e,i)]}}},{key:"pixelToLatLon",value:function(e,o,i,s){var a=[e[0]/s,e[1]/s],n=t.lon2tile(o[1],i,!1)-a[0],r=t.lat2tile(o[0],i,!1)-a[1];return[t.tile2lat(r,i),t.tile2lon(n,i)]}},{key:"latLonToPixel",value:function(e,o,i,s,a){var n=t.lon2tile(e[1],i,!1),r=t.lat2tile(e[0],i,!1);return[-(n-t.lon2tile(o[1],i,!1))*s,-(r-t.lat2tile(o[0],i,!1))*s]}}]),t}();e.default=s,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMarkerOptions=e.defaultMapOptions=void 0;e.defaultMapOptions={source:function(t,e,o){return"https://maps.geocod.io/tiles/base/".concat(o,"/").concat(t,"/").concat(e,".png")},zoom:12,center:[38.841779,-77.088312],tileSize:256,panAccelerationMultiplier:2,maxPanAcceleration:3.5,throwTimingThresholdMs:100,throwVelocityThreshold:3e3,animationDurationMs:300,debounceIntervalMs:200,tileAreaMultiplier:2,debug:!1};e.defaultMarkerOptions={color:"rgba(0, 0, 200, 0.7)",type:"marker"}},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(3)),s=a(o(6));function a(t){return t&&t.__esModule?t:{default:t}}var n={Map:i.default,Marker:s.default};e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=n(o(0)),s=n(o(4)),a=o(1);function n(t){return t&&t.__esModule?t:{default:t}}function r(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(e,o){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!e.getContext)throw new Error("Could not get canvas context");this.canvas=e,this.context=this.canvas.getContext("2d"),this.options=Object.assign({},a.defaultMapOptions,o),this.initializeState(),this.attachEvents(),this.applyStyles(),this.lastDrawState=null,this.draw=this.draw.bind(this),window.requestAnimationFrame(this.draw)}return function(t,e,o){e&&r(t.prototype,e),o&&r(t,o)}(t,[{key:"initializeState",value:function(){this.state={canvasDimensions:[this.canvas.width,this.canvas.height],tiles:{},moveOffset:[0,0],targetMoveOffset:[0,0],targetMoveOffsetIsCoord:!1,moveAnimationStart:null,dragStartPosition:null,lastEventActionTime:null,startZoom:this.options.zoom,targetZoom:this.options.zoom,zoomAnimationStart:null,scale:1,lastMouseMoveEvent:null,mouseVelocities:[],markers:[],tileLayers:[new s.default(this)]}}},{key:"getZoom",value:function(){return this.options.zoom}},{key:"setZoom",value:function(t){this.zoomValueIsValid(t)&&(this.state.tileLayers.push(new s.default(this,t)),this.state.lastEventActionTime=window.performance.now(),this.state.zoomAnimationStart=window.performance.now(),this.state.targetZoom=t,this.state.startZoom=this.options.zoom)}},{key:"setCenter",value:function(t){if(!Array.isArray(t)||2!==t.length)throw new Error("Please provide a valid array with a lat/lon");t=t.map(function(t){return parseFloat(t)}),this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=t,this.state.targetMoveOffsetIsCoord=!0}},{key:"setTargetMoveOffset",value:function(t,e){!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?(this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=i.default.pixelToLatLon([t,e],this.options.center,this.options.zoom,this.options.tileSize),this.state.targetMoveOffsetIsCoord=!0):(this.state.targetMoveOffset=[t,e],this.state.targetMoveOffsetIsCoord=!1,this.state.moveOffset=this.state.targetMoveOffset)}},{key:"zoomValueIsValid",value:function(t){return t>=1&&t<=18}},{key:"isReadyForEvent",value:function(){return!this.state.lastEventActionTime||window.performance.now()-this.state.lastEventActionTime>this.options.debounceIntervalMs}},{key:"calculateVelocity",value:function(t,e,o,i){return(t-e)/(o-i)*1e3}},{key:"attachEvents",value:function(){var t=this;this.canvas.addEventListener("wheel",function(e){e.preventDefault(),t.isReadyForEvent()&&(e.deltaY>5?t.setZoom(t.options.zoom-1):e.deltaY<-5&&t.setZoom(t.options.zoom+1))}),this.canvas.addEventListener("dblclick",function(e){e.preventDefault();var o=t.state.canvasDimensions[0]/2,i=t.state.canvasDimensions[1]/2;t.setTargetMoveOffset(-(e.clientX-o),-(e.clientY-i)),t.setZoom(t.options.zoom+1)}),this.canvas.addEventListener("mousedown",function(e){e.preventDefault(),t.state.mouseVelocities=[],t.state.dragStartPosition=[e.clientX-t.state.moveOffset[0],e.clientY-t.state.moveOffset[1]]}),this.canvas.addEventListener("mouseup",function(e){e.preventDefault();var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY);if(0!==t.state.moveOffset[0]||0!==t.state.moveOffset[1]){var s=window.performance.now()-t.options.throwTimingThresholdMs,a=t.state.mouseVelocities.filter(function(t){return t[0]>s}).map(function(t){return t[1]}),n=a.reduce(function(t,e){return t+e},0)/a.length;if(n>=t.options.throwVelocityThreshold){var r=n/t.options.throwVelocityThreshold*t.options.panAccelerationMultiplier;r=Math.min(r,t.options.maxPanAcceleration),t.setTargetMoveOffset(o*r,i*r)}else t.updateCenter()}t.state.dragStartPosition=null}),this.canvas.addEventListener("mousemove",function(e){if(e.preventDefault(),t.state.dragStartPosition){var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY),s=window.performance.now(),a=t.calculateVelocity(t.state.moveOffset[0],o,s,t.state.lastMouseMoveEvent),n=t.calculateVelocity(t.state.moveOffset[1],i,s,t.state.lastMouseMoveEvent),r=Math.round(Math.sqrt(a*a+n*n));t.state.mouseVelocities.push([s,r]),t.setTargetMoveOffset(o,i,!1),t.state.lastMouseMoveEvent=window.performance.now()}return!1})}},{key:"applyStyles",value:function(){this.canvas.style.cursor="grab"}},{key:"easeOutQuad",value:function(t){return t*(2-t)}},{key:"updateMoveOffset",value:function(){if(this.state.moveOffset!==this.state.targetMoveOffset){var t=window.performance.now(),e=Math.max(t-this.state.moveAnimationStart,0),o=this.easeOutQuad(e/this.options.animationDurationMs),s=this.state.targetMoveOffset;this.state.targetMoveOffsetIsCoord&&(s=i.default.latLonToPixel(this.state.targetMoveOffset,this.options.center,this.options.zoom,this.options.tileSize,this.state.canvasDimensions)),this.state.moveOffset=o>=.99?s:[this.state.moveOffset[0]+(s[0]-this.state.moveOffset[0])*o,this.state.moveOffset[1]+(s[1]-this.state.moveOffset[1])*o],this.state.moveOffset===s&&this.updateCenter()}}},{key:"updateCenter",value:function(){var t=i.default.pixelToLatLon(this.state.moveOffset,this.options.center,this.options.zoom,this.options.tileSize);this.setTargetMoveOffset(0,0,!1),this.options.center=t}},{key:"updateZoom",value:function(){if(this.options.zoom!==this.state.targetZoom){var t=Math.max(window.performance.now()-this.state.zoomAnimationStart,0),e=this.easeOutQuad(t/this.options.animationDurationMs),o=Math.abs(this.state.targetZoom-this.state.startZoom);this.state.targetZoom<=this.state.startZoom&&(o*=-1);var i=o*e,s=this.options.animationDurationMs-t;this.options.zoom=s<=5?this.state.targetZoom:this.state.startZoom+i;var a=Math.round(this.options.zoom),n=this.options.zoom-a;this.state.scale=Math.pow(2,n),this.options.zoom===this.state.targetZoom&&(this.state.tileLayers.shift(),this.state.tileLayers[0].tilesZoomLevel=null)}else this.state.scale=1}},{key:"garbageCollect",value:function(){var t=this,e=Object.values(this.state.tiles);if(e.length>this.maxTilesToKeep()){var o=(new Date).getTime()-5e3,i=e.filter(function(t){return t.lastRequested<o}).sort(function(t,e){return~~(t.lastRequested<e.lastRequested)}),s=this.maxTilesToKeep()-(e.length-i.length);i.splice(i.length-s).forEach(function(e){e.src="",delete t.state.tiles[e.tileId]})}}},{key:"maxTilesToKeep",value:function(){return 1e3}},{key:"shouldRedraw",value:function(){var t=JSON.stringify([this.state,this.options]);return this.lastDrawState!==t&&(this.lastDrawState=t,!0)}},{key:"draw",value:function(){this.updateMoveOffset(),this.updateZoom(),this.state.tileLayers.forEach(function(t){return t.calculateGrid()}),this.garbageCollect(),this.shouldRedraw()&&(this.state.tileLayers.length>0&&this.state.tileLayers[0].drawTiles(this.state.scale),this.drawMarkers()),window.requestAnimationFrame(this.draw)}},{key:"getMapBounds",value:function(){return{nw:i.default.pixelToLatLon([this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize),se:i.default.pixelToLatLon([-this.state.canvasDimensions[0]/2,-this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize)}}},{key:"drawMarkers",value:function(){var t=this,e=this.getMapBounds(),o=this.state.markers.filter(function(t){return t.coords[0]<=e.nw[0]&&t.coords[0]>=e.se[0]&&t.coords[1]>=e.nw[1]&&t.coords[1]<=e.se[1]}),s=[this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2];o.map(function(e){var o=i.default.latLonToPixel(e.coords,t.options.center,t.options.zoom,t.options.tileSize,t.state.canvasDimensions);e.render(t.context,[s[0]-o[0]+t.state.moveOffset[0],s[1]-o[1]+t.state.moveOffset[1]])})}},{key:"addMarker",value:function(t){this.state.markers.push(t)}}]),t}();e.default=l,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(0)),s=a(o(5));function a(t){return t&&t.__esModule?t:{default:t}}function n(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var r=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.map=e,this.tilesZoomLevel=o,this.shouldBeDeleted=!1,this.context=e.context,this.state={grid:[],gridHash:null,relativeTileOffset:[0,0]}}return function(t,e,o){e&&n(t.prototype,e),o&&n(t,o)}(t,[{key:"toJSON",value:function(){return[this.state,this.loadedPercentage()]}},{key:"getTilesCount",value:function(t){var e=Math.ceil(t/this.map.options.tileSize)*this.map.options.tileAreaMultiplier;return e%2==0&&e++,e}},{key:"calculateGrid",value:function(){var t=this.map,e=t.state,o=t.options,a=i.default.lat2tile(o.center[0],Math.round(this.tilesZoomLevel||o.zoom),!1),n=i.default.lon2tile(o.center[1],Math.round(this.tilesZoomLevel||o.zoom),!1),r=[a,n].join(",");if(this.state.gridHash!==r){var l=this.getTilesCount(e.canvasDimensions[0]),u=this.getTilesCount(e.canvasDimensions[1]),f=Math.floor(a),c=Math.floor(n);this.state.relativeTileOffset=[Math.abs(n-c),Math.abs(a-f)];for(var h=c-Math.floor(l/2),d=f-Math.floor(u/2),v=[],p=0;p<u;p++)for(var m=0;m<l;m++){v[m]||(v[m]=[]);var y=h+m,g=d+p;y>=0&&g>=0&&(v[m][p]=new s.default(y,g,Math.round(this.tilesZoomLevel||o.zoom)),this.ensureTileAsset(v[m][p]))}this.state.grid=v,this.state.gridHash=r}}},{key:"ensureTileAsset",value:function(t){var e=this;if(!(t.id in this.map.state.tiles)){var o=this.map.options.source(Math.floor(t.x),Math.floor(t.y),t.zoom);this.map.state.tiles[t.id]=new Image,this.map.state.tiles[t.id].tileId=t.id,this.map.state.tiles[t.id].src=o,this.map.state.tiles[t.id].loaded=!1,this.map.state.tiles[t.id].onload=function(){e.map.state.tiles[t.id].loaded=!0}}this.map.state.tiles[t.id].lastRequested=(new Date).getTime()}},{key:"drawTiles",value:function(t){var e=this.map.state.canvasDimensions[0],o=this.map.state.canvasDimensions[1],i=this.map.options.tileSize*t,s=[i/2-this.state.relativeTileOffset[0]*i,i/2-this.state.relativeTileOffset[1]*i];this.context.fillStyle="#EEE",this.context.fillRect(0,0,e,o);for(var a=this.getTilesCount(e),n=this.getTilesCount(o),r=a*i-e,l=n*i-o,u=0;u<n;u++)for(var f=0;f<a;f++){var c=this.state.grid[f][u];if(c){var h=this.map.state.moveOffset[0]+s[0]+(f*i-r/2),d=this.map.state.moveOffset[1]+s[1]+(u*i-l/2);try{this.map.state.tiles[c.id].loaded?this.context.drawImage(this.map.state.tiles[c.id],h,d,i,i):this.drawGenericBackground(h,d,i)}catch(t){this.drawGenericBackground(h,d,i)}this.map.options.debug&&(this.context.strokeStyle="green",this.context.strokeRect(h,d,i,i))}}this.map.options.debug&&(this.context.fillStyle="rgba(200, 0, 0, 0.7)",this.context.beginPath(),this.context.arc(e/2,o/2,5,0,2*Math.PI),this.context.fill())}},{key:"drawGenericBackground",value:function(t,e,o){var i=o/8;this.context.beginPath();for(var s=i;s<o;s+=i)for(var a=i;a<o;a+=i)this.context.moveTo(t,e+a),this.context.lineTo(t+o,e+a),this.context.moveTo(t+s,e),this.context.lineTo(t+s,e+o);this.context.strokeStyle="#DDD",this.context.stroke(),this.context.strokeStyle="#CCC",this.context.strokeRect(t,e,o,o)}},{key:"loadedPercentage",value:function(){for(var t=this.getTilesCount(this.map.state.canvasDimensions[0]),e=this.getTilesCount(this.map.state.canvasDimensions[1]),o=t*e,i=0,s=0;s<e;s++)for(var a=0;a<t;a++){var n=this.state.grid[a][s];this.map.state.tiles[n.id].loaded&&i++}return i/o}}]),t}();e.default=r,t.exports=e.default},function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=function(){function t(e,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._x=e,this._y=o,this._zoom=i}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,[{key:"x",get:function(){return this._x}},{key:"y",get:function(){return this._y}},{key:"zoom",get:function(){return this._zoom}},{key:"id",get:function(){return[this.x,this.y,this.zoom].join("|")}}]),t}();e.default=s,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(1);function s(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var a=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._coords=e,this._options=Object.assign({},i.defaultMarkerOptions,o)}return function(t,e,o){e&&s(t.prototype,e),o&&s(t,o)}(t,[{key:"render",value:function(t,e){var o=null;switch(this.options.type){case"marker":o=this.renderMarker;break;case"circle":o=this.renderCircle;break;case"donut":o=this.renderDonut}if(!o)throw new Error('Unsupported marker type: "'.concat(this.options.type,'"'));t.fillStyle=this.options.color,t.strokeStyle=this.options.color,(o=o.bind(this))(t,e)}},{key:"renderCircle",value:function(t,e){t.save(),t.beginPath(),t.arc(e[0],e[1],5,0,2*Math.PI),t.fill(),t.restore()}},{key:"renderDonut",value:function(t,e){t.save(),t.beginPath(),t.lineWidth=5,t.arc(e[0],e[1],7,0,2*Math.PI),t.stroke(),t.restore()}},{key:"renderMarker",value:function(t,e){var o=e[0]-8.8490345,i=e[1]-24.786272;t.save(),t.transform(.184386,0,0,.184386,.551658+o,4.09576+i),t.beginPath(),t.lineWidth=1.667195,t.moveTo(45,-22.212949),t.bezierCurveTo(18.494941,-22.212949,-2.991863,-.726145,-2.991863,25.778914),t.bezierCurveTo(-2.991863,52.282306,45,112.21295,45,112.21295),t.bezierCurveTo(45,112.21295,92.991863,52.282306,92.991863,25.777247),t.bezierCurveTo(92.991863,-.726145,71.505059,-22.212949,45,-22.212949),t.moveTo(45,43.827962),t.bezierCurveTo(33.553042,43.827962,24.273437,34.550024,24.273437,23.103067),t.bezierCurveTo(24.273437,11.656109,33.553042,2.376504,45,2.376504),t.bezierCurveTo(56.446958,2.376504,65.726563,11.654442,65.726563,23.101399),t.bezierCurveTo(65.726563,34.548357,56.446958,43.827962,45,43.827962),t.fill(),t.restore()}},{key:"coords",get:function(){return this._coords}},{key:"options",get:function(){return this._options}}]),t}();e.default=a,t.exports=e.default}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("LightningMaps",[],e):"object"==typeof exports?exports.LightningMaps=e():t.LightningMaps=e()}(window,function(){return function(t){var e={};function o(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(i,n,function(e){return t[e]}.bind(null,n));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2)}([function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,null,[{key:"lon2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(t+180)/360*Math.pow(2,e);return o?Math.floor(i):i}},{key:"lat2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(1-Math.log(Math.tan(t*Math.PI/180)+1/Math.cos(t*Math.PI/180))/Math.PI)/2*Math.pow(2,e);return o?Math.floor(i):i}},{key:"tile2lon",value:function(t,e){return t/Math.pow(2,e)*360-180}},{key:"tile2lat",value:function(t,e){var o=Math.PI-2*Math.PI*t/Math.pow(2,e);return 180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))}},{key:"tile2boundingBox",value:function(e,o,i){return{ne:[t.tile2lat(o,i),t.tile2lon(e+1,i)],sw:[t.tile2lat(o+1,i),t.tile2lon(e,i)]}}},{key:"pixelToLatLon",value:function(e,o,i,n){var s=[e[0]/n,e[1]/n],a=t.lon2tile(o[1],i,!1)-s[0],r=t.lat2tile(o[0],i,!1)-s[1];return[t.tile2lat(r,i),t.tile2lon(a,i)]}},{key:"latLonToPixel",value:function(e,o,i,n,s){var a=t.lon2tile(e[1],i,!1),r=t.lat2tile(e[0],i,!1);return[-(a-t.lon2tile(o[1],i,!1))*n,-(r-t.lat2tile(o[0],i,!1))*n]}}]),t}();e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMarkerOptions=e.defaultMapOptions=void 0;e.defaultMapOptions={source:function(t,e,o){return"https://maps.geocod.io/tiles/base/".concat(o,"/").concat(t,"/").concat(e,".png")},zoom:12,center:[38.841779,-77.088312],attribution:"© OpenStreetMap contributors",tileSize:256,panAccelerationMultiplier:2,maxPanAcceleration:3.5,throwTimingThresholdMs:100,throwVelocityThreshold:3e3,animationDurationMs:300,debounceIntervalMs:200,tileAreaMultiplier:2,debug:!1};e.defaultMarkerOptions={color:"rgba(0, 0, 200, 0.7)",type:"marker"}},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=s(o(3)),n=s(o(6));function s(t){return t&&t.__esModule?t:{default:t}}var a={Map:i.default,Marker:n.default};e.default=a,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(0)),n=a(o(4)),s=o(1);function a(t){return t&&t.__esModule?t:{default:t}}function r(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(e,o){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!e.getContext)throw new Error("Could not get canvas context");this.canvas=e,this.context=this.canvas.getContext("2d"),this.options=Object.assign({},s.defaultMapOptions,o),this.initializeState(),this.attachEvents(),this.applyStyles(),this.lastDrawState=null,this.draw=this.draw.bind(this),window.requestAnimationFrame(this.draw)}return function(t,e,o){e&&r(t.prototype,e),o&&r(t,o)}(t,[{key:"initializeState",value:function(){this.state={canvasDimensions:[this.canvas.width,this.canvas.height],tiles:{},moveOffset:[0,0],targetMoveOffset:[0,0],targetMoveOffsetIsCoord:!1,moveAnimationStart:null,dragStartPosition:null,lastEventActionTime:null,startZoom:this.options.zoom,targetZoom:this.options.zoom,zoomAnimationStart:null,scale:1,lastMouseMoveEvent:null,mouseVelocities:[],markers:[],tileLayers:[new n.default(this)]}}},{key:"getZoom",value:function(){return this.options.zoom}},{key:"setZoom",value:function(t){this.zoomValueIsValid(t)&&(this.state.tileLayers.push(new n.default(this,t)),this.state.lastEventActionTime=window.performance.now(),this.state.zoomAnimationStart=window.performance.now(),this.state.targetZoom=t,this.state.startZoom=this.options.zoom)}},{key:"setCenter",value:function(t){if(!Array.isArray(t)||2!==t.length)throw new Error("Please provide a valid array with a lat/lon");t=t.map(function(t){return parseFloat(t)}),this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=t,this.state.targetMoveOffsetIsCoord=!0}},{key:"setTargetMoveOffset",value:function(t,e){!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?(this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=i.default.pixelToLatLon([t,e],this.options.center,this.options.zoom,this.options.tileSize),this.state.targetMoveOffsetIsCoord=!0):(this.state.targetMoveOffset=[t,e],this.state.targetMoveOffsetIsCoord=!1,this.state.moveOffset=this.state.targetMoveOffset)}},{key:"zoomValueIsValid",value:function(t){return t>=1&&t<=18}},{key:"isReadyForEvent",value:function(){return!this.state.lastEventActionTime||window.performance.now()-this.state.lastEventActionTime>this.options.debounceIntervalMs}},{key:"calculateVelocity",value:function(t,e,o,i){return(t-e)/(o-i)*1e3}},{key:"attachEvents",value:function(){var t=this;this.canvas.addEventListener("wheel",function(e){e.preventDefault(),t.isReadyForEvent()&&(e.deltaY>5?t.setZoom(t.options.zoom-1):e.deltaY<-5&&t.setZoom(t.options.zoom+1))}),this.canvas.addEventListener("dblclick",function(e){e.preventDefault();var o=t.state.canvasDimensions[0]/2,i=t.state.canvasDimensions[1]/2;t.setTargetMoveOffset(-(e.clientX-o),-(e.clientY-i)),t.setZoom(t.options.zoom+1)}),this.canvas.addEventListener("mousedown",function(e){e.preventDefault(),t.state.mouseVelocities=[],t.state.dragStartPosition=[e.clientX-t.state.moveOffset[0],e.clientY-t.state.moveOffset[1]]}),this.canvas.addEventListener("mouseup",function(e){e.preventDefault();var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY);if(0!==t.state.moveOffset[0]||0!==t.state.moveOffset[1]){var n=window.performance.now()-t.options.throwTimingThresholdMs,s=t.state.mouseVelocities.filter(function(t){return t[0]>n}).map(function(t){return t[1]}),a=s.reduce(function(t,e){return t+e},0)/s.length;if(a>=t.options.throwVelocityThreshold){var r=a/t.options.throwVelocityThreshold*t.options.panAccelerationMultiplier;r=Math.min(r,t.options.maxPanAcceleration),t.setTargetMoveOffset(o*r,i*r)}else t.updateCenter()}t.state.dragStartPosition=null}),this.canvas.addEventListener("mousemove",function(e){if(e.preventDefault(),t.state.dragStartPosition){var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY),n=window.performance.now(),s=t.calculateVelocity(t.state.moveOffset[0],o,n,t.state.lastMouseMoveEvent),a=t.calculateVelocity(t.state.moveOffset[1],i,n,t.state.lastMouseMoveEvent),r=Math.round(Math.sqrt(s*s+a*a));t.state.mouseVelocities.push([n,r]),t.setTargetMoveOffset(o,i,!1),t.state.lastMouseMoveEvent=window.performance.now()}return!1})}},{key:"applyStyles",value:function(){this.canvas.style.cursor="grab"}},{key:"easeOutQuad",value:function(t){return t*(2-t)}},{key:"updateMoveOffset",value:function(){if(this.state.moveOffset!==this.state.targetMoveOffset){var t=window.performance.now(),e=Math.max(t-this.state.moveAnimationStart,0),o=this.easeOutQuad(e/this.options.animationDurationMs),n=this.state.targetMoveOffset;this.state.targetMoveOffsetIsCoord&&(n=i.default.latLonToPixel(this.state.targetMoveOffset,this.options.center,this.options.zoom,this.options.tileSize,this.state.canvasDimensions)),this.state.moveOffset=o>=.99?n:[this.state.moveOffset[0]+(n[0]-this.state.moveOffset[0])*o,this.state.moveOffset[1]+(n[1]-this.state.moveOffset[1])*o],this.state.moveOffset===n&&this.updateCenter()}}},{key:"updateCenter",value:function(){var t=i.default.pixelToLatLon(this.state.moveOffset,this.options.center,this.options.zoom,this.options.tileSize);this.setTargetMoveOffset(0,0,!1),this.options.center=t}},{key:"updateZoom",value:function(){if(this.options.zoom!==this.state.targetZoom){var t=Math.max(window.performance.now()-this.state.zoomAnimationStart,0),e=this.easeOutQuad(t/this.options.animationDurationMs),o=Math.abs(this.state.targetZoom-this.state.startZoom);this.state.targetZoom<=this.state.startZoom&&(o*=-1);var i=o*e,n=this.options.animationDurationMs-t;this.options.zoom=n<=5?this.state.targetZoom:this.state.startZoom+i;var s=Math.round(this.options.zoom),a=this.options.zoom-s;this.state.scale=Math.pow(2,a),this.options.zoom===this.state.targetZoom&&(this.state.tileLayers.shift(),this.state.tileLayers[0].tilesZoomLevel=null)}else this.state.scale=1}},{key:"garbageCollect",value:function(){var t=this,e=Object.values(this.state.tiles);if(e.length>this.maxTilesToKeep()){var o=(new Date).getTime()-5e3,i=e.filter(function(t){return t.lastRequested<o}).sort(function(t,e){return~~(t.lastRequested<e.lastRequested)}),n=this.maxTilesToKeep()-(e.length-i.length);i.splice(i.length-n).forEach(function(e){e.src="",delete t.state.tiles[e.tileId]})}}},{key:"maxTilesToKeep",value:function(){return 1e3}},{key:"shouldRedraw",value:function(){var t=JSON.stringify([this.state,this.options]);return this.lastDrawState!==t&&(this.lastDrawState=t,!0)}},{key:"draw",value:function(){this.updateMoveOffset(),this.updateZoom(),this.state.tileLayers.forEach(function(t){return t.calculateGrid()}),this.garbageCollect(),this.shouldRedraw()&&(this.state.tileLayers.length>0&&this.state.tileLayers[0].drawTiles(this.state.scale),this.drawMarkers(),this.drawAttribution()),window.requestAnimationFrame(this.draw)}},{key:"getMapBounds",value:function(){return{nw:i.default.pixelToLatLon([this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize),se:i.default.pixelToLatLon([-this.state.canvasDimensions[0]/2,-this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize)}}},{key:"drawMarkers",value:function(){var t=this,e=this.getMapBounds(),o=this.state.markers.filter(function(t){return t.coords[0]<=e.nw[0]&&t.coords[0]>=e.se[0]&&t.coords[1]>=e.nw[1]&&t.coords[1]<=e.se[1]}),n=[this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2];o.map(function(e){var o=i.default.latLonToPixel(e.coords,t.options.center,t.options.zoom,t.options.tileSize,t.state.canvasDimensions);e.render(t.context,[n[0]-o[0]+t.state.moveOffset[0],n[1]-o[1]+t.state.moveOffset[1]])})}},{key:"drawAttribution",value:function(){this.context.font="bold 12px sans-serif";var t=this.context.measureText(this.options.attribution),e=this.state.canvasDimensions[0]-t.width-4,o=this.state.canvasDimensions[1]-2-4;this.context.fillStyle="rgba(255, 255, 255, 0.7)",this.roundedRectangle(e-4,o-15,t.width+80,80),this.context.fillStyle="rgba(0, 0, 0, 0.7)",this.context.fillText(this.options.attribution,e,o)}},{key:"roundedRectangle",value:function(t,e,o,i){this.context.beginPath(),this.context.moveTo(t+5,e),this.context.lineTo(t+o-5,e),this.context.quadraticCurveTo(t+o,e,t+o,e+5),this.context.lineTo(t+o,e+i-5),this.context.quadraticCurveTo(t+o,e+i,t+o-5,e+i),this.context.lineTo(t+5,e+i),this.context.quadraticCurveTo(t,e+i,t,e+i-5),this.context.lineTo(t,e+5),this.context.quadraticCurveTo(t,e,t+5,e),this.context.closePath(),this.context.fill()}},{key:"addMarker",value:function(t){this.state.markers.push(t)}},{key:"addMarkers",value:function(t){var e=this;t.map(function(t){return e.addMarker(t)})}}]),t}();e.default=l,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=s(o(0)),n=s(o(5));function s(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var r=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.map=e,this.tilesZoomLevel=o,this.shouldBeDeleted=!1,this.context=e.context,this.state={grid:[],gridHash:null,relativeTileOffset:[0,0]}}return function(t,e,o){e&&a(t.prototype,e),o&&a(t,o)}(t,[{key:"toJSON",value:function(){return[this.state,this.loadedPercentage()]}},{key:"getTilesCount",value:function(t){var e=Math.ceil(t/this.map.options.tileSize)*this.map.options.tileAreaMultiplier;return e%2==0&&e++,e}},{key:"calculateGrid",value:function(){var t=this.map,e=t.state,o=t.options,s=i.default.lat2tile(o.center[0],Math.round(this.tilesZoomLevel||o.zoom),!1),a=i.default.lon2tile(o.center[1],Math.round(this.tilesZoomLevel||o.zoom),!1),r=[s,a].join(",");if(this.state.gridHash!==r){var l=this.getTilesCount(e.canvasDimensions[0]),u=this.getTilesCount(e.canvasDimensions[1]),c=Math.floor(s),h=Math.floor(a);this.state.relativeTileOffset=[Math.abs(a-h),Math.abs(s-c)];for(var f=h-Math.floor(l/2),d=c-Math.floor(u/2),v=[],p=0;p<u;p++)for(var m=0;m<l;m++){v[m]||(v[m]=[]);var y=f+m,g=d+p;y>=0&&g>=0&&(v[m][p]=new n.default(y,g,Math.round(this.tilesZoomLevel||o.zoom)),this.ensureTileAsset(v[m][p]))}this.state.grid=v,this.state.gridHash=r}}},{key:"ensureTileAsset",value:function(t){var e=this;if(!(t.id in this.map.state.tiles)){var o=this.map.options.source(Math.floor(t.x),Math.floor(t.y),t.zoom);this.map.state.tiles[t.id]=new Image,this.map.state.tiles[t.id].tileId=t.id,this.map.state.tiles[t.id].src=o,this.map.state.tiles[t.id].loaded=!1,this.map.state.tiles[t.id].onload=function(){e.map.state.tiles[t.id].loaded=!0}}this.map.state.tiles[t.id].lastRequested=(new Date).getTime()}},{key:"drawTiles",value:function(t){var e=this.map.state.canvasDimensions[0],o=this.map.state.canvasDimensions[1],i=this.map.options.tileSize*t,n=[i/2-this.state.relativeTileOffset[0]*i,i/2-this.state.relativeTileOffset[1]*i];this.context.fillStyle="#EEE",this.context.fillRect(0,0,e,o);for(var s=this.getTilesCount(e),a=this.getTilesCount(o),r=s*i-e,l=a*i-o,u=0;u<a;u++)for(var c=0;c<s;c++){var h=this.state.grid[c][u];if(h){var f=this.map.state.moveOffset[0]+n[0]+(c*i-r/2),d=this.map.state.moveOffset[1]+n[1]+(u*i-l/2);try{this.map.state.tiles[h.id].loaded?this.context.drawImage(this.map.state.tiles[h.id],f,d,i,i):this.drawGenericBackground(f,d,i)}catch(t){this.drawGenericBackground(f,d,i)}this.map.options.debug&&(this.context.strokeStyle="green",this.context.strokeRect(f,d,i,i))}}this.map.options.debug&&(this.context.fillStyle="rgba(200, 0, 0, 0.7)",this.context.beginPath(),this.context.arc(e/2,o/2,5,0,2*Math.PI),this.context.fill())}},{key:"drawGenericBackground",value:function(t,e,o){var i=o/8;this.context.beginPath();for(var n=i;n<o;n+=i)for(var s=i;s<o;s+=i)this.context.moveTo(t,e+s),this.context.lineTo(t+o,e+s),this.context.moveTo(t+n,e),this.context.lineTo(t+n,e+o);this.context.strokeStyle="#DDD",this.context.stroke(),this.context.strokeStyle="#CCC",this.context.strokeRect(t,e,o,o)}},{key:"loadedPercentage",value:function(){for(var t=this.getTilesCount(this.map.state.canvasDimensions[0]),e=this.getTilesCount(this.map.state.canvasDimensions[1]),o=t*e,i=0,n=0;n<e;n++)for(var s=0;s<t;s++){var a=this.state.grid[s][n];this.map.state.tiles[a.id].loaded&&i++}return i/o}}]),t}();e.default=r,t.exports=e.default},function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(){function t(e,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._x=e,this._y=o,this._zoom=i}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,[{key:"x",get:function(){return this._x}},{key:"y",get:function(){return this._y}},{key:"zoom",get:function(){return this._zoom}},{key:"id",get:function(){return[this.x,this.y,this.zoom].join("|")}}]),t}();e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(1);function n(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var s=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._coords=e,this._options=Object.assign({},i.defaultMarkerOptions,o)}return function(t,e,o){e&&n(t.prototype,e),o&&n(t,o)}(t,[{key:"render",value:function(t,e){var o=null;switch(this.options.type){case"marker":o=this.renderMarker;break;case"circle":o=this.renderCircle;break;case"donut":o=this.renderDonut}if(!o)throw new Error('Unsupported marker type: "'.concat(this.options.type,'"'));t.fillStyle=this.options.color,t.strokeStyle=this.options.color,(o=o.bind(this))(t,e)}},{key:"renderCircle",value:function(t,e){t.save(),t.beginPath(),t.arc(e[0],e[1],5,0,2*Math.PI),t.fill(),t.restore()}},{key:"renderDonut",value:function(t,e){t.save(),t.beginPath(),t.lineWidth=5,t.arc(e[0],e[1],7,0,2*Math.PI),t.stroke(),t.restore()}},{key:"renderMarker",value:function(t,e){var o=e[0]-8.8490345,i=e[1]-24.786272;t.save(),t.transform(.184386,0,0,.184386,.551658+o,4.09576+i),t.beginPath(),t.lineWidth=1.667195,t.moveTo(45,-22.212949),t.bezierCurveTo(18.494941,-22.212949,-2.991863,-.726145,-2.991863,25.778914),t.bezierCurveTo(-2.991863,52.282306,45,112.21295,45,112.21295),t.bezierCurveTo(45,112.21295,92.991863,52.282306,92.991863,25.777247),t.bezierCurveTo(92.991863,-.726145,71.505059,-22.212949,45,-22.212949),t.moveTo(45,43.827962),t.bezierCurveTo(33.553042,43.827962,24.273437,34.550024,24.273437,23.103067),t.bezierCurveTo(24.273437,11.656109,33.553042,2.376504,45,2.376504),t.bezierCurveTo(56.446958,2.376504,65.726563,11.654442,65.726563,23.101399),t.bezierCurveTo(65.726563,34.548357,56.446958,43.827962,45,43.827962),t.fill(),t.restore()}},{key:"coords",get:function(){return this._coords}},{key:"options",get:function(){return this._options}}]),t}();e.default=s,t.exports=e.default}])});
//# sourceMappingURL=LightningMaps.min.js.map

@@ -460,2 +460,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

this.drawMarkers();
this.drawAttribution();
}

@@ -494,2 +495,32 @@

}, {
key: "drawAttribution",
value: function drawAttribution() {
var margin = 4;
this.context.font = 'bold 12px sans-serif';
var textBounds = this.context.measureText(this.options.attribution);
var x = this.state.canvasDimensions[0] - textBounds.width - margin;
var y = this.state.canvasDimensions[1] - 2 - margin;
this.context.fillStyle = 'rgba(255, 255, 255, 0.7)';
this.roundedRectangle(x - margin, y - 15, textBounds.width + 80, 80);
this.context.fillStyle = 'rgba(0, 0, 0, 0.7)';
this.context.fillText(this.options.attribution, x, y);
}
}, {
key: "roundedRectangle",
value: function roundedRectangle(x, y, width, height) {
var radius = 5;
this.context.beginPath();
this.context.moveTo(x + radius, y);
this.context.lineTo(x + width - radius, y);
this.context.quadraticCurveTo(x + width, y, x + width, y + radius);
this.context.lineTo(x + width, y + height - radius);
this.context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.context.lineTo(x + radius, y + height);
this.context.quadraticCurveTo(x, y + height, x, y + height - radius);
this.context.lineTo(x, y + radius);
this.context.quadraticCurveTo(x, y, x + radius, y);
this.context.closePath();
this.context.fill();
}
}, {
key: "addMarker",

@@ -499,2 +530,11 @@ value: function addMarker(marker) {

}
}, {
key: "addMarkers",
value: function addMarkers(markers) {
var _this4 = this;
markers.map(function (marker) {
return _this4.addMarker(marker);
});
}
}]);

@@ -1036,2 +1076,3 @@

center: [38.841779, -77.088312],
attribution: '© OpenStreetMap contributors',

@@ -1038,0 +1079,0 @@ /**

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("LightningMaps",[],e):"object"==typeof exports?exports.LightningMaps=e():t.LightningMaps=e()}(window,function(){return function(t){var e={};function o(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)o.d(i,s,function(e){return t[e]}.bind(null,s));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2)}([function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,null,[{key:"lon2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(t+180)/360*Math.pow(2,e);return o?Math.floor(i):i}},{key:"lat2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(1-Math.log(Math.tan(t*Math.PI/180)+1/Math.cos(t*Math.PI/180))/Math.PI)/2*Math.pow(2,e);return o?Math.floor(i):i}},{key:"tile2lon",value:function(t,e){return t/Math.pow(2,e)*360-180}},{key:"tile2lat",value:function(t,e){var o=Math.PI-2*Math.PI*t/Math.pow(2,e);return 180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))}},{key:"tile2boundingBox",value:function(e,o,i){return{ne:[t.tile2lat(o,i),t.tile2lon(e+1,i)],sw:[t.tile2lat(o+1,i),t.tile2lon(e,i)]}}},{key:"pixelToLatLon",value:function(e,o,i,s){var a=[e[0]/s,e[1]/s],n=t.lon2tile(o[1],i,!1)-a[0],r=t.lat2tile(o[0],i,!1)-a[1];return[t.tile2lat(r,i),t.tile2lon(n,i)]}},{key:"latLonToPixel",value:function(e,o,i,s,a){var n=t.lon2tile(e[1],i,!1),r=t.lat2tile(e[0],i,!1);return[-(n-t.lon2tile(o[1],i,!1))*s,-(r-t.lat2tile(o[0],i,!1))*s]}}]),t}();e.default=s,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMarkerOptions=e.defaultMapOptions=void 0;e.defaultMapOptions={source:function(t,e,o){return"https://maps.geocod.io/tiles/base/".concat(o,"/").concat(t,"/").concat(e,".png")},zoom:12,center:[38.841779,-77.088312],tileSize:256,panAccelerationMultiplier:2,maxPanAcceleration:3.5,throwTimingThresholdMs:100,throwVelocityThreshold:3e3,animationDurationMs:300,debounceIntervalMs:200,tileAreaMultiplier:2,debug:!1};e.defaultMarkerOptions={color:"rgba(0, 0, 200, 0.7)",type:"marker"}},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(3)),s=a(o(6));function a(t){return t&&t.__esModule?t:{default:t}}var n={Map:i.default,Marker:s.default};e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=n(o(0)),s=n(o(4)),a=o(1);function n(t){return t&&t.__esModule?t:{default:t}}function r(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(e,o){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!e.getContext)throw new Error("Could not get canvas context");this.canvas=e,this.context=this.canvas.getContext("2d"),this.options=Object.assign({},a.defaultMapOptions,o),this.initializeState(),this.attachEvents(),this.applyStyles(),this.lastDrawState=null,this.draw=this.draw.bind(this),window.requestAnimationFrame(this.draw)}return function(t,e,o){e&&r(t.prototype,e),o&&r(t,o)}(t,[{key:"initializeState",value:function(){this.state={canvasDimensions:[this.canvas.width,this.canvas.height],tiles:{},moveOffset:[0,0],targetMoveOffset:[0,0],targetMoveOffsetIsCoord:!1,moveAnimationStart:null,dragStartPosition:null,lastEventActionTime:null,startZoom:this.options.zoom,targetZoom:this.options.zoom,zoomAnimationStart:null,scale:1,lastMouseMoveEvent:null,mouseVelocities:[],markers:[],tileLayers:[new s.default(this)]}}},{key:"getZoom",value:function(){return this.options.zoom}},{key:"setZoom",value:function(t){this.zoomValueIsValid(t)&&(this.state.tileLayers.push(new s.default(this,t)),this.state.lastEventActionTime=window.performance.now(),this.state.zoomAnimationStart=window.performance.now(),this.state.targetZoom=t,this.state.startZoom=this.options.zoom)}},{key:"setCenter",value:function(t){if(!Array.isArray(t)||2!==t.length)throw new Error("Please provide a valid array with a lat/lon");t=t.map(function(t){return parseFloat(t)}),this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=t,this.state.targetMoveOffsetIsCoord=!0}},{key:"setTargetMoveOffset",value:function(t,e){!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?(this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=i.default.pixelToLatLon([t,e],this.options.center,this.options.zoom,this.options.tileSize),this.state.targetMoveOffsetIsCoord=!0):(this.state.targetMoveOffset=[t,e],this.state.targetMoveOffsetIsCoord=!1,this.state.moveOffset=this.state.targetMoveOffset)}},{key:"zoomValueIsValid",value:function(t){return t>=1&&t<=18}},{key:"isReadyForEvent",value:function(){return!this.state.lastEventActionTime||window.performance.now()-this.state.lastEventActionTime>this.options.debounceIntervalMs}},{key:"calculateVelocity",value:function(t,e,o,i){return(t-e)/(o-i)*1e3}},{key:"attachEvents",value:function(){var t=this;this.canvas.addEventListener("wheel",function(e){e.preventDefault(),t.isReadyForEvent()&&(e.deltaY>5?t.setZoom(t.options.zoom-1):e.deltaY<-5&&t.setZoom(t.options.zoom+1))}),this.canvas.addEventListener("dblclick",function(e){e.preventDefault();var o=t.state.canvasDimensions[0]/2,i=t.state.canvasDimensions[1]/2;t.setTargetMoveOffset(-(e.clientX-o),-(e.clientY-i)),t.setZoom(t.options.zoom+1)}),this.canvas.addEventListener("mousedown",function(e){e.preventDefault(),t.state.mouseVelocities=[],t.state.dragStartPosition=[e.clientX-t.state.moveOffset[0],e.clientY-t.state.moveOffset[1]]}),this.canvas.addEventListener("mouseup",function(e){e.preventDefault();var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY);if(0!==t.state.moveOffset[0]||0!==t.state.moveOffset[1]){var s=window.performance.now()-t.options.throwTimingThresholdMs,a=t.state.mouseVelocities.filter(function(t){return t[0]>s}).map(function(t){return t[1]}),n=a.reduce(function(t,e){return t+e},0)/a.length;if(n>=t.options.throwVelocityThreshold){var r=n/t.options.throwVelocityThreshold*t.options.panAccelerationMultiplier;r=Math.min(r,t.options.maxPanAcceleration),t.setTargetMoveOffset(o*r,i*r)}else t.updateCenter()}t.state.dragStartPosition=null}),this.canvas.addEventListener("mousemove",function(e){if(e.preventDefault(),t.state.dragStartPosition){var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY),s=window.performance.now(),a=t.calculateVelocity(t.state.moveOffset[0],o,s,t.state.lastMouseMoveEvent),n=t.calculateVelocity(t.state.moveOffset[1],i,s,t.state.lastMouseMoveEvent),r=Math.round(Math.sqrt(a*a+n*n));t.state.mouseVelocities.push([s,r]),t.setTargetMoveOffset(o,i,!1),t.state.lastMouseMoveEvent=window.performance.now()}return!1})}},{key:"applyStyles",value:function(){this.canvas.style.cursor="grab"}},{key:"easeOutQuad",value:function(t){return t*(2-t)}},{key:"updateMoveOffset",value:function(){if(this.state.moveOffset!==this.state.targetMoveOffset){var t=window.performance.now(),e=Math.max(t-this.state.moveAnimationStart,0),o=this.easeOutQuad(e/this.options.animationDurationMs),s=this.state.targetMoveOffset;this.state.targetMoveOffsetIsCoord&&(s=i.default.latLonToPixel(this.state.targetMoveOffset,this.options.center,this.options.zoom,this.options.tileSize,this.state.canvasDimensions)),this.state.moveOffset=o>=.99?s:[this.state.moveOffset[0]+(s[0]-this.state.moveOffset[0])*o,this.state.moveOffset[1]+(s[1]-this.state.moveOffset[1])*o],this.state.moveOffset===s&&this.updateCenter()}}},{key:"updateCenter",value:function(){var t=i.default.pixelToLatLon(this.state.moveOffset,this.options.center,this.options.zoom,this.options.tileSize);this.setTargetMoveOffset(0,0,!1),this.options.center=t}},{key:"updateZoom",value:function(){if(this.options.zoom!==this.state.targetZoom){var t=Math.max(window.performance.now()-this.state.zoomAnimationStart,0),e=this.easeOutQuad(t/this.options.animationDurationMs),o=Math.abs(this.state.targetZoom-this.state.startZoom);this.state.targetZoom<=this.state.startZoom&&(o*=-1);var i=o*e,s=this.options.animationDurationMs-t;this.options.zoom=s<=5?this.state.targetZoom:this.state.startZoom+i;var a=Math.round(this.options.zoom),n=this.options.zoom-a;this.state.scale=Math.pow(2,n),this.options.zoom===this.state.targetZoom&&(this.state.tileLayers.shift(),this.state.tileLayers[0].tilesZoomLevel=null)}else this.state.scale=1}},{key:"garbageCollect",value:function(){var t=this,e=Object.values(this.state.tiles);if(e.length>this.maxTilesToKeep()){var o=(new Date).getTime()-5e3,i=e.filter(function(t){return t.lastRequested<o}).sort(function(t,e){return~~(t.lastRequested<e.lastRequested)}),s=this.maxTilesToKeep()-(e.length-i.length);i.splice(i.length-s).forEach(function(e){e.src="",delete t.state.tiles[e.tileId]})}}},{key:"maxTilesToKeep",value:function(){return 1e3}},{key:"shouldRedraw",value:function(){var t=JSON.stringify([this.state,this.options]);return this.lastDrawState!==t&&(this.lastDrawState=t,!0)}},{key:"draw",value:function(){this.updateMoveOffset(),this.updateZoom(),this.state.tileLayers.forEach(function(t){return t.calculateGrid()}),this.garbageCollect(),this.shouldRedraw()&&(this.state.tileLayers.length>0&&this.state.tileLayers[0].drawTiles(this.state.scale),this.drawMarkers()),window.requestAnimationFrame(this.draw)}},{key:"getMapBounds",value:function(){return{nw:i.default.pixelToLatLon([this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize),se:i.default.pixelToLatLon([-this.state.canvasDimensions[0]/2,-this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize)}}},{key:"drawMarkers",value:function(){var t=this,e=this.getMapBounds(),o=this.state.markers.filter(function(t){return t.coords[0]<=e.nw[0]&&t.coords[0]>=e.se[0]&&t.coords[1]>=e.nw[1]&&t.coords[1]<=e.se[1]}),s=[this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2];o.map(function(e){var o=i.default.latLonToPixel(e.coords,t.options.center,t.options.zoom,t.options.tileSize,t.state.canvasDimensions);e.render(t.context,[s[0]-o[0]+t.state.moveOffset[0],s[1]-o[1]+t.state.moveOffset[1]])})}},{key:"addMarker",value:function(t){this.state.markers.push(t)}}]),t}();e.default=l,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(0)),s=a(o(5));function a(t){return t&&t.__esModule?t:{default:t}}function n(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var r=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.map=e,this.tilesZoomLevel=o,this.shouldBeDeleted=!1,this.context=e.context,this.state={grid:[],gridHash:null,relativeTileOffset:[0,0]}}return function(t,e,o){e&&n(t.prototype,e),o&&n(t,o)}(t,[{key:"toJSON",value:function(){return[this.state,this.loadedPercentage()]}},{key:"getTilesCount",value:function(t){var e=Math.ceil(t/this.map.options.tileSize)*this.map.options.tileAreaMultiplier;return e%2==0&&e++,e}},{key:"calculateGrid",value:function(){var t=this.map,e=t.state,o=t.options,a=i.default.lat2tile(o.center[0],Math.round(this.tilesZoomLevel||o.zoom),!1),n=i.default.lon2tile(o.center[1],Math.round(this.tilesZoomLevel||o.zoom),!1),r=[a,n].join(",");if(this.state.gridHash!==r){var l=this.getTilesCount(e.canvasDimensions[0]),u=this.getTilesCount(e.canvasDimensions[1]),f=Math.floor(a),c=Math.floor(n);this.state.relativeTileOffset=[Math.abs(n-c),Math.abs(a-f)];for(var h=c-Math.floor(l/2),d=f-Math.floor(u/2),v=[],p=0;p<u;p++)for(var m=0;m<l;m++){v[m]||(v[m]=[]);var y=h+m,g=d+p;y>=0&&g>=0&&(v[m][p]=new s.default(y,g,Math.round(this.tilesZoomLevel||o.zoom)),this.ensureTileAsset(v[m][p]))}this.state.grid=v,this.state.gridHash=r}}},{key:"ensureTileAsset",value:function(t){var e=this;if(!(t.id in this.map.state.tiles)){var o=this.map.options.source(Math.floor(t.x),Math.floor(t.y),t.zoom);this.map.state.tiles[t.id]=new Image,this.map.state.tiles[t.id].tileId=t.id,this.map.state.tiles[t.id].src=o,this.map.state.tiles[t.id].loaded=!1,this.map.state.tiles[t.id].onload=function(){e.map.state.tiles[t.id].loaded=!0}}this.map.state.tiles[t.id].lastRequested=(new Date).getTime()}},{key:"drawTiles",value:function(t){var e=this.map.state.canvasDimensions[0],o=this.map.state.canvasDimensions[1],i=this.map.options.tileSize*t,s=[i/2-this.state.relativeTileOffset[0]*i,i/2-this.state.relativeTileOffset[1]*i];this.context.fillStyle="#EEE",this.context.fillRect(0,0,e,o);for(var a=this.getTilesCount(e),n=this.getTilesCount(o),r=a*i-e,l=n*i-o,u=0;u<n;u++)for(var f=0;f<a;f++){var c=this.state.grid[f][u];if(c){var h=this.map.state.moveOffset[0]+s[0]+(f*i-r/2),d=this.map.state.moveOffset[1]+s[1]+(u*i-l/2);try{this.map.state.tiles[c.id].loaded?this.context.drawImage(this.map.state.tiles[c.id],h,d,i,i):this.drawGenericBackground(h,d,i)}catch(t){this.drawGenericBackground(h,d,i)}this.map.options.debug&&(this.context.strokeStyle="green",this.context.strokeRect(h,d,i,i))}}this.map.options.debug&&(this.context.fillStyle="rgba(200, 0, 0, 0.7)",this.context.beginPath(),this.context.arc(e/2,o/2,5,0,2*Math.PI),this.context.fill())}},{key:"drawGenericBackground",value:function(t,e,o){var i=o/8;this.context.beginPath();for(var s=i;s<o;s+=i)for(var a=i;a<o;a+=i)this.context.moveTo(t,e+a),this.context.lineTo(t+o,e+a),this.context.moveTo(t+s,e),this.context.lineTo(t+s,e+o);this.context.strokeStyle="#DDD",this.context.stroke(),this.context.strokeStyle="#CCC",this.context.strokeRect(t,e,o,o)}},{key:"loadedPercentage",value:function(){for(var t=this.getTilesCount(this.map.state.canvasDimensions[0]),e=this.getTilesCount(this.map.state.canvasDimensions[1]),o=t*e,i=0,s=0;s<e;s++)for(var a=0;a<t;a++){var n=this.state.grid[a][s];this.map.state.tiles[n.id].loaded&&i++}return i/o}}]),t}();e.default=r,t.exports=e.default},function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=function(){function t(e,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._x=e,this._y=o,this._zoom=i}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,[{key:"x",get:function(){return this._x}},{key:"y",get:function(){return this._y}},{key:"zoom",get:function(){return this._zoom}},{key:"id",get:function(){return[this.x,this.y,this.zoom].join("|")}}]),t}();e.default=s,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(1);function s(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var a=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._coords=e,this._options=Object.assign({},i.defaultMarkerOptions,o)}return function(t,e,o){e&&s(t.prototype,e),o&&s(t,o)}(t,[{key:"render",value:function(t,e){var o=null;switch(this.options.type){case"marker":o=this.renderMarker;break;case"circle":o=this.renderCircle;break;case"donut":o=this.renderDonut}if(!o)throw new Error('Unsupported marker type: "'.concat(this.options.type,'"'));t.fillStyle=this.options.color,t.strokeStyle=this.options.color,(o=o.bind(this))(t,e)}},{key:"renderCircle",value:function(t,e){t.save(),t.beginPath(),t.arc(e[0],e[1],5,0,2*Math.PI),t.fill(),t.restore()}},{key:"renderDonut",value:function(t,e){t.save(),t.beginPath(),t.lineWidth=5,t.arc(e[0],e[1],7,0,2*Math.PI),t.stroke(),t.restore()}},{key:"renderMarker",value:function(t,e){var o=e[0]-8.8490345,i=e[1]-24.786272;t.save(),t.transform(.184386,0,0,.184386,.551658+o,4.09576+i),t.beginPath(),t.lineWidth=1.667195,t.moveTo(45,-22.212949),t.bezierCurveTo(18.494941,-22.212949,-2.991863,-.726145,-2.991863,25.778914),t.bezierCurveTo(-2.991863,52.282306,45,112.21295,45,112.21295),t.bezierCurveTo(45,112.21295,92.991863,52.282306,92.991863,25.777247),t.bezierCurveTo(92.991863,-.726145,71.505059,-22.212949,45,-22.212949),t.moveTo(45,43.827962),t.bezierCurveTo(33.553042,43.827962,24.273437,34.550024,24.273437,23.103067),t.bezierCurveTo(24.273437,11.656109,33.553042,2.376504,45,2.376504),t.bezierCurveTo(56.446958,2.376504,65.726563,11.654442,65.726563,23.101399),t.bezierCurveTo(65.726563,34.548357,56.446958,43.827962,45,43.827962),t.fill(),t.restore()}},{key:"coords",get:function(){return this._coords}},{key:"options",get:function(){return this._options}}]),t}();e.default=a,t.exports=e.default}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("LightningMaps",[],e):"object"==typeof exports?exports.LightningMaps=e():t.LightningMaps=e()}(window,function(){return function(t){var e={};function o(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(i,n,function(e){return t[e]}.bind(null,n));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2)}([function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,null,[{key:"lon2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(t+180)/360*Math.pow(2,e);return o?Math.floor(i):i}},{key:"lat2tile",value:function(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(1-Math.log(Math.tan(t*Math.PI/180)+1/Math.cos(t*Math.PI/180))/Math.PI)/2*Math.pow(2,e);return o?Math.floor(i):i}},{key:"tile2lon",value:function(t,e){return t/Math.pow(2,e)*360-180}},{key:"tile2lat",value:function(t,e){var o=Math.PI-2*Math.PI*t/Math.pow(2,e);return 180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))}},{key:"tile2boundingBox",value:function(e,o,i){return{ne:[t.tile2lat(o,i),t.tile2lon(e+1,i)],sw:[t.tile2lat(o+1,i),t.tile2lon(e,i)]}}},{key:"pixelToLatLon",value:function(e,o,i,n){var s=[e[0]/n,e[1]/n],a=t.lon2tile(o[1],i,!1)-s[0],r=t.lat2tile(o[0],i,!1)-s[1];return[t.tile2lat(r,i),t.tile2lon(a,i)]}},{key:"latLonToPixel",value:function(e,o,i,n,s){var a=t.lon2tile(e[1],i,!1),r=t.lat2tile(e[0],i,!1);return[-(a-t.lon2tile(o[1],i,!1))*n,-(r-t.lat2tile(o[0],i,!1))*n]}}]),t}();e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMarkerOptions=e.defaultMapOptions=void 0;e.defaultMapOptions={source:function(t,e,o){return"https://maps.geocod.io/tiles/base/".concat(o,"/").concat(t,"/").concat(e,".png")},zoom:12,center:[38.841779,-77.088312],attribution:"© OpenStreetMap contributors",tileSize:256,panAccelerationMultiplier:2,maxPanAcceleration:3.5,throwTimingThresholdMs:100,throwVelocityThreshold:3e3,animationDurationMs:300,debounceIntervalMs:200,tileAreaMultiplier:2,debug:!1};e.defaultMarkerOptions={color:"rgba(0, 0, 200, 0.7)",type:"marker"}},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=s(o(3)),n=s(o(6));function s(t){return t&&t.__esModule?t:{default:t}}var a={Map:i.default,Marker:n.default};e.default=a,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=a(o(0)),n=a(o(4)),s=o(1);function a(t){return t&&t.__esModule?t:{default:t}}function r(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(e,o){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!e.getContext)throw new Error("Could not get canvas context");this.canvas=e,this.context=this.canvas.getContext("2d"),this.options=Object.assign({},s.defaultMapOptions,o),this.initializeState(),this.attachEvents(),this.applyStyles(),this.lastDrawState=null,this.draw=this.draw.bind(this),window.requestAnimationFrame(this.draw)}return function(t,e,o){e&&r(t.prototype,e),o&&r(t,o)}(t,[{key:"initializeState",value:function(){this.state={canvasDimensions:[this.canvas.width,this.canvas.height],tiles:{},moveOffset:[0,0],targetMoveOffset:[0,0],targetMoveOffsetIsCoord:!1,moveAnimationStart:null,dragStartPosition:null,lastEventActionTime:null,startZoom:this.options.zoom,targetZoom:this.options.zoom,zoomAnimationStart:null,scale:1,lastMouseMoveEvent:null,mouseVelocities:[],markers:[],tileLayers:[new n.default(this)]}}},{key:"getZoom",value:function(){return this.options.zoom}},{key:"setZoom",value:function(t){this.zoomValueIsValid(t)&&(this.state.tileLayers.push(new n.default(this,t)),this.state.lastEventActionTime=window.performance.now(),this.state.zoomAnimationStart=window.performance.now(),this.state.targetZoom=t,this.state.startZoom=this.options.zoom)}},{key:"setCenter",value:function(t){if(!Array.isArray(t)||2!==t.length)throw new Error("Please provide a valid array with a lat/lon");t=t.map(function(t){return parseFloat(t)}),this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=t,this.state.targetMoveOffsetIsCoord=!0}},{key:"setTargetMoveOffset",value:function(t,e){!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?(this.state.moveAnimationStart=window.performance.now(),this.state.targetMoveOffset=i.default.pixelToLatLon([t,e],this.options.center,this.options.zoom,this.options.tileSize),this.state.targetMoveOffsetIsCoord=!0):(this.state.targetMoveOffset=[t,e],this.state.targetMoveOffsetIsCoord=!1,this.state.moveOffset=this.state.targetMoveOffset)}},{key:"zoomValueIsValid",value:function(t){return t>=1&&t<=18}},{key:"isReadyForEvent",value:function(){return!this.state.lastEventActionTime||window.performance.now()-this.state.lastEventActionTime>this.options.debounceIntervalMs}},{key:"calculateVelocity",value:function(t,e,o,i){return(t-e)/(o-i)*1e3}},{key:"attachEvents",value:function(){var t=this;this.canvas.addEventListener("wheel",function(e){e.preventDefault(),t.isReadyForEvent()&&(e.deltaY>5?t.setZoom(t.options.zoom-1):e.deltaY<-5&&t.setZoom(t.options.zoom+1))}),this.canvas.addEventListener("dblclick",function(e){e.preventDefault();var o=t.state.canvasDimensions[0]/2,i=t.state.canvasDimensions[1]/2;t.setTargetMoveOffset(-(e.clientX-o),-(e.clientY-i)),t.setZoom(t.options.zoom+1)}),this.canvas.addEventListener("mousedown",function(e){e.preventDefault(),t.state.mouseVelocities=[],t.state.dragStartPosition=[e.clientX-t.state.moveOffset[0],e.clientY-t.state.moveOffset[1]]}),this.canvas.addEventListener("mouseup",function(e){e.preventDefault();var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY);if(0!==t.state.moveOffset[0]||0!==t.state.moveOffset[1]){var n=window.performance.now()-t.options.throwTimingThresholdMs,s=t.state.mouseVelocities.filter(function(t){return t[0]>n}).map(function(t){return t[1]}),a=s.reduce(function(t,e){return t+e},0)/s.length;if(a>=t.options.throwVelocityThreshold){var r=a/t.options.throwVelocityThreshold*t.options.panAccelerationMultiplier;r=Math.min(r,t.options.maxPanAcceleration),t.setTargetMoveOffset(o*r,i*r)}else t.updateCenter()}t.state.dragStartPosition=null}),this.canvas.addEventListener("mousemove",function(e){if(e.preventDefault(),t.state.dragStartPosition){var o=-(t.state.dragStartPosition[0]-e.clientX),i=-(t.state.dragStartPosition[1]-e.clientY),n=window.performance.now(),s=t.calculateVelocity(t.state.moveOffset[0],o,n,t.state.lastMouseMoveEvent),a=t.calculateVelocity(t.state.moveOffset[1],i,n,t.state.lastMouseMoveEvent),r=Math.round(Math.sqrt(s*s+a*a));t.state.mouseVelocities.push([n,r]),t.setTargetMoveOffset(o,i,!1),t.state.lastMouseMoveEvent=window.performance.now()}return!1})}},{key:"applyStyles",value:function(){this.canvas.style.cursor="grab"}},{key:"easeOutQuad",value:function(t){return t*(2-t)}},{key:"updateMoveOffset",value:function(){if(this.state.moveOffset!==this.state.targetMoveOffset){var t=window.performance.now(),e=Math.max(t-this.state.moveAnimationStart,0),o=this.easeOutQuad(e/this.options.animationDurationMs),n=this.state.targetMoveOffset;this.state.targetMoveOffsetIsCoord&&(n=i.default.latLonToPixel(this.state.targetMoveOffset,this.options.center,this.options.zoom,this.options.tileSize,this.state.canvasDimensions)),this.state.moveOffset=o>=.99?n:[this.state.moveOffset[0]+(n[0]-this.state.moveOffset[0])*o,this.state.moveOffset[1]+(n[1]-this.state.moveOffset[1])*o],this.state.moveOffset===n&&this.updateCenter()}}},{key:"updateCenter",value:function(){var t=i.default.pixelToLatLon(this.state.moveOffset,this.options.center,this.options.zoom,this.options.tileSize);this.setTargetMoveOffset(0,0,!1),this.options.center=t}},{key:"updateZoom",value:function(){if(this.options.zoom!==this.state.targetZoom){var t=Math.max(window.performance.now()-this.state.zoomAnimationStart,0),e=this.easeOutQuad(t/this.options.animationDurationMs),o=Math.abs(this.state.targetZoom-this.state.startZoom);this.state.targetZoom<=this.state.startZoom&&(o*=-1);var i=o*e,n=this.options.animationDurationMs-t;this.options.zoom=n<=5?this.state.targetZoom:this.state.startZoom+i;var s=Math.round(this.options.zoom),a=this.options.zoom-s;this.state.scale=Math.pow(2,a),this.options.zoom===this.state.targetZoom&&(this.state.tileLayers.shift(),this.state.tileLayers[0].tilesZoomLevel=null)}else this.state.scale=1}},{key:"garbageCollect",value:function(){var t=this,e=Object.values(this.state.tiles);if(e.length>this.maxTilesToKeep()){var o=(new Date).getTime()-5e3,i=e.filter(function(t){return t.lastRequested<o}).sort(function(t,e){return~~(t.lastRequested<e.lastRequested)}),n=this.maxTilesToKeep()-(e.length-i.length);i.splice(i.length-n).forEach(function(e){e.src="",delete t.state.tiles[e.tileId]})}}},{key:"maxTilesToKeep",value:function(){return 1e3}},{key:"shouldRedraw",value:function(){var t=JSON.stringify([this.state,this.options]);return this.lastDrawState!==t&&(this.lastDrawState=t,!0)}},{key:"draw",value:function(){this.updateMoveOffset(),this.updateZoom(),this.state.tileLayers.forEach(function(t){return t.calculateGrid()}),this.garbageCollect(),this.shouldRedraw()&&(this.state.tileLayers.length>0&&this.state.tileLayers[0].drawTiles(this.state.scale),this.drawMarkers(),this.drawAttribution()),window.requestAnimationFrame(this.draw)}},{key:"getMapBounds",value:function(){return{nw:i.default.pixelToLatLon([this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize),se:i.default.pixelToLatLon([-this.state.canvasDimensions[0]/2,-this.state.canvasDimensions[1]/2],this.options.center,this.options.zoom,this.options.tileSize)}}},{key:"drawMarkers",value:function(){var t=this,e=this.getMapBounds(),o=this.state.markers.filter(function(t){return t.coords[0]<=e.nw[0]&&t.coords[0]>=e.se[0]&&t.coords[1]>=e.nw[1]&&t.coords[1]<=e.se[1]}),n=[this.state.canvasDimensions[0]/2,this.state.canvasDimensions[1]/2];o.map(function(e){var o=i.default.latLonToPixel(e.coords,t.options.center,t.options.zoom,t.options.tileSize,t.state.canvasDimensions);e.render(t.context,[n[0]-o[0]+t.state.moveOffset[0],n[1]-o[1]+t.state.moveOffset[1]])})}},{key:"drawAttribution",value:function(){this.context.font="bold 12px sans-serif";var t=this.context.measureText(this.options.attribution),e=this.state.canvasDimensions[0]-t.width-4,o=this.state.canvasDimensions[1]-2-4;this.context.fillStyle="rgba(255, 255, 255, 0.7)",this.roundedRectangle(e-4,o-15,t.width+80,80),this.context.fillStyle="rgba(0, 0, 0, 0.7)",this.context.fillText(this.options.attribution,e,o)}},{key:"roundedRectangle",value:function(t,e,o,i){this.context.beginPath(),this.context.moveTo(t+5,e),this.context.lineTo(t+o-5,e),this.context.quadraticCurveTo(t+o,e,t+o,e+5),this.context.lineTo(t+o,e+i-5),this.context.quadraticCurveTo(t+o,e+i,t+o-5,e+i),this.context.lineTo(t+5,e+i),this.context.quadraticCurveTo(t,e+i,t,e+i-5),this.context.lineTo(t,e+5),this.context.quadraticCurveTo(t,e,t+5,e),this.context.closePath(),this.context.fill()}},{key:"addMarker",value:function(t){this.state.markers.push(t)}},{key:"addMarkers",value:function(t){var e=this;t.map(function(t){return e.addMarker(t)})}}]),t}();e.default=l,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=s(o(0)),n=s(o(5));function s(t){return t&&t.__esModule?t:{default:t}}function a(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var r=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.map=e,this.tilesZoomLevel=o,this.shouldBeDeleted=!1,this.context=e.context,this.state={grid:[],gridHash:null,relativeTileOffset:[0,0]}}return function(t,e,o){e&&a(t.prototype,e),o&&a(t,o)}(t,[{key:"toJSON",value:function(){return[this.state,this.loadedPercentage()]}},{key:"getTilesCount",value:function(t){var e=Math.ceil(t/this.map.options.tileSize)*this.map.options.tileAreaMultiplier;return e%2==0&&e++,e}},{key:"calculateGrid",value:function(){var t=this.map,e=t.state,o=t.options,s=i.default.lat2tile(o.center[0],Math.round(this.tilesZoomLevel||o.zoom),!1),a=i.default.lon2tile(o.center[1],Math.round(this.tilesZoomLevel||o.zoom),!1),r=[s,a].join(",");if(this.state.gridHash!==r){var l=this.getTilesCount(e.canvasDimensions[0]),u=this.getTilesCount(e.canvasDimensions[1]),c=Math.floor(s),h=Math.floor(a);this.state.relativeTileOffset=[Math.abs(a-h),Math.abs(s-c)];for(var f=h-Math.floor(l/2),d=c-Math.floor(u/2),v=[],p=0;p<u;p++)for(var m=0;m<l;m++){v[m]||(v[m]=[]);var y=f+m,g=d+p;y>=0&&g>=0&&(v[m][p]=new n.default(y,g,Math.round(this.tilesZoomLevel||o.zoom)),this.ensureTileAsset(v[m][p]))}this.state.grid=v,this.state.gridHash=r}}},{key:"ensureTileAsset",value:function(t){var e=this;if(!(t.id in this.map.state.tiles)){var o=this.map.options.source(Math.floor(t.x),Math.floor(t.y),t.zoom);this.map.state.tiles[t.id]=new Image,this.map.state.tiles[t.id].tileId=t.id,this.map.state.tiles[t.id].src=o,this.map.state.tiles[t.id].loaded=!1,this.map.state.tiles[t.id].onload=function(){e.map.state.tiles[t.id].loaded=!0}}this.map.state.tiles[t.id].lastRequested=(new Date).getTime()}},{key:"drawTiles",value:function(t){var e=this.map.state.canvasDimensions[0],o=this.map.state.canvasDimensions[1],i=this.map.options.tileSize*t,n=[i/2-this.state.relativeTileOffset[0]*i,i/2-this.state.relativeTileOffset[1]*i];this.context.fillStyle="#EEE",this.context.fillRect(0,0,e,o);for(var s=this.getTilesCount(e),a=this.getTilesCount(o),r=s*i-e,l=a*i-o,u=0;u<a;u++)for(var c=0;c<s;c++){var h=this.state.grid[c][u];if(h){var f=this.map.state.moveOffset[0]+n[0]+(c*i-r/2),d=this.map.state.moveOffset[1]+n[1]+(u*i-l/2);try{this.map.state.tiles[h.id].loaded?this.context.drawImage(this.map.state.tiles[h.id],f,d,i,i):this.drawGenericBackground(f,d,i)}catch(t){this.drawGenericBackground(f,d,i)}this.map.options.debug&&(this.context.strokeStyle="green",this.context.strokeRect(f,d,i,i))}}this.map.options.debug&&(this.context.fillStyle="rgba(200, 0, 0, 0.7)",this.context.beginPath(),this.context.arc(e/2,o/2,5,0,2*Math.PI),this.context.fill())}},{key:"drawGenericBackground",value:function(t,e,o){var i=o/8;this.context.beginPath();for(var n=i;n<o;n+=i)for(var s=i;s<o;s+=i)this.context.moveTo(t,e+s),this.context.lineTo(t+o,e+s),this.context.moveTo(t+n,e),this.context.lineTo(t+n,e+o);this.context.strokeStyle="#DDD",this.context.stroke(),this.context.strokeStyle="#CCC",this.context.strokeRect(t,e,o,o)}},{key:"loadedPercentage",value:function(){for(var t=this.getTilesCount(this.map.state.canvasDimensions[0]),e=this.getTilesCount(this.map.state.canvasDimensions[1]),o=t*e,i=0,n=0;n<e;n++)for(var s=0;s<t;s++){var a=this.state.grid[s][n];this.map.state.tiles[a.id].loaded&&i++}return i/o}}]),t}();e.default=r,t.exports=e.default},function(t,e,o){"use strict";function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(){function t(e,o,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._x=e,this._y=o,this._zoom=i}return function(t,e,o){e&&i(t.prototype,e),o&&i(t,o)}(t,[{key:"x",get:function(){return this._x}},{key:"y",get:function(){return this._y}},{key:"zoom",get:function(){return this._zoom}},{key:"id",get:function(){return[this.x,this.y,this.zoom].join("|")}}]),t}();e.default=n,t.exports=e.default},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(1);function n(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var s=function(){function t(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._coords=e,this._options=Object.assign({},i.defaultMarkerOptions,o)}return function(t,e,o){e&&n(t.prototype,e),o&&n(t,o)}(t,[{key:"render",value:function(t,e){var o=null;switch(this.options.type){case"marker":o=this.renderMarker;break;case"circle":o=this.renderCircle;break;case"donut":o=this.renderDonut}if(!o)throw new Error('Unsupported marker type: "'.concat(this.options.type,'"'));t.fillStyle=this.options.color,t.strokeStyle=this.options.color,(o=o.bind(this))(t,e)}},{key:"renderCircle",value:function(t,e){t.save(),t.beginPath(),t.arc(e[0],e[1],5,0,2*Math.PI),t.fill(),t.restore()}},{key:"renderDonut",value:function(t,e){t.save(),t.beginPath(),t.lineWidth=5,t.arc(e[0],e[1],7,0,2*Math.PI),t.stroke(),t.restore()}},{key:"renderMarker",value:function(t,e){var o=e[0]-8.8490345,i=e[1]-24.786272;t.save(),t.transform(.184386,0,0,.184386,.551658+o,4.09576+i),t.beginPath(),t.lineWidth=1.667195,t.moveTo(45,-22.212949),t.bezierCurveTo(18.494941,-22.212949,-2.991863,-.726145,-2.991863,25.778914),t.bezierCurveTo(-2.991863,52.282306,45,112.21295,45,112.21295),t.bezierCurveTo(45,112.21295,92.991863,52.282306,92.991863,25.777247),t.bezierCurveTo(92.991863,-.726145,71.505059,-22.212949,45,-22.212949),t.moveTo(45,43.827962),t.bezierCurveTo(33.553042,43.827962,24.273437,34.550024,24.273437,23.103067),t.bezierCurveTo(24.273437,11.656109,33.553042,2.376504,45,2.376504),t.bezierCurveTo(56.446958,2.376504,65.726563,11.654442,65.726563,23.101399),t.bezierCurveTo(65.726563,34.548357,56.446958,43.827962,45,43.827962),t.fill(),t.restore()}},{key:"coords",get:function(){return this._coords}},{key:"options",get:function(){return this._options}}]),t}();e.default=s,t.exports=e.default}])});
//# sourceMappingURL=LightningMaps.min.js.map
{
"name": "lightning-maps",
"version": "0.0.1",
"description": "Produce universal library with webpack and es6",
"version": "0.0.4",
"description": "Lightweight, dependency-free slippy map renderer",
"main": "lib/LightningMaps.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -1,2 +0,2 @@

# Lightning Maps `[WIP]`
# Lightning Maps (*Alpha release*)

@@ -10,3 +10,3 @@ A lightweight, dependency-free slippy map renderer.

* Modern, built using ES6+ syntax
* Lightweight, [absolutely zero dependencies](https://github.com/Geocodio/lightning-maps/blob/master/package.json#L28) with a minified bundle of less than 20kb
* Lightweight, [absolutely zero dependencies](https://github.com/Geocodio/lightning-maps/blob/master/package.json#L28) with a [minified bundle](https://raw.githubusercontent.com/Geocodio/lightning-maps/master/lib/LightningMaps.min.js) of less than 20kb
* Ability to render thousands of markers, by using `<canvas>` rendering instead of depending on the DOM

@@ -17,8 +17,12 @@ * Wrappers for React and VueJS (Coming soon)

### 1. Include `LightningMaps.min.js`
### 1. Install
> Optional: You can also use your favorite module loader
```
npm install --save npm lightning-maps
```
Or link directly to our build via the [unpkg](https://unpkg.com) CDN:
```html
<script src="LightningMaps.min.js"></script>
<script src="https://unpkg.com/lightning-maps@0.0.1/lib/LightningMaps.min.js"></script>
```

@@ -59,3 +63,3 @@

> You can now head to [http://localhost:8081/docs/simple.html](http://localhost:8081/docs/simple.html) or [http://localhost:8081/docs/markers.html](http://localhost:8081/docs/markers.html) to test the app
> You can now head to [http://localhost:8080/simple.html](http://localhost:8080/simple.html) or [http://localhost:8080/markers.html](http://localhost:8080/markers.html) to test the app

@@ -62,0 +66,0 @@ ### Build library for distribution

@@ -8,2 +8,3 @@ export const defaultMapOptions = {

center: [38.841779, -77.088312],
attribution: '© OpenStreetMap contributors',

@@ -10,0 +11,0 @@ /**

@@ -369,2 +369,3 @@ import TileConversion from './TileConversion';

this.drawMarkers();
this.drawAttribution();
}

@@ -424,2 +425,37 @@

drawAttribution() {
const margin = 4;
this.context.font = 'bold 12px sans-serif';
const textBounds = this.context.measureText(this.options.attribution);
const x = this.state.canvasDimensions[0] - textBounds.width - margin;
const y = this.state.canvasDimensions[1] - 2 - margin;
this.context.fillStyle = 'rgba(255, 255, 255, 0.7)';
this.roundedRectangle(x - margin, y - 15, textBounds.width + 80, 80);
this.context.fillStyle = 'rgba(0, 0, 0, 0.7)';
this.context.fillText(this.options.attribution, x, y);
}
roundedRectangle(x, y, width, height) {
const radius = 5;
this.context.beginPath();
this.context.moveTo(x + radius, y);
this.context.lineTo(x + width - radius, y);
this.context.quadraticCurveTo(x + width, y, x + width, y + radius);
this.context.lineTo(x + width, y + height - radius);
this.context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.context.lineTo(x + radius, y + height);
this.context.quadraticCurveTo(x, y + height, x, y + height - radius);
this.context.lineTo(x, y + radius);
this.context.quadraticCurveTo(x, y, x + radius, y);
this.context.closePath();
this.context.fill();
}
addMarker(marker) {

@@ -429,2 +465,6 @@ this.state.markers.push(marker);

addMarkers(markers) {
markers.map(marker => this.addMarker(marker));
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc