Если я вас правильно понимаю, это может сработать,
let updateViewExtent = function (pixel, level) {
this['vectorLayer' + level].getFeatures(event.pixel).then((features) => {
if (features.length > 0) {
return;
}
const feature = features[0];
if (!feature) {
return;
}
// zoom to feature clicked (here just first feature)
this.map.getView().fit(feature.getGeometry().getExtent(), {size: this.map.getSize()});
}
this.map.on('singleclick', (event) => {
// if this is the lower level return
if (this.MapLevel === LOWERLEVEL) {
return;
}
// zoom to the clicked feature of the level
updateViewExtent(event.pixel, this.MapLevel);
// update map level and layers visibility
this['vectorLayer' + this.MapLevel].setVisible(false);
this.MapLevel += 1;
this['vectorLayer' + this.MapLevel].setVisible(true);
});
this.map.on('dblclick', (event) => {
// if this is the upper level return
if (this.MapLevel === UPPERLEVEL) {
return;
}
// zoom to the clicked feature of the upper level
updateViewExtent(event.pixel, this.MapLevel - 1);
// update map level and layers visibility
this['vectorLayer' + this.MapLevel].setVisible(false);
this.MapLevel -= 1;
this['vectorLayer' + this.MapLevel].setVisible(true);
});
Я использую функцию для увеличения масштаба желаемого, в данном случае - нажатую функцию. На самом деле может случиться так, что это больше, чем просто функция, вы можете увеличить масштаб. Если вы действительно хотите увеличить масштаб слоя до двойного щелчка, тогда вместо вызова функции просто используйте это,
// zoom upper layer extent
this.map.getView().fit(
this['vectorLayer' + (this.MapLevel - 1)].getSource().getExtent(),
{size: this.map.getSize()}
);
Наконец, вам может потребоваться отменить поведение карты по умолчанию при двойном щелчке (увеличить на одном уровне).