[OpenLayers-Users] Reuse Layer - Refresh map
Diego M.
oo_O2_oo at hotmail.com
Wed Mar 7 13:10:51 EST 2012
Hi All
I'm trying to assign my layer to a variable, and reuse it with no need to
send a new request for features.
so, I've created a function contains Layer definition and map.addLayers.
call it with inital boolean value(true) at top of my init() after my map
definition.
var n == true;
function display (n)
{
if(n == true) //send new request for myLayer
{
*myLayer = new OpenLayers.Layer.Vector("main", { *
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: .... etc });
*map.addLayers([googleLayer , myLayer]); *
}
else //reuse myLayer
{
map.destroy(); *//here i need to refresh my map*
map = new OpenLayers.Map('map',{
maxExtent: ... etc
});
map.addLayers([googleLayer , myLayer]);
}
}
as you noticed, n = true by default, so myLayer will receive a new features
since it has nothing yet.
and when i add a link calling display function with (false) , the map is
refreshing with my previous layer (myLayer) without send new request for
features.
by this I'm hoping to get displaying map faster and easily move back and
forward through it.
my problem is i'm keep getting this message error : /Cannot set property
'className' of null/
so i'm not sure if my refreshing technique is right or i need to change
something else.
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Reuse-Layer-Refresh-map-tp4555614p4555614.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list