[OpenLayers-Users] Re: Legend not updating on changelayer and
moveend
jasonHo
sk1 at sk1consulting.com
Tue Sep 27 11:14:58 EDT 2011
Emailed some local colleagues, got this response back which solved my
problem:
Just a guess, but I bet the legend div updates when it detects a change to
the legendUrl field. When the legendurl is set in the moveend and
changelayer, it looks like this:
legLyrStore.data.items[2].set("legendURL",
"http://floodatlas.org/geoserver/wcmp/wms?FORMAT=image/gif&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=wcmp:LM_2007_backshoreclass&SCALE="
+ map.getScale());
The important bit there is the map.getScale(). Since you haven't zoomed in
or out, the map scale hasn't changed, and therefore the legendUrl doesn't
change, and the legend doesn't update. Once you zoom, the scale changes, the
url changes, and the legend updates.
A quick and dirty fix might be to add a random number to the url you are
using there, like:
legLyrStore.data.items[2].set("legendURL",
"http://floodatlas.org/geoserver/wcmp/wms?FORMAT=image/gif&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=wcmp:LM_2007_backshoreclass&SCALE="
+ map.getScale() + "&random=" + Math.random() );
Hope that helps!
Cheers,
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Legend-not-updating-on-changelayer-and-moveend-tp6833360p6836296.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list