Fix feature-animation example migrating map postcompose event
This commit is contained in:
committed by
Tim Schaub
parent
3bf9a54ed5
commit
a924834920
@@ -8,16 +8,16 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
|||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
|
import {OSM, Vector as VectorSource} from '../src/ol/source.js';
|
||||||
import {Circle as CircleStyle, Stroke, Style} from '../src/ol/style.js';
|
import {Circle as CircleStyle, Stroke, Style} from '../src/ol/style.js';
|
||||||
|
import {getVectorContext} from '../src/ol/render';
|
||||||
|
|
||||||
|
const tileLayer = new TileLayer({
|
||||||
const map = new Map({
|
|
||||||
layers: [
|
|
||||||
new TileLayer({
|
|
||||||
source: new OSM({
|
source: new OSM({
|
||||||
wrapX: false
|
wrapX: false
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
],
|
|
||||||
|
const map = new Map({
|
||||||
|
layers: [tileLayer],
|
||||||
target: 'map',
|
target: 'map',
|
||||||
view: new View({
|
view: new View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
@@ -44,10 +44,10 @@ function addRandomFeature() {
|
|||||||
const duration = 3000;
|
const duration = 3000;
|
||||||
function flash(feature) {
|
function flash(feature) {
|
||||||
const start = new Date().getTime();
|
const start = new Date().getTime();
|
||||||
const listenerKey = map.on('postcompose', animate);
|
const listenerKey = tileLayer.on('postrender', animate);
|
||||||
|
|
||||||
function animate(event) {
|
function animate(event) {
|
||||||
const vectorContext = event.vectorContext;
|
const vectorContext = getVectorContext(event);
|
||||||
const frameState = event.frameState;
|
const frameState = event.frameState;
|
||||||
const flashGeom = feature.getGeometry().clone();
|
const flashGeom = feature.getGeometry().clone();
|
||||||
const elapsed = frameState.time - start;
|
const elapsed = frameState.time - start;
|
||||||
|
|||||||
Reference in New Issue
Block a user