<!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>
> Hello all,<br>
><br>
> I'm trying to use Vector layers based on WFS and I am encountering issues<br>
> with the layers not displaying straight away. To display them properly I<br>
> need to remove them and add them again or call refresh().<br>
><br>
> Here is what I do:<br>
><br>
> var propertyFilter = new OpenLayers.Filter.Comparison({<br>
> type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
> property: 'year',<br>
> value: 2009<br>
> });<br>
> subregions = new OpenLayers.Layer.Vector("Subregions", {<br>
> strategies: [new OpenLayers.Strategy.BBOX()],<br>
> filter: propertyFilter,<br>
> projection: new OpenLayers.Projection("EPSG:4326"),<br>
> styleMap: subregionStyle,<br>
> protocol: new OpenLayers.Protocol.WFS({<br>
> url: "<@geoServerUrlTemplate/>/wfs",<br>
> featureType: "subregions_in_time",<br>
> featureNS: "http://health-e-waterways.org"<br>
> })<br>
> });<br>
> // the next bit forces IE8 to show the overlay<br>
> subregions.events.register('loadend',subregions,function(e) {<br>
> map.removeLayer(subregions);<br>
> map.addLayer(subregions);<br>
> });<br>
> map.addLayer(subregions);<br>
><br>
> Note the event hook, which fixes this layer for IE8 (it worked in Firefox<br>
> out of the box). The same trick does not work if I swap in another layer<br>
> later. I can't get this bit of code to work properly at all:<br>
><br>
> function focusOnSubregion(name) {<br>
> current_subregion=name;<br>
> if (current_subregion == 'Northern') {<br>
> map.zoomToExtent(northern_bounds);<br>
> } else if (current_subregion == 'Southern') {<br>
> map.zoomToExtent(southern_bounds);<br>
> } else if (current_subregion == 'Western') {<br>
> map.zoomToExtent(western_bounds);<br>
> } else if (current_subregion == 'Moreton Bay') {<br>
> map.zoomToExtent(moreton_bounds);<br>
> } else {<br>
> map.zoomToExtent(bounds);<br>
> }<br>
> var yearFilter = new OpenLayers.Filter.Comparison({<br>
> type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
> property: 'year',<br>
> value: 2009<br>
> });<br>
> var subRegionFilter = new OpenLayers.Filter.Comparison({<br>
> type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
> property: 'subregion',<br>
> value: name<br>
> });<br>
> var propertyFilter = new OpenLayers.Filter.Logical({<br>
> type: OpenLayers.Filter.Logical.AND,<br>
> filters: [yearFilter, subRegionFilter]<br>
> });<br>
> current_areas = new OpenLayers.Layer.Vector("Catchments", {<br>
> strategies: [new OpenLayers.Strategy.BBOX()],<br>
> filter: propertyFilter,<br>
> projection: new OpenLayers.Projection("EPSG:4326"),<br>
> styleMap: catchmentStyle,<br>
> protocol: new OpenLayers.Protocol.WFS({<br>
> url: "<@geoServerUrlTemplate/>/wfs",<br>
> featureType: "areas_in_time",<br>
> featureNS: "http://health-e-waterways.org"<br>
> })<br>
> });<br>
> map.removeLayer(subregions);<br>
> map.addLayer(current_areas);<br>
> }<br>
><br>
> I tried using the "loadend" event again with various things in it, but it<br>
> doesn't work. Turning the layer off/on manually does as does a call to<br>
> refresh() later.<br>
><br>
> Am I doing something wrong? Is there something I should wait for before<br>
> adding the layer?<br>
><br>
> 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></body></html>