I have a map with 4-5 vectors. At the beginning, the loading of the web application is very very slow, but was fine before I've added a new one vector, which is used only for little zooms.

Is it possible to launch the loading of a vector only when the specific zoom is reached?

I'm currently using OpenLayers 2.2, and as a beginner in OpenLayers, the only way I found to load a vector was like this:

var olmap = new ol.Map({
    layers: [
        new ol.layer.Tile({
            source: new ol.source.OSM({
                url: 'php/map/getOsm.php?z={z}&x={x}&y={y}'
        }), vector, vector_country, vector_countryName, vector_term, vector_port, vector_ramp
    renderer: ol.RendererHint.CANVAS,
    overlays: [overlay],
    controls: ol.control.defaults().extend([
        new ol.control.FullScreen(), new app.CustomExport()
    view: mapView

That was quite easy :


1 Answer 1


This may or may not help you. You could try the Map zoomend event and then do what you desire when the zoom level changes.

MAP.events.register("zoomend", this, function(e) {
var zoom = MAP.getZoom();
    // do something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.