2

I have a TMS layer that looks something like this:

var v = 1;
my_tms = new OpenLayers.Layer.TMS(
    "My TMS",
    "my_mapserver.php?v="+my_var+"&",
     { transparent: 'true', type:'png', getURL:get_my_url }
);

Where my_mapserver.php returns map tiles according to the value of v.

The app allows users to change v, and I simply want to refresh the my_tms layer, however, so far the only way I can get it to refresh is by destroying the map and recreating it.

I thought I could just do something like this:

v = 2;
my_tms = new OpenLayers.Layer.TMS(
    "My TMS",
    "my_mapserver.php?v="+my_var+"&",
     { transparent: 'true', type:'png', getURL:get_my_url }
);
my_tms.redraw();

However, these tiles are not getting requested when I redraw().

Any help is appreciated.

Paul
  • 80
  • 1
  • 6

2 Answers2

1

As TMS layers inherits from Grid layer you could try to call clearGrid() method to remove all existing tiles and then spiralTileLoad() to load new ones.

igorti
  • 3,828
  • 3
  • 22
  • 29
  • Thank you! I found I did not need clearGrid(), but rather just my_tms.url = "my_mapserver.php?v="+my_var+"&"; my_tms.spiralTileLoad(); my_tms.redraw(); – Paul Feb 10 '11 at 17:25
0

layer.redraw();, OpenLayers.Strategy.Refresh and clearGrid() didn't help me in reloading tiles of OpenLayers.Layer.TMS layer in OpenLayers 2.13.1, but helped:

layer.mergeNewParams({});
rutsky
  • 3,900
  • 2
  • 31
  • 30