3

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 :

olmap.addLayer(nameofthelayer);
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 12, 2014 at 10:24
0

1 Answer 1

4

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
}); 
answered Jun 12, 2014 at 12:16
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.