I discovered that Openlayers is loading tiles that are out of the defined map width/height and the restricted extend of the preset. Using TMS Base Layer, but the same is true for the standard OSM Base Layer.

This results in massive loading of unneeded/invisible/404 images, bloating page size and loading time. Is this indeed intended behavior or can the loading of tiles outside the viewable map be restricted somehow?

I could imagine both behaviors having their use cases, but for me it would be essential to get initial page load to an acceptable minimum. A config option would therefore be perfect.

Comments

zzolo’s picture

Component: Layers » OL API

Hi @heliogabal. This is a good idea. HAve you tried restricting the extent of the map?

If this does not fix it, the first step in this would be how to do this in OL and then translate it to this module. We won't try to build this feature in this module. Patches welcome.

heliogabal’s picture

Hi @zzolo, thanks for answering, and sorry for getting back to you so late, I thought I'd get a notification if there was an answer, so I just see your response now.

Yes, I'm restricting the extent of the map, but I think I found the reason why the tiles outside of the extent are getting loaded: the buffer parameter defaults to 2, setting "the amount of tiles that exist outside the visible area of the map" (http://trac.osgeo.org/openlayers/wiki/OpenLayersOptimization)

For the WMS Layer type, this has been added to the Layer form as discussed here: http://drupal.org/node/810846 but this possibility is missing for the TMS Layer type. I'm not sure therefore if this issue should be renamed accordingly to "add 'buffer' params for TMS layers", if you think so, please go ahead. It's not exactly the solution to my problem, but it would be a useful option in cases like mine.

Unfortunately, I'm not a programmer and my tries to adapt the respective WMS code to the TMS Layer type failed, so I would be still thankful for any hints how to do this, or a patch I could test.

zzolo’s picture

Hey @heliogabal. Have you actually tried putting the buffer to 0? I dont think this is going to solve you problem exactly. It may still load the bad images if they are in the visible area.

heliogabal’s picture

Priority: Normal » Minor
Status: Active » Fixed

just to wrap this up after a long time... I finally solved my problem by adding
options.buffer = 0;
directly in includes/layer_types/tms.js

I tried to add this as an option to the module and create a patch, but failed and gave up - I have to learn to program eventually... But maybe this information will help someone else to add this option if it seems usefull, although I guess it's en edge case. So I think it is ok to close this issue. Thanks for responding @zzolo!

Pol’s picture

Status: Fixed » Needs work
ken-g’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)