Fix flight-animation example with postrender event
This commit is contained in:
committed by
Tim Schaub
parent
45cd573768
commit
4d54549b5f
@@ -6,14 +6,17 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
|||||||
import Stamen from '../src/ol/source/Stamen.js';
|
import Stamen from '../src/ol/source/Stamen.js';
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
import VectorSource from '../src/ol/source/Vector.js';
|
||||||
import {Stroke, Style} from '../src/ol/style.js';
|
import {Stroke, Style} from '../src/ol/style.js';
|
||||||
|
import {getVectorContext} from '../src/ol/render';
|
||||||
|
|
||||||
|
const tileLayer = new TileLayer({
|
||||||
|
source: new Stamen({
|
||||||
|
layer: 'toner'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
tileLayer
|
||||||
source: new Stamen({
|
|
||||||
layer: 'toner'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new View({
|
||||||
@@ -63,7 +66,7 @@ const flightsSource = new VectorSource({
|
|||||||
addLater(feature, i * 50);
|
addLater(feature, i * 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.on('postcompose', animateFlights);
|
tileLayer.on('postrender', animateFlights);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -85,7 +88,7 @@ map.addLayer(flightsLayer);
|
|||||||
|
|
||||||
const pointsPerMs = 0.1;
|
const pointsPerMs = 0.1;
|
||||||
function animateFlights(event) {
|
function animateFlights(event) {
|
||||||
const vectorContext = event.vectorContext;
|
const vectorContext = getVectorContext(event);
|
||||||
const frameState = event.frameState;
|
const frameState = event.frameState;
|
||||||
vectorContext.setStyle(style);
|
vectorContext.setStyle(style);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user