I have whipped up a demo where I am using OL to serve up a simple,
single-tile MapServer layer.  My goal is to display a legend in an
adjacent div using a mode=legend call to MapServer.  I almost have it
working, but the synchronization is a little off.  My test is that I
have a scale-dependent layer in my map file and I am watching when the
this layer gets added to the legend.  I am wondering if I am listening
for the wrong event.

I am listening for the 'moveend' event, grabbing the bounds and using
it to construct the legend call.  Here is my (admitedly verbose) code.

map.events.register("moveend", map, function(e) {
            var bounds = map.getExtent();
            var boundsArr = bounds.toArray();
            var currentExtent =
boundsArr[0]+'+'+boundsArr[1]+'+'+boundsArr[2]+'+'+boundsArr[3];
            
document.getElementById('legend_box').getElementsByTagName('img')[0].src="http://localhost/cgi-bin/mapserv?mode=legend&map=/Users/david/backendmaps/roads/roads_ol.map&mapext=";
+ currentExtent;

The legend is updating, but when the new layer appears on the map, it
doesn't often show up in the legend until the next zoom.

I see that the bbox value returned by getExtent is not the same as the
bbox values that OL plugs into the map request to MapServer.  I assume
that this is because getExtent() is giving the value for the visible
map, not the whole image being requested.

This leads me to two questions:

1.  If I am zooming in/out on a map is 'moveend' the correct  event to
listen for if I want to grab the extent of the image being requested?

2.   If so, is getExtent() the right call to get the extent of the new
image being requested?

Thanks,

David.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to