diff --git a/examples/kml-layer.html b/examples/kml-layer.html index b7217e6a20..90f1af9418 100644 --- a/examples/kml-layer.html +++ b/examples/kml-layer.html @@ -1,45 +1,33 @@ - - - - - - - - -

KML Layer Example

+ + + + + + + +

KML Layer Example

-
- KML -
+
KML
-

- Demonstrates loading and displaying a KML file on top of a basemap. +

+ Demonstrates loading and displaying a KML file on top of a basemap.

-
- +
+

+ A vector layer can be populated with features from a KML document + by configuring the layer with an HTTP protocol that points to the + KML document and is configured with a KML format for parsing features. + The fixed strategy is used to load all features at once. +

+

+ View the kml-layer.js + source to see how this is done. +

+
+ + + diff --git a/examples/kml-layer.js b/examples/kml-layer.js new file mode 100644 index 0000000000..1b0e85efd3 --- /dev/null +++ b/examples/kml-layer.js @@ -0,0 +1,22 @@ +var map = new OpenLayers.Map({ + div: "map", + layers: [ + new OpenLayers.Layer.WMS( + "WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", + {layers: "basic"} + ), + new OpenLayers.Layer.Vector("KML", { + strategies: [new OpenLayers.Strategy.Fixed()], + protocol: new OpenLayers.Protocol.HTTP({ + url: "kml/lines.kml", + format: new OpenLayers.Format.KML({ + extractStyles: true, + extractAttributes: true, + maxDepth: 2 + }) + }) + }) + ], + center: new OpenLayers.LonLat(-112.169, 36.099), + zoom: 11 +});