Reputation: 545
I have some custom svg layers rendered "on top" of openlayers 3 using d3.js, which works fine. During the postrender-event I translate and update coordinates of my layers which, again, work fine.
For some layers I do, however, want to scale the visual objects based on zoom levels. I have a working solution based on map.getView().getResolution() but it's not perfectly smooth as, during zooming, getResolution() returns the same resolution until the transition is done.
Is there any way to get an update on the exact resolution during the zooming?
Upvotes: 2
Views: 1271
Reputation: 3142
map.on('postrender', function(event){
console.log(event.frameState.viewState.resolution);
});
The viewState object contains the current resolution
, center
, rotation
and projection
of the View.
Relevant docs: http://openlayers.org/en/v3.8.2/apidoc/ol.MapEvent.html, http://openlayers.org/en/v3.8.2/apidoc/olx.html#FrameState, http://openlayers.org/en/v3.8.2/apidoc/olx.html#ViewState
Upvotes: 3