简体   繁体   中英

Openlayers 5 How to watch for view.center changes

I'm currently working on a project to use openlayers 5's observable to observe some items in the map and respond accordingly.

http://openlayers.org/en/latest/apidoc/module-ol_Observable-Observable.html

What I want to do is every time the view's center changes, I want to call a function. I'm doing this currently (but its not working).

view.on('center', function(event){
    // do something with the center
});

Any tips?

Got it. I was missing the text "change".

view.on('change:center', function(){});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM