Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to be able to change the url for a layer in code.

The reasons is that I am implementing local caching.

When local caching is Not enabled, we use 4 servers to deliver tiles to run parallel http requests.

However, when the caching is enabled, it caches tiles for the four servers. There is no guarantee that the request for the same tile will be for the same server, so, potentially, the local cache may end up four times the size it needs to be. (and four copies of the same tile will be in the cache)

To counter this, we have set up another server to be used only for users who are using the local cache to guarantee that the cache will always return a tile if it is there (simply because the server is always the same)

I have experimented with layer.getFullRequestString( { }, url );

I am able to actually retrieve the request string if I use this syntax:

layer.getFullRequestString( { } ) (note, it errors if you do not put the {} )

but have not been able to actually cause a change in the layers fetch url. The function seems to ignore the supplied url completely.

I have tried a single url and a url array to no avail.

Openlayers Documenmtation is as follows:

getFullRequestString:function(  newParams, altUrl   ) Combine the layer’s url with its params and these newParams.

Add the SRS parameter from projection -- this is probably more eloquently done via a setProjection() method, but this works for now and always.

Parameters newParams {Object} altUrl {String} Use this as the url instead of the layer’s url Returns {String}

Any thoughts or better ways to address this very much appreciated

Thanks

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Ok, we ended up deleting the layer and receating it with the new Url's and keeping current position and zoom levels. works Ok. We can toggle back and forward between the two ok

share|improve this answer
 
and what about memory leaking? I tried this approach but it seems that GC doesn't work as supposed if I create new layer every time. mergeNewParams() works better with the memory, but it can't change the url. –  dementiev Jan 22 at 23:35
 
and getFullRequestString can't change url, too –  dementiev Jan 23 at 0:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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