Putting the script tag at the end of the body (for demonstration purposes).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10725 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
<link rel="stylesheet" href="style.css" type="text/css">
|
<link rel="stylesheet" href="style.css" type="text/css">
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script>OpenLayers.ImgPath = "../img/";</script>
|
<script>OpenLayers.ImgPath = "../img/";</script>
|
||||||
<script src="filter-strategy.js"></script>
|
|
||||||
<style>
|
<style>
|
||||||
.olControlAttribution {
|
.olControlAttribution {
|
||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body>
|
||||||
<h1 id="title">Filter Strategy</h1>
|
<h1 id="title">Filter Strategy</h1>
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
Demonstrates the filter strategy for limiting features passed to the layer.
|
Demonstrates the filter strategy for limiting features passed to the layer.
|
||||||
@@ -44,5 +43,6 @@
|
|||||||
source to see how this is done
|
source to see how this is done
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="filter-strategy.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,11 +1,40 @@
|
|||||||
var map, filter, filterStrategy;
|
var map, filter, filterStrategy;
|
||||||
|
var animationTimer;
|
||||||
|
var currentDate;
|
||||||
var startDate = new Date(1272736800000); // lower bound of when values
|
var startDate = new Date(1272736800000); // lower bound of when values
|
||||||
var endDate = new Date(1272737100000); // upper value of when values
|
var endDate = new Date(1272737100000); // upper value of when values
|
||||||
var step = 8; // sencods to advance each interval
|
var step = 8; // sencods to advance each interval
|
||||||
var interval = 0.125; // seconds between each step in the animation
|
var interval = 0.125; // seconds between each step in the animation
|
||||||
|
|
||||||
function init() {
|
function startAnimation() {
|
||||||
|
if (animationTimer) {
|
||||||
|
stopAnimation(true);
|
||||||
|
}
|
||||||
|
if (!currentDate) {
|
||||||
|
currentDate = startDate;
|
||||||
|
}
|
||||||
|
var spanEl = document.getElementById("span");
|
||||||
|
var next = function() {
|
||||||
|
var span = parseInt(spanEl.value, 10);
|
||||||
|
if (currentDate < endDate) {
|
||||||
|
filter.lowerBoundary = currentDate;
|
||||||
|
filter.upperBoundary = new Date(currentDate.getTime() + (span * 1000));
|
||||||
|
filterStrategy.setFilter(filter);
|
||||||
|
currentDate = new Date(currentDate.getTime() + (step * 1000))
|
||||||
|
} else {
|
||||||
|
stopAnimation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
animationTimer = window.setInterval(next, interval * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopAnimation(reset) {
|
||||||
|
window.clearInterval(animationTimer);
|
||||||
|
animationTimer = null;
|
||||||
|
if (reset === true) {
|
||||||
|
currentDate = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add behavior to elements
|
// add behavior to elements
|
||||||
document.getElementById("start").onclick = startAnimation;
|
document.getElementById("start").onclick = startAnimation;
|
||||||
@@ -53,37 +82,3 @@ function init() {
|
|||||||
map.addLayers([osm, flights]);
|
map.addLayers([osm, flights]);
|
||||||
map.setCenter(new OpenLayers.LonLat(-93.2735, 44.8349).transform(geographic, mercator), 8);
|
map.setCenter(new OpenLayers.LonLat(-93.2735, 44.8349).transform(geographic, mercator), 8);
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
var animationTimer;
|
|
||||||
var currentDate;
|
|
||||||
function startAnimation() {
|
|
||||||
if (animationTimer) {
|
|
||||||
stopAnimation(true);
|
|
||||||
}
|
|
||||||
if (!currentDate) {
|
|
||||||
currentDate = startDate;
|
|
||||||
}
|
|
||||||
var spanEl = document.getElementById("span");
|
|
||||||
var next = function() {
|
|
||||||
var span = parseInt(spanEl.value, 10);
|
|
||||||
if (currentDate < endDate) {
|
|
||||||
filter.lowerBoundary = currentDate;
|
|
||||||
filter.upperBoundary = new Date(currentDate.getTime() + (span * 1000));
|
|
||||||
filterStrategy.setFilter(filter);
|
|
||||||
currentDate = new Date(currentDate.getTime() + (step * 1000))
|
|
||||||
} else {
|
|
||||||
stopAnimation(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
animationTimer = window.setInterval(next, interval * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopAnimation(reset) {
|
|
||||||
window.clearInterval(animationTimer);
|
|
||||||
animationTimer = null;
|
|
||||||
if (reset === true) {
|
|
||||||
currentDate = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user