Это проектact.js с OpenLayers 5.3.0
Карта определена в
componentDidUpdate() {
this.map = new Map({
target: this.container,
view: new View({
center: [2.5, 2.5],
projection: projection,
zoom: 2,
minZoom: 0.1,
maxZoom: 7
}),
interactions: defaultInteractions({
// dragPan: false,
keyboard: false,
// mouseWheelZoom: false,
doubleClickZoom :false
}),
layers: [graphic, this.roadLayer, this.robotLayer, this.laserLayer, this.targetLayer, this.restrictLayer, this.specialLayer]
});
view=this.map.getView();
zoom=view.getZoom();
view.on('change:resolution',function(e){
console.log('change:resolution');// dosen't work
});
view.on('change:center',function(e){
console.log('moveing');
});
this.map.on('moveend',function(e){
console.log(view);
zoom = view.getZoom();
// console.log("resolution", view.getResolution()); // Always the same
// console.log('moveend');
console.log("zoom"+zoom); // Always 2
if(view.getZoom()!==zoom)
console.log('zomeend了,change:zoom了');
});
};
Проблема в том, что когда я масштабирую карту, изменяюсь: разрешение не будетсрабатывание и масштабирование всегда будет 2 в качестве начального значения. Я также попытался поместить map.on ('moveend') в подобный componentDidMount (), тот же результат.
Почему я не могу получить текущий Zoom?
Это проблема жизненного круга? реагировать? Любая подсказка будет огромной помощью.