When provided with a url, the GeoJSON vector layer type currently calls OpenLayers.loadURL() and then proceeds to manually parse the response and add it to a map. This is functional but it doesn't take advantage of some of the things OpenLayers will do for you automatically.

In my case, I only want the data for the layer to be requested if it's needed (when a user enables the layer via the layerswitcher), not on every page load. The current method will send out an ajax request (via OpenLayers.loadURL()) as soon as the code is executed - on page load.

I have attached a patch that lets OpenLayers only request the data from the url when it is needed - eg: when the layer is made visible. If the layer is visible by default, then every thing will continue to function normally. If the layer isn't visible initially (can be enabled via the layerswitcher) then no request for the data is made until it is needed.

There are two patches, one for the beta1 release (which I am using) and one for 2.x dev.

Comments

pol’s picture

Status: Active » Needs review
pol’s picture

Status: Needs review » Needs work

The last submitted patch, openlayers_geojson_vector_layer_async_7.x-2.x.patch, failed testing.

pol’s picture

Assigned: Unassigned » pol