[OpenLayers-Users] dynamic generated kml-layer

Roald de Wit roald.dewit at lisasoft.com
Mon Jun 16 07:54:22 EDT 2008


Hi  Christian,

Christian Schanz wrote:
> what is the best way to add a dynamically generated kml-layer to a map?
> The kml is generated by passing the current extent of the view and so
> the layer should be updated after zooming or moving.
>   
What you describe here is effectively the behaviour of a WFS layer. If I 
remember correctly, since 2.6 (current stable release) you can create a 
WFS layer and define what the format should be. In your case, that would 
be OpenLayers.Format.KML:

    var layer = new OpenLayers.Layer.WFS( "KML Layer ", url, params,
    {format: OpenLayers.Format.KML, extractStyles: true,
    extractAttributes: true} );

It will automatically add a bbox parameter to the request string. If 
that is enough for you, then you're ready to go. If not: in your params 
parameter you can put anything you'd like to send to the server.  Not 
sure how to dynamically add the current zoomlevel etc. Make sure you use 
Firebug in Firefox to test what requests are sent to your server.

I hope this helps you in the right direction.

Kind regards,

Roald

--
Roald de Wit
Software Engineer
roald.dewit at lisasoft.com

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/





More information about the Users mailing list