Reputation: 83
We are using openlayer 6.3.1 und want to use "postrender" event from Layer Api, but it does not work right.
The code is like this:
vectorLayer.on("postrender", this.moveFeature);
......
moveFeature: function (event) {
console.log(event);
...
The console log message will not show.
But if i change the code to:
vectorLayer.on("postrender", console.log("test"));
the log message "test" will be shown in console,
If i change the code to:
vectorLayer.on("postrender", function(evt) {
console.log(evt);
});
there is also no console messages, what could be the problem? Our project is backbone basis, and we use many backbone event, i dont know if it make some troubles.
Upvotes: 3
Views: 710
Reputation: 99
Your layer is probably already rendered. You can call render
on the map after declaring your event.
function animate(event) {
// your logic here
// Rerender to loop
map.render();
}
this.vectorLayer.on('postrender', animate);
map.render();
Upvotes: 0