framedCloud.css was unneccesary. Combining this into theme/default/style.css, and removing from examples. Only changes examples and theme, so committing without review. (Closes #1750) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8905 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
82 lines
2.9 KiB
HTML
82 lines
2.9 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
|
|
<link rel="stylesheet" href="style.css" type="text/css" />
|
|
|
|
<style type="text/css">
|
|
#map {
|
|
width: 100%;
|
|
height: 80%;
|
|
border: 1px solid black;
|
|
}
|
|
.olPopup p { margin:0px; font-size: .9em;}
|
|
.olPopup h2 { font-size:1.2em; }
|
|
</style>
|
|
<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://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
|
map.addLayer(layer);
|
|
map.addLayer(new OpenLayers.Layer.GML("KML", "kml/sundials.kml",
|
|
{
|
|
format: OpenLayers.Format.KML,
|
|
formatOptions: {
|
|
extractStyles: true,
|
|
extractAttributes: true
|
|
}
|
|
}));
|
|
selectControl = new OpenLayers.Control.SelectFeature(map.layers[1],
|
|
{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
|
|
|
|
map.addControl(selectControl);
|
|
selectControl.activate();
|
|
map.zoomToExtent(new OpenLayers.Bounds(68.774414,11.381836,123.662109,34.628906));
|
|
}
|
|
function onPopupClose(evt) {
|
|
selectControl.unselect(selectedFeature);
|
|
}
|
|
function onFeatureSelect(feature) {
|
|
selectedFeature = feature;
|
|
// Since KML is user-generated, do naive protection against
|
|
// Javascript.
|
|
var content = "<h2>"+feature.attributes.name + "</h2>" + feature.attributes.description;
|
|
if (content.search("<script") != -1) {
|
|
content = "Content contained Javascript! Escaped content below.<br />" + content.replace(/</g, "<");
|
|
}
|
|
popup = new OpenLayers.Popup.FramedCloud("chicken",
|
|
feature.geometry.getBounds().getCenterLonLat(),
|
|
new OpenLayers.Size(100,100),
|
|
content,
|
|
null, true, onPopupClose);
|
|
feature.popup = popup;
|
|
map.addPopup(popup);
|
|
}
|
|
function onFeatureUnselect(feature) {
|
|
map.removePopup(feature.popup);
|
|
feature.popup.destroy();
|
|
feature.popup = null;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
<h1 id="title">KML Layer Example</h1>
|
|
|
|
<div id="tags"></div>
|
|
|
|
<p id="shortdesc">
|
|
Demonstrates loading and displaying a KML file on top of a basemap.
|
|
</p>
|
|
|
|
<div id="map" class="smallmap"></div>
|
|
|
|
<div id="docs"></div>
|
|
</body>
|
|
</html>
|