<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">I still haven't figured out what the problem really is, but it seems to work if I don't zoom just before switching layers (i.e. remove all the zoomToExtent(..) calls). Is there any way to wait for a zoom to finish?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Thanks,<br>
   Peter<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>On Mon, 7 Sep 2009 09:13:36 am Peter Becker wrote:<br>
&gt; Hello all,<br>
&gt;<br>
&gt; I'm trying to use Vector layers based on WFS and I am encountering issues<br>
&gt; with the layers not displaying straight away. To display them properly I<br>
&gt; need to remove them and add them again or call refresh().<br>
&gt;<br>
&gt; Here is what I do:<br>
&gt;<br>
&gt;         var propertyFilter = new OpenLayers.Filter.Comparison({<br>
&gt;             type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
&gt;             property: 'year',<br>
&gt;             value: 2009<br>
&gt;         });<br>
&gt;         subregions = new OpenLayers.Layer.Vector("Subregions", {<br>
&gt;             strategies: [new OpenLayers.Strategy.BBOX()],<br>
&gt;             filter: propertyFilter,<br>
&gt;             projection: new OpenLayers.Projection("EPSG:4326"),<br>
&gt;             styleMap: subregionStyle,<br>
&gt;             protocol: new OpenLayers.Protocol.WFS({<br>
&gt;                 url:  "&lt;@geoServerUrlTemplate/&gt;/wfs",<br>
&gt;                 featureType: "subregions_in_time",<br>
&gt;                 featureNS: "http://health-e-waterways.org"<br>
&gt;             })<br>
&gt;         });<br>
&gt;         // the next bit forces IE8 to show the overlay<br>
&gt;         subregions.events.register('loadend',subregions,function(e) {<br>
&gt;             map.removeLayer(subregions);<br>
&gt;             map.addLayer(subregions);<br>
&gt;         });<br>
&gt;         map.addLayer(subregions);<br>
&gt;<br>
&gt; Note the event hook, which fixes this layer for IE8 (it worked in Firefox<br>
&gt; out of the box). The same trick does not work if I swap in another layer<br>
&gt; later. I can't get this bit of code to work properly at all:<br>
&gt;<br>
&gt;     function focusOnSubregion(name) {<br>
&gt;         current_subregion=name;<br>
&gt;         if (current_subregion == 'Northern') {<br>
&gt;             map.zoomToExtent(northern_bounds);<br>
&gt;         } else if (current_subregion == 'Southern') {<br>
&gt;             map.zoomToExtent(southern_bounds);<br>
&gt;         } else if (current_subregion == 'Western') {<br>
&gt;             map.zoomToExtent(western_bounds);<br>
&gt;         } else if (current_subregion == 'Moreton Bay') {<br>
&gt;             map.zoomToExtent(moreton_bounds);<br>
&gt;         } else {<br>
&gt;             map.zoomToExtent(bounds);<br>
&gt;         }<br>
&gt;         var yearFilter = new OpenLayers.Filter.Comparison({<br>
&gt;             type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
&gt;             property: 'year',<br>
&gt;             value: 2009<br>
&gt;         });<br>
&gt;         var subRegionFilter = new OpenLayers.Filter.Comparison({<br>
&gt;             type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
&gt;             property: 'subregion',<br>
&gt;             value: name<br>
&gt;         });<br>
&gt;         var propertyFilter = new OpenLayers.Filter.Logical({<br>
&gt;             type: OpenLayers.Filter.Logical.AND,<br>
&gt;             filters: [yearFilter, subRegionFilter]<br>
&gt;         });<br>
&gt;         current_areas = new OpenLayers.Layer.Vector("Catchments", {<br>
&gt;             strategies: [new OpenLayers.Strategy.BBOX()],<br>
&gt;             filter: propertyFilter,<br>
&gt;             projection: new OpenLayers.Projection("EPSG:4326"),<br>
&gt;             styleMap: catchmentStyle,<br>
&gt;             protocol: new OpenLayers.Protocol.WFS({<br>
&gt;                 url:  "&lt;@geoServerUrlTemplate/&gt;/wfs",<br>
&gt;                 featureType: "areas_in_time",<br>
&gt;                 featureNS: "http://health-e-waterways.org"<br>
&gt;             })<br>
&gt;         });<br>
&gt;         map.removeLayer(subregions);<br>
&gt;         map.addLayer(current_areas);<br>
&gt;     }<br>
&gt;<br>
&gt; I tried using the "loadend" event again with various things in it, but it<br>
&gt; doesn't work. Turning the layer off/on manually does as does a call to<br>
&gt; refresh() later.<br>
&gt;<br>
&gt; Am I doing something wrong? Is there something I should wait for before<br>
&gt; adding the layer?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;    Peter<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>