openlayers-3 , Openlayers 3: Change the vectors layers when the zoom level change

I'm a new user of Open-layers 3. I have my web page with layer OSM add by OL3, and I added any vectors layers(markers) by ol.layer.Vector. I need to change the vector layer when the zoom level changes. Please Layers have setVisible()/getVisible() methods, so you could trigger those on your layers at a particular zoom level. Zoom can be derived on 'moveend' events, then you can trigger whether a particular layer is visible or not. Zoom can be gotten from map.getView().getZoom() (will return the number that is the zoom), then tell the layer you need to either show or hide accordingly. Layers are held in an Collection(array) object and can be gotten via a map.getLayers() call, then you could choose which one to show/hide. When I add layers I record the order of them so I can get one directly. Source.

Яндекс.Метрика Рейтинг Free Web Counter
page counter
Last Modified: April 23, 2016 @ 7:01 pm