[OpenLayers-Users] How to remove and reload a GML layer - solved

Robert Sanson SansonR at asurequality.com
Thu Sep 18 22:11:48 EDT 2008


I ended up using layer.destroy();, followed by recreating the layer from
scratch, but aos had to add some dummy date to the end, to force the
browser to load from the Web server, rather than from cache like so:
 
dummyDate = new Date() ;
dummyParameter = "&" + dummyDate.getTime();
 
fbnd = new OpenLayers.Layer.GML("Farm boundary",
               
"http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&request=getfeature&typename=farm&service=wfs&version=1.0.0&BBOX="+x1+","+y1+","+x2+","+y2+"&maxfeatures=120
(
'http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&request=getfeature&typename=farm&service=wfs&version=1.0.0&BBOX="+x1+","+y1+","+x2+","+y2+"&maxfeatures=120'
)" + dummyParameter,
                {singleTile: true, style: farm_style,
extractAttributes: true});
                map.addLayer(fbnd);
 
Robert

>>> Jesus <mogollonster at gmail.com> 19/09/2008 1:24 p.m. >>>

Hi, i have the same problem i try the layer.redraw(true) method, cause
it
should reload the layer? but nothing

I notice that if i create a new layer or even a map it not instantiate
a new
object it just add the new members of the old one to the new one.

any clue?

I´m using the zoomify layers proposed in
http://oldmapsonline.googlecode.com/svn/trunk/openlayers/examples/zoomify.html


but i need reload the images each minute, and i can't


Robert Sanson wrote:
> 
> Hi
>  
> The trick to getting the reload layer to work was to add a dummy
parameter
> to the end of the URL, so the browser thought it was a new request.
>  
> Cheers,
>  
> Robert 
> 
>>>> "Robert Sanson" <SansonR at asurequality.com> 18/09/2008 12:03 p.m.
>>>
> Does anyone know how to remove and reload a GML layer?
>  
> I have a layer added to my map as:
>  
> va map, fbnd;
>  
> fbnd = new OpenLayers.Layer.GML("Farm boundary",
>                
>
"http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&request=getfeature&typename=farm&service=wfs&version=1.0.0&BBOX="+x1+","+y1+","+x2+","+y2+"&maxfeatures=120

> (
>
'http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&amp;request=getfeature&amp;typename=farm&amp;service=wfs&amp;version=1.0.0&amp;BBOX="+x1+","+y1+","+x2+","+y2+"&amp;maxfeatures=120'
> )",
>                 {singleTile: true, style: farm_style,
extractAttributes:
> true});
>               map.addLayer(fbnd);
>  
> I then do some edits to the database.
>  
> I now want to remove it and reload it, based on a user clicking a
button
>  
> I tried:
>  
> map.removeLayer(fbnd,false); 
>  
> This works, but then iI tried to reload it as:
>  
> fbnd = new OpenLayers.Layer.GML("Farm boundary",
>                
>
"http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&request=getfeature&typename=farm&service=wfs&version=1.0.0&BBOX="+x1+","+y1+","+x2+","+y2+"&maxfeatures=120

> (
>
'http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid+"&amp;request=getfeature&amp;typename=farm&amp;service=wfs&amp;version=1.0.0&amp;BBOX="+x1+","+y1+","+x2+","+y2+"&amp;maxfeatures=120'
> )",
>                 {singleTile: true, style: farm_style,
extractAttributes:
> true});
>               map.addLayer(fbnd);
>  
> This seems to load the same data without forcing a refresh.
>  
> Any clues?
>  
> Many thanks,
>  
> Robert
> 
> 
> 
> 
> ------------------------------------------------------------------
> The contents of this email are confidential to AsureQuality. If you
have
> received this communication in error please notify the sender
immediately
> and delete the message and any attachments. The opinions expressed in
this
> email are not necessarily those of AsureQuality. This message has
been
> scanned for known viruses before delivery. AsureQuality supports the
> Unsolicited Electronic Messages Act 2007. If you do not wish to
receive
> similar communications in future, please notify the sender of this
> message.
> ------------------------------------------------------------------
> 
> 
> 
> This message has been scanned for malware by SurfControl plc.
> www.surfcontrol.com ( http://www.surfcontrol.com/ )
> 
> 
> Click here (
>
https://www.mailcontrol.com/sr/lboVqLLfumvTndxI!oX7UhblTb0BBCjq4am39x6ai4pLLlBB97uqOsrupOtDxR9eNzk2Jf8HBVsDNW0+5ADKWw==

> ) to report this email as spam.
> ------------------------------------------------------------------
> The contents of this email are confidential to AsureQuality. If you
have
> received this communication in error please notify the sender
immediately
> and delete the message and any attachments. The opinions expressed in
this
> email are not necessarily those of AsureQuality. This message has
been
> scanned for known viruses before delivery. AsureQuality supports the
> Unsolicited Electronic Messages Act 2007. If you do not wish to
receive
> similar communications in future, please notify the sender of this
> message.
> ------------------------------------------------------------------
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org 
> http://openlayers.org/mailman/listinfo/users 
> 
> 

-- 
View this message in context:
http://n2.nabble.com/How-to-remove-and-reload-a-GML-layer-tp1096944p1099858.html

Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org 
http://openlayers.org/mailman/listinfo/users
------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080919/9762d013/attachment.html


More information about the Users mailing list