[OpenLayers-Users] Removing a layer

Carlos Pinto cmsp76 at gmail.com
Tue Oct 14 11:21:15 EDT 2008


Thanks very much.
I feel a little bit dum. But at least the problem is solved.

Best,

Carlos


On Tue, Oct 14, 2008 at 5:01 PM, <bartvde at osgis.nl> wrote:

> Probably this is because of the scope of your variable.
>
> If you define var xxxx in a function, it only has a local scope inside of
> the function, outside of the function it is not accessible.
>
> Instead, you can define the variable outside of the function with the var
> keyword.
>
> var xxxx = null;
>
> function init() {
>  xxx = new ......;
> }
>
> Best regards,
> Bart
>
> > Hi all,
> > I am having one trouble and I don't know what else to do.
> >
> > I have my map and I have develop some javascript code that is working
> > fine.
> > What happened this weekend is that I developed a function that had that
> > some
> > layers in the beginning:
> >
> >
> > var myStyle128684655922811250 = new OpenLayers.StyleMap({fillOpacity:
> > 0.5});var rules128684655922811250 = {0: {fillColor: '#ffffff',
> > fillOpacity:0.5}   };
> >
> > myStyle128684655922811250.addUniqueValueRules('default', 'type',
> > rules128684655922811250);
> >
> > var layer128684655922811250 = new OpenLayers.Layer.GML('mercury layer',
> > '../GML/glmush55qv3web45ak21mhrf128684655922811250.xml',{styleMap:
> > myStyle128684655922811250} );
> >
> > map.addLayer(layer128684655922811250);
> >
> >
> > and this is working fine.  What is really funny is that the following
> code
> > only works if the code above is outside a function. If the code above is
> > inside the init() function then this code don't work:
> >
> > //// REMOVE THE LAYER
> > map.removeLayer(layer128684657963905000);
> > layer128684657963905000.destroy();
> >
> >
> > Why??? Anybody knows why??????
> >
> > Thanks
> >
> > Best,
> >
> > Carlos
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081014/782c2b23/attachment.html


More information about the Users mailing list