2

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

1 Answer 1

0

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

2
  • 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.
    – gis_wild
    Commented Jan 22, 2014 at 23:35
  • and getFullRequestString can't change url, too
    – gis_wild
    Commented Jan 23, 2014 at 0:21

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.