fixed bug with date order
getbounds now work
This commit is contained in:
parent
2c604a8279
commit
521ae23609
@ -9,11 +9,72 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
#control {
|
||||||
|
display:none;
|
||||||
|
z-index: 10;
|
||||||
|
position: absolute;
|
||||||
|
left: 10px;
|
||||||
|
bottom: 10px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: 0 0 4px rgba(0, 0, 0, .2);
|
||||||
|
padding: 8px;
|
||||||
|
margin: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#control:hover {
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
#control span {
|
||||||
|
display: block;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
vertical-align: middle;
|
||||||
|
position:relative
|
||||||
|
}
|
||||||
|
#control span.play:before {
|
||||||
|
content:"";
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
height: 10px;
|
||||||
|
width: 3px;
|
||||||
|
background: #666;
|
||||||
|
left: 2px;
|
||||||
|
top: 1px;
|
||||||
|
-webkit-border-radius: 4px;
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
#control span.play:after {
|
||||||
|
content:"";
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
height: 10px;
|
||||||
|
width: 3px;
|
||||||
|
background: #666;
|
||||||
|
right: 1px;
|
||||||
|
top: 1px;
|
||||||
|
-webkit-border-radius: 4px;
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#control span.pause:before {
|
||||||
|
content:"";
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
height: 0px;
|
||||||
|
width: 0px;
|
||||||
|
border: 6px solid transparent;
|
||||||
|
border-left: 8px solid #666;
|
||||||
|
left: 3px;
|
||||||
|
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<input type="file" id="files" name="files" />
|
<input type="file" id="files" name="files" />
|
||||||
<div id="map"></div>
|
<div id="map"><div id="control"><span class="play"></span></div></div>
|
||||||
|
|
||||||
<script src="vendor/leaflet.js"></script>
|
<script src="vendor/leaflet.js"></script>
|
||||||
<script src="vendor/papaparse.min.js"></script>
|
<script src="vendor/papaparse.min.js"></script>
|
||||||
@ -23,8 +84,8 @@
|
|||||||
<script>
|
<script>
|
||||||
var map = new L.Map('map', {
|
var map = new L.Map('map', {
|
||||||
zoomControl: true,
|
zoomControl: true,
|
||||||
center: [40, -100],
|
center: [40, 0],
|
||||||
zoom: 5
|
zoom: 6
|
||||||
});
|
});
|
||||||
|
|
||||||
L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
|
L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
|
||||||
@ -101,11 +162,11 @@
|
|||||||
'}'
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
var pointsToLoad = 1000;
|
var pointsToLoad = 50000;
|
||||||
|
|
||||||
var animationDuration = 60;
|
var animationDuration = 60;
|
||||||
var steps = pointsToLoad;
|
var steps = 2048;
|
||||||
var cumulative = true;
|
var cumulative = false;
|
||||||
var loop = true;
|
var loop = true;
|
||||||
var cartocss = CARTOCSS_NORMAL;
|
var cartocss = CARTOCSS_NORMAL;
|
||||||
|
|
||||||
@ -127,14 +188,25 @@
|
|||||||
complete: function (results) {
|
complete: function (results) {
|
||||||
for (var i = 1; i <= pointsToLoad && i < results.data.length; i++) {
|
for (var i = 1; i <= pointsToLoad && i < results.data.length; i++) {
|
||||||
var point = results.data[i];
|
var point = results.data[i];
|
||||||
torqueLayer.provider.addPoint(point[1], point[0], point[3], point[2]);
|
torqueLayer.provider.addPoint(point[2], point[1], point[0], point[3]);
|
||||||
}
|
}
|
||||||
torqueLayer.provider.setReady();
|
torqueLayer.provider.setReady();
|
||||||
|
document.getElementById('control').style.visibility = "visible";
|
||||||
torqueLayer.play();
|
torqueLayer.play();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
document.getElementById('files').addEventListener('change', handleFileSelect, false);
|
document.getElementById('files').addEventListener('change', handleFileSelect, false);
|
||||||
|
|
||||||
|
function handlePlayPause(evt) {
|
||||||
|
if (torqueLayer.isRunning()) {
|
||||||
|
torqueLayer.pause();
|
||||||
|
} else {
|
||||||
|
torqueLayer.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById('control').addEventListener('click', handlePlayPause, false);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -18,6 +18,11 @@ var internal = function (options) {
|
|||||||
}
|
}
|
||||||
this.points = [];
|
this.points = [];
|
||||||
this._tileQueue = [];
|
this._tileQueue = [];
|
||||||
|
this.options.bounds = [
|
||||||
|
[Number.MAX_VALUE, Number.MAX_VALUE],
|
||||||
|
[Number.MIN_VALUE, Number.MIN_VALUE]
|
||||||
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -46,9 +51,13 @@ internal.prototype = {
|
|||||||
|
|
||||||
this.points.sort(function (point1, point2) {
|
this.points.sort(function (point1, point2) {
|
||||||
if (self.timestampType == "number") {
|
if (self.timestampType == "number") {
|
||||||
return point1.value - point2.value;
|
return point1.time - point2.time;
|
||||||
} else {
|
} else {
|
||||||
return new Date(point1.value) - new Date(point2.value);
|
if (typeof(point1.time) == "string") {
|
||||||
|
return new Date(point1.time) - new Date(point2.time);
|
||||||
|
} else {
|
||||||
|
return point1.time - point2.time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,6 +112,13 @@ internal.prototype = {
|
|||||||
maxLon: maxs[0]
|
maxLon: maxs[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Update total bounds */
|
||||||
|
if (tile.latLonBounds.maxLat > this.options.bounds[1][0]) this.options.bounds[1][0] = tile.latLonBounds.maxLat;
|
||||||
|
if (tile.latLonBounds.minLat < this.options.bounds[0][0]) this.options.bounds[0][0] = tile.latLonBounds.minLat;
|
||||||
|
if (tile.latLonBounds.maxLon > this.options.bounds[1][1]) this.options.bounds[1][1] = tile.latLonBounds.maxLon;
|
||||||
|
if (tile.latLonBounds.minLon < this.options.bounds[0][1]) this.options.bounds[0][1] = tile.latLonBounds.minLon;
|
||||||
|
|
||||||
|
|
||||||
/* Function to find out if a point falls into this tile */
|
/* Function to find out if a point falls into this tile */
|
||||||
tile.contains = function (point) {
|
tile.contains = function (point) {
|
||||||
return point.lat < tile.latLonBounds.maxLat && point.lat > tile.latLonBounds.minLat && point.lon < tile.latLonBounds.maxLon && point.lon > tile.latLonBounds.minLon;
|
return point.lat < tile.latLonBounds.maxLat && point.lat > tile.latLonBounds.minLat && point.lon < tile.latLonBounds.maxLon && point.lon > tile.latLonBounds.minLon;
|
||||||
@ -170,7 +186,6 @@ internal.prototype = {
|
|||||||
var pointsInTileForFutureTimestamp = pointsInThisTileByTimestamp[futureTimestamps] || (pointsInThisTileByTimestamp[futureTimestamps] = []);
|
var pointsInTileForFutureTimestamp = pointsInThisTileByTimestamp[futureTimestamps] || (pointsInThisTileByTimestamp[futureTimestamps] = []);
|
||||||
pointsInTileForFutureTimestamp.push({idx: pointIdx, value: point.value});
|
pointsInTileForFutureTimestamp.push({idx: pointIdx, value: point.value});
|
||||||
}
|
}
|
||||||
console.log(pointsInThisTileByTimestamp.length);
|
|
||||||
} else {
|
} else {
|
||||||
var pointsInTileForThisTimestamp = pointsInThisTileByTimestamp[pointTimestamp] || (pointsInThisTileByTimestamp[pointTimestamp] = []);
|
var pointsInTileForThisTimestamp = pointsInThisTileByTimestamp[pointTimestamp] || (pointsInThisTileByTimestamp[pointTimestamp] = []);
|
||||||
pointsInTileForThisTimestamp.push({idx: pointIdx, value: point.value});
|
pointsInTileForThisTimestamp.push({idx: pointIdx, value: point.value});
|
||||||
|
Loading…
Reference in New Issue
Block a user