Update KML layer example.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10875 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,38 +1,13 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
|
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
|
||||||
<link rel="stylesheet" href="style.css" type="text/css" />
|
<link rel="stylesheet" href="style.css" type="text/css">
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var lon = 5;
|
|
||||||
var lat = 40;
|
|
||||||
var zoom = 5;
|
|
||||||
var map, layer;
|
|
||||||
|
|
||||||
function init(){
|
|
||||||
map = new OpenLayers.Map('map');
|
|
||||||
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
|
||||||
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
|
|
||||||
map.addLayer(layer);
|
|
||||||
map.addLayer(new OpenLayers.Layer.GML("KML", "kml/lines.kml",
|
|
||||||
{
|
|
||||||
format: OpenLayers.Format.KML,
|
|
||||||
formatOptions: {
|
|
||||||
extractStyles: true,
|
|
||||||
extractAttributes: true,
|
|
||||||
maxDepth: 2
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
map.zoomToExtent(new OpenLayers.Bounds(-112.306698,36.017792,-112.03204,36.18087));
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body>
|
||||||
<h1 id="title">KML Layer Example</h1>
|
<h1 id="title">KML Layer Example</h1>
|
||||||
|
|
||||||
<div id="tags">
|
<div id="tags">KML</div>
|
||||||
KML
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
Demonstrates loading and displaying a KML file on top of a basemap.
|
Demonstrates loading and displaying a KML file on top of a basemap.
|
||||||
@@ -40,6 +15,19 @@
|
|||||||
|
|
||||||
<div id="map" class="smallmap"></div>
|
<div id="map" class="smallmap"></div>
|
||||||
|
|
||||||
<div id="docs"></div>
|
<div id="docs">
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
View the <a href="kml-layer.js" target="_blank">kml-layer.js</a>
|
||||||
|
source to see how this is done.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script src="kml-layer.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
22
examples/kml-layer.js
Normal file
22
examples/kml-layer.js
Normal file
@@ -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
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user