dashboard - first version
This commit is contained in:
10
static/vendor/leaflet/css/leaflet-liveupdate.css
vendored
Normal file
10
static/vendor/leaflet/css/leaflet-liveupdate.css
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.leaflet-control-liveupdate a {
|
||||
background:#fff url(liveupdate.png) no-repeat 0 0;
|
||||
background-size:26px 52px;
|
||||
}
|
||||
.leaflet-liveupdate-on .leaflet-control-liveupdate a {
|
||||
background-position:0 -26px;
|
||||
}
|
||||
.leaflet-liveupdate-on a {
|
||||
background-position:0 -26px;
|
||||
}
|
11
static/vendor/leaflet/js/leaflet-heat.js
vendored
Normal file
11
static/vendor/leaflet/js/leaflet-heat.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
(c) 2014, Vladimir Agafonkin
|
||||
simpleheat, a tiny JavaScript library for drawing heatmaps with Canvas
|
||||
https://github.com/mourner/simpleheat
|
||||
*/
|
||||
!function(){"use strict";function t(i){return this instanceof t?(this._canvas=i="string"==typeof i?document.getElementById(i):i,this._ctx=i.getContext("2d"),this._width=i.width,this._height=i.height,this._max=1,void this.clear()):new t(i)}t.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t,i){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,i){i=i||15;var a=this._circle=document.createElement("canvas"),s=a.getContext("2d"),e=this._r=t+i;return a.width=a.height=2*e,s.shadowOffsetX=s.shadowOffsetY=200,s.shadowBlur=i,s.shadowColor="black",s.beginPath(),s.arc(e-200,e-200,t,0,2*Math.PI,!0),s.closePath(),s.fill(),this},gradient:function(t){var i=document.createElement("canvas"),a=i.getContext("2d"),s=a.createLinearGradient(0,0,0,256);i.width=1,i.height=256;for(var e in t)s.addColorStop(e,t[e]);return a.fillStyle=s,a.fillRect(0,0,1,256),this._grad=a.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var i=this._ctx;i.clearRect(0,0,this._width,this._height);for(var a,s=0,e=this._data.length;e>s;s++)a=this._data[s],i.globalAlpha=Math.max(a[2]/this._max,t||.05),i.drawImage(this._circle,a[0]-this._r,a[1]-this._r);var n=i.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),i.putImageData(n,0,0),this},_colorize:function(t,i){for(var a,s=3,e=t.length;e>s;s+=4)a=4*t[s],a&&(t[s-3]=i[a],t[s-2]=i[a+1],t[s-1]=i[a+2])}},window.simpleheat=t}(),/*
|
||||
(c) 2014, Vladimir Agafonkin
|
||||
Leaflet.heat, a tiny and fast heatmap plugin for Leaflet.
|
||||
https://github.com/Leaflet/Leaflet.heat
|
||||
*/
|
||||
L.HeatLayer=(L.Layer?L.Layer:L.Class).extend({initialize:function(t,i){this._latlngs=t,L.setOptions(this,i)},setLatLngs:function(t){return this._latlngs=t,this.redraw()},addLatLng:function(t){return this._latlngs.push(t),this.redraw()},setOptions:function(t){return L.setOptions(this,t),this._heat&&this._updateOptions(),this.redraw()},redraw:function(){return!this._heat||this._frame||this._map._animating||(this._frame=L.Util.requestAnimFrame(this._redraw,this)),this},onAdd:function(t){this._map=t,this._canvas||this._initCanvas(),t._panes.overlayPane.appendChild(this._canvas),t.on("moveend",this._reset,this),t.options.zoomAnimation&&L.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._canvas),t.off("moveend",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},_initCanvas:function(){var t=this._canvas=L.DomUtil.create("canvas","leaflet-heatmap-layer leaflet-layer"),i=L.DomUtil.testProp(["transformOrigin","WebkitTransformOrigin","msTransformOrigin"]);t.style[i]="50% 50%";var a=this._map.getSize();t.width=a.x,t.height=a.y;var s=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(t,"leaflet-zoom-"+(s?"animated":"hide")),this._heat=simpleheat(t),this._updateOptions()},_updateOptions:function(){this._heat.radius(this.options.radius||this._heat.defaultRadius,this.options.blur),this.options.gradient&&this._heat.gradient(this.options.gradient),this.options.max&&this._heat.max(this.options.max)},_reset:function(){var t=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,t);var i=this._map.getSize();this._heat._width!==i.x&&(this._canvas.width=this._heat._width=i.x),this._heat._height!==i.y&&(this._canvas.height=this._heat._height=i.y),this._redraw()},_redraw:function(){var t,i,a,s,e,n,h,o,r,d=[],_=this._heat._r,l=this._map.getSize(),m=new L.Bounds(L.point([-_,-_]),l.add([_,_])),c=void 0===this.options.max?1:this.options.max,u=void 0===this.options.maxZoom?this._map.getMaxZoom():this.options.maxZoom,f=1/Math.pow(2,Math.max(0,Math.min(u-this._map.getZoom(),12))),g=_/2,p=[],v=this._map._getMapPanePos(),w=v.x%g,y=v.y%g;for(t=0,i=this._latlngs.length;i>t;t++)if(a=this._map.latLngToContainerPoint(this._latlngs[t]),m.contains(a)){e=Math.floor((a.x-w)/g)+2,n=Math.floor((a.y-y)/g)+2;var x=void 0!==this._latlngs[t].alt?this._latlngs[t].alt:void 0!==this._latlngs[t][2]?+this._latlngs[t][2]:1;r=x*f,p[n]=p[n]||[],s=p[n][e],s?(s[0]=(s[0]*s[2]+a.x*r)/(s[2]+r),s[1]=(s[1]*s[2]+a.y*r)/(s[2]+r),s[2]+=r):p[n][e]=[a.x,a.y,r]}for(t=0,i=p.length;i>t;t++)if(p[t])for(h=0,o=p[t].length;o>h;h++)s=p[t][h],s&&d.push([Math.round(s[0]),Math.round(s[1]),Math.min(s[2],c)]);this._heat.data(d).draw(this.options.minOpacity),this._frame=null},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),a=this._map._getCenterOffset(t.center)._multiplyBy(-i).subtract(this._map._getMapPanePos());L.DomUtil.setTransform?L.DomUtil.setTransform(this._canvas,a,i):this._canvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(a)+" scale("+i+")"}}),L.heatLayer=function(t,i){return new L.HeatLayer(t,i)};
|
100
static/vendor/leaflet/js/leaflet-liveupdate.js
vendored
Normal file
100
static/vendor/leaflet/js/leaflet-liveupdate.js
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
L.Control.Liveupdate = L.Control.extend({
|
||||
|
||||
timer: false,
|
||||
|
||||
options: {
|
||||
position: 'topleft',
|
||||
title: {
|
||||
'false': 'Start live updates',
|
||||
'true': 'Stop live updates'
|
||||
},
|
||||
is_updating: true,
|
||||
update_map: false, // callback function
|
||||
interval: 10000
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
this.container = L.DomUtil.create('div', 'leaflet-control-liveupdate leaflet-bar leaflet-control');
|
||||
|
||||
this.link = L.DomUtil.create('a', 'leaflet-control-liveupdate-button leaflet-bar-part', this.container);
|
||||
this.link.href = '#';
|
||||
|
||||
this._map = map;
|
||||
this._setUpdating(this.options.is_updating);
|
||||
map.liveUpdateControl = this;
|
||||
|
||||
L.DomEvent.on(this.link, 'click', this._click, this);
|
||||
return this.container;
|
||||
},
|
||||
|
||||
_click: function (e) {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
L.DomEvent.preventDefault(e);
|
||||
this.toggleUpdating();
|
||||
},
|
||||
|
||||
_toggleTitle: function() {
|
||||
this.link.title = this.options.title[this.isUpdating()];
|
||||
},
|
||||
|
||||
isUpdating: function () {
|
||||
return this._isUpdating || false;
|
||||
},
|
||||
|
||||
_setUpdating: function (updating) {
|
||||
this._isUpdating = updating;
|
||||
if (updating) {
|
||||
L.DomUtil.addClass(this.container, 'leaflet-liveupdate-on');
|
||||
} else {
|
||||
L.DomUtil.removeClass(this.container, 'leaflet-liveupdate-on');
|
||||
}
|
||||
this._toggleTitle();
|
||||
},
|
||||
|
||||
toggleUpdating: function () {
|
||||
if (this.isUpdating ()) {
|
||||
this.stopUpdating ();
|
||||
a = 'stopped';
|
||||
}
|
||||
else {
|
||||
this.startUpdating ();
|
||||
a = 'started';
|
||||
}
|
||||
if (this._map.messagebox) {
|
||||
this._map.messagebox.show('Live updates ' + a);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
startUpdating: function () {
|
||||
|
||||
var map = this._map;
|
||||
var update_map = this.options.update_map;
|
||||
var _this = this;
|
||||
|
||||
this._setUpdating(true);
|
||||
update_map(this);
|
||||
this.timer = setInterval(function() {
|
||||
update_map(_this);
|
||||
}, this.options.interval);
|
||||
return this;
|
||||
},
|
||||
|
||||
stopUpdating: function () {
|
||||
this._setUpdating(false);
|
||||
clearInterval(this.timer);
|
||||
this.timer = false;
|
||||
return this;
|
||||
},
|
||||
|
||||
updateNow: function () {
|
||||
var update_map = this.options.update_map;
|
||||
update_map(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
L.control.liveupdate = function (options) {
|
||||
return new L.Control.Liveupdate(options);
|
||||
};
|
42
static/vendor/leaflet/js/leaflet.migrationLayer.js
vendored
Normal file
42
static/vendor/leaflet/js/leaflet.migrationLayer.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
!function(t){var i={calculateColor:function(t,i){if(0===t.indexOf("#")){var s=t.slice(1),a=parseInt(s.slice(0,2),16),e=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4),16)
|
||||
return"rgba("+a+","+e+","+r+","+i+")"}return/^rgb\(/.test(t)?t.replace(/rgb/,"rgba").replace(")",",")+i+")":t.split(",").splice(0,3).join(",")+i+")"}},s={forEach:function(t,i,s){if("function"==typeof Array.prototype.forEach)t.forEach(i,s)
|
||||
else for(var a=0,e=t.length;e>a;a++)i.apply(s,[t[a],a,t])},map:function(t,i,s){if("function"==typeof Array.prototype.map)return t.map(i,s)
|
||||
for(var a=[],e=0,r=t.length;r>e;e++)a[e]=i.apply(s,[t[e],e,t])
|
||||
return a}},a=function(){var t=function(t){this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.style=t.style,this.color=t.color,this.size=t.size,this.borderWidth=t.borderWidth,this.borderColor=t.borderColor}
|
||||
return t.prototype.draw=function(t){t.save(),t.translate(this.x,this.y),t.rotate(this.rotation),t.lineWidth=this.borderWidth||0,t.strokeStyle=this.borderColor||"#000",t.fillStyle=this.color||"#000",t.beginPath(),"circle"===this.style?t.arc(0,0,this.size,0,2*Math.PI,!1):"arrow"===this.style&&(t.moveTo(-this.size,-this.size),t.lineTo(this.size,0),t.lineTo(-this.size,this.size),t.lineTo(-this.size/4,0),t.lineTo(-this.size,-this.size)),t.closePath(),t.stroke(),t.fill(),t.restore()},t}(),e=function(){var t=function(t){var i=t.startX,s=t.startY,a=t.endX,e=t.endY,r=Math.sqrt(Math.pow(i-a,2)+Math.pow(s-e,2)),o=(i+a)/2,n=(s+e)/2,h=1.5,l=(s-e)*h+o,d=(a-i)*h+n,c=Math.sqrt(Math.pow(r/2,2)+Math.pow(r*h,2)),p=Math.atan2(s-d,i-l),u=Math.atan2(e-d,a-l)
|
||||
this.startX=i,this.startY=s,this.endX=a,this.endY=e,this.centerX=l,this.centerY=d,this.startAngle=p,this.endAngle=u,this.startLabel=t&&t.labels&&t.labels[0],this.endLabel=t&&t.labels&&t.labels[1],this.radius=c,this.lineWidth=t.width||1,this.strokeStyle=t.color||"#000",this.label=t.label,this.font=t.font,this.shadowBlur=t.shadowBlur}
|
||||
return t.prototype.draw=function(t){if(t.save(),t.lineWidth=this.lineWidth,t.strokeStyle=this.strokeStyle,t.shadowColor=this.strokeStyle,t.shadowBlur=this.shadowBlur||2,t.beginPath(),t.arc(this.centerX,this.centerY,this.radius,this.startAngle,this.endAngle,!1),t.stroke(),t.restore(),t.save(),t.fillStyle=this.strokeStyle,this.label){if(t.font=this.label,this.startLabel){var i=this.startX-15,s=this.startY+5
|
||||
t.fillText(this.startLabel,i,s)}if(this.endLabel){var i=this.endX-15,s=this.endY-5
|
||||
t.fillText(this.endLabel,i,s)}}t.restore()},t}(),r=function(){function t(t){this.x=t.x,this.y=t.y,this.maxRadius=t.radius,this.color=t.color,this.shadowBlur=5,this.lineWidth=t.borderWidth,this.r=0,this.factor=2/t.radius}return t.prototype.draw=function(t){var s=.5
|
||||
this.r+=s,t.save(),t.translate(this.x,this.y)
|
||||
var a=this.color
|
||||
a=i.calculateColor(a,1-this.r/this.maxRadius),t.strokeStyle=a,t.shadowBlur=this.shadowBlur,t.shadowColor=a,t.lineWidth=this.lineWidth,t.beginPath(),t.arc(0,0,this.r,0,2*Math.PI,!1),t.stroke(),t.restore(),Math.abs(this.maxRadius-this.r)<.8&&(this.r=0)},t}(),o=function(){var t=function(t){var i=t.startX,s=t.startY,e=t.endX,r=t.endY,o=Math.sqrt(Math.pow(i-e,2)+Math.pow(s-r,2)),n=(i+e)/2,h=(s+r)/2,l=1.5,d=(s-r)*l+n,c=(e-i)*l+h,p=Math.sqrt(Math.pow(o/2,2)+Math.pow(o*l,2)),u=Math.atan2(s-c,i-d),f=Math.atan2(r-c,e-d)
|
||||
0>u*f&&(0>u?(u+=2*Math.PI,f+=2*Math.PI):f+=2*Math.PI),this.tailPointsCount=50,this.centerX=d,this.centerY=c,this.startAngle=u,this.endAngle=f,this.radius=p,this.lineWidth=t.width||1,this.strokeStyle=t.color||"#fff",this.factor=2/this.radius,this.deltaAngle=80/Math.min(this.radius,400)/this.tailPointsCount,this.trailAngle=this.startAngle,this.arcAngle=this.startAngle,this.animateBlur=!0,this.marker=new a({x:50,y:80,rotation:50*Math.PI/180,style:"arrow",color:"rgb(255, 255, 255)",size:3,borderWidth:0,borderColor:this.strokeStyle})}
|
||||
return t.prototype.drawArc=function(t,i,s,a,e){t.save(),t.lineWidth=s,t.strokeStyle=i,t.shadowColor=this.strokeStyle,t.lineCap="round",t.beginPath(),t.arc(this.centerX,this.centerY,this.radius,a,e,!1),t.stroke(),t.restore()},t.prototype.draw=function(t){var s=this.endAngle,a=this.trailAngle+this.factor,e=this.strokeStyle
|
||||
this.animateBlur&&(this.arcAngle=a),this.trailAngle=a,e=i.calculateColor(e,.1),this.drawArc(t,e,this.lineWidth,this.startAngle,this.arcAngle)
|
||||
for(var r=this.tailPointsCount,o=0;r>o;o++){var n=i.calculateColor(this.strokeStyle,.3-.3/r*o),h=5
|
||||
this.trailAngle-this.deltaAngle*o>this.startAngle&&this.drawArc(t,n,h-h/r*o,this.trailAngle-this.deltaAngle*o,this.trailAngle)}t.save(),t.translate(this.centerX,this.centerY),this.marker.x=Math.cos(this.trailAngle)*this.radius,this.marker.y=Math.sin(this.trailAngle)*this.radius,this.marker.rotation=this.trailAngle+Math.PI/2,this.marker.draw(t),t.restore(),180*(s-this.trailAngle)/Math.PI<.5&&(this.trailAngle=this.startAngle,this.animateBlur=!1)},t}(),n=function(){var i=function(t){this.data=t.data,this.store={arcs:[],markers:[],pulses:[],sparks:[]},this.playAnimation=!0,this.started=!1,this.context=t.context,this.style=t.style,this.init()}
|
||||
return i.prototype.init=function(){this.updateData(this.data)},i.prototype.add=function(t){},i.prototype.remove=function(){},i.prototype.clear=function(){this.store={arcs:[],markers:[],pulses:[],sparks:[]},this.playAnimation=!0,this.started=!1,t.cancelAnimationFrame(this.requestAnimationId)},i.prototype.updateData=function(t){t&&0!==t.length&&(this.clear(),this.data=t,this.data&&this.data.length>0&&s.forEach(this.data,function(t){var i=new e({startX:t.from[0],startY:t.from[1],endX:t.to[0],endY:t.to[1],labels:t.labels,label:this.style.arc.label,font:this.style.arc.font,width:this.style.arc.width,color:t.color}),s=new a({x:t.to[0],y:t.to[1],rotation:i.endAngle+Math.PI/2,style:"arrow",color:t.color,size:4,borderWidth:0,borderColor:t.color}),n=new r({x:t.to[0],y:t.to[1],radius:this.style.pulse.radius,color:t.color,borderWidth:this.style.pulse.borderWidth}),h=new o({startX:t.from[0],startY:t.from[1],endX:t.to[0],endY:t.to[1],width:15,color:t.color})
|
||||
this.store.arcs.push(i),this.store.markers.push(s),this.store.pulses.push(n),this.store.sparks.push(h)},this))},i.prototype.start=function(i){var s=this
|
||||
this.started||(!function a(){if(s.requestAnimationId=t.requestAnimationFrame(a,i),s.playAnimation){i.width+=1,i.width-=1
|
||||
for(var e in s.store)for(var r=s.store[e],o=0,n=r.length;n>o;o++)r[o].draw(s.context)}}(),this.started=!0)},i.prototype.play=function(){this.playAnimation=!0},i.prototype.pause=function(){this.playAnimation=!1},i}()
|
||||
L.MigrationLayer=L.Class.extend({options:{map:{},data:{},pulseRadius:25,pulseBorderWidth:3,arcWidth:1,arcLabel:!0,arcLabelFont:"15px sans-serif",Marker:{},Spark:{}},_setOptions:function(t,i){t.hasOwnProperty("options")||(t.options=t.options?L.Util.create(t.options):{})
|
||||
for(var s in i)t.options[s]=i[s]
|
||||
return t.options},initialize:function(t){this._setOptions(this,t),this._map=this.options.map||{},this._data=this.options.data||{},this._style={pulse:{radius:this.options.pulseRadius,borderWidth:this.options.pulseBorderWidth},arc:{width:this.options.arcWidth,label:this.options.arcLabel,font:this.options.arcLabelFont}}||{},this._show=!0,this._init()},_init:function(){var t=L.DomUtil.create("div","leaflet-ODLayer-container")
|
||||
if(t.style.position="absolute",t.style.width=this._map.getSize().x+"px",t.style.height=this._map.getSize().y+"px",this.container=t,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),t.appendChild(this.canvas),this._map.getPanes().overlayPane.appendChild(t),!this.migration){var i=this._convertData()
|
||||
this.migration=new n({data:i,context:this.context,style:this._style})}},_resize:function(){var i=this._map.getBounds(),s=i.getNorthWest(),a=this._map.latLngToContainerPoint(s)
|
||||
a.y>0?this.container.style.top=-a.y+"px":this.container.style.top="0px"
|
||||
var e=t.getComputedStyle(this._map.getContainer())
|
||||
this.canvas.setAttribute("width",parseInt(e.width,10)),this.canvas.setAttribute("height",parseInt(e.height,10))},_convertData:function(){var t=this._map.getBounds()
|
||||
if(this._data&&t){var i=s.map(this._data,function(t){var i=this._map.latLngToContainerPoint(new L.LatLng(t.from[1],t.from[0])),s=this._map.latLngToContainerPoint(new L.LatLng(t.to[1],t.to[0]))
|
||||
return{from:[i.x,i.y],to:[s.x,s.y],labels:t.labels,value:t.value,color:t.color}},this)
|
||||
return i}},_bindMapEvents:function(){var t=this
|
||||
this._map.on("moveend",function(){t.migration.play(),t._draw()}),this._map.on("zoomstart ",function(){t.container.style.display="none"}),this._map.on("zoomend",function(){t._show&&(t.container.style.display="",t._draw())})},_draw:function(){var t=this._map.getBounds()
|
||||
if(t&&this.migration.playAnimation){this._resize(),this._transform()
|
||||
var i=this._convertData()
|
||||
this.migration.updateData(i),this.migration.start(this.canvas)}},_transform:function(){var t=this._map.getBounds(),i=this._map.latLngToLayerPoint(t.getNorthWest())
|
||||
L.DomUtil.setPosition(this.container,i)},addTo:function(){this._bindMapEvents()
|
||||
var t=this._map.getBounds()
|
||||
if(t&&this.migration.playAnimation){this._resize(),this._transform()
|
||||
var i=this._convertData()
|
||||
this.migration.updateData(i),this.migration.start(this.canvas)}},setData:function(t){this._data=t,this._draw()},hide:function(){this.container.style.display="none",this._show=!1},show:function(){this.container.style.display="",this._show=!0},play:function(){this.migration.play()},pause:function(){this.migration.pause()},destroy:function(){this.migration.clear(),this.container.parentNode.removeChild(this.container),this._map.clearAllEventListeners(),this.mapHandles=[]}}),L.migrationLayer=function(t){return new L.MigrationLayer(t)}}(window)
|
Reference in New Issue
Block a user