有两个思路;一个是动态样式,一个是事件监听更改样式。
change:resolution事件监听更改样式
1 map.getView().on('change:resolution',checkZoom);//checkZoom为调用的函数
2
3 function checkZoom() {
4 // alert("1");
5 // var childId;
6 console.log(map.getView().getZoom());
7 if (map.getView().getZoom() == 11) {
8 // console.log(vector.getSource().getFeatures()[0].getProperties().CODE);
9 // childId = vector.getSource().getFeatures()[0].getProperties().CODE;
10 // vector.setVisible(false);
11 lastVectorShow();
12
13 }
14 }
动态样式
https://stackoom.com/question/3qROp
温馨提示:将鼠标放在语句上可以显示对应的英文。 或者 切换至中英