Files
openlayers/examples/popups.html
2006-05-25 02:27:29 +00:00

86 lines
3.1 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer, popup;
function init(){
map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://octo.metacarta.com/cgi-bin/mapserv",
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
function changer() {
popup.setBackgroundColor("red");
popup.setSize(new OpenLayers.Size(100,600));
// popup.moveTo(new OpenLayers.Pixel(120,120));
// popup.setOpacity(.5);
popup.setBorder("2px solid");
popup.setContentHTML("High Chickens");
}
function add() {
popup = new OpenLayers.Popup("chicken",
new OpenLayers.LonLat(5,40),
new OpenLayers.Size(200,200),
"example popup");
map.addPopup(popup);
}
function addAnchor() {
popup = new OpenLayers.Popup.Anchored("chicken",
new OpenLayers.LonLat(5,40),
new OpenLayers.Size(200,200),
"example popup");
map.addPopup(popup);
}
function addAnchorBubble() {
popup = new OpenLayers.Popup.AnchoredBubble("chicken",
new OpenLayers.LonLat(5,40),
new OpenLayers.Size(200,200),
"example popup");
popup.setBackgroundColor("yellow");
popup.setOpacity(0.7);
map.addPopup(popup);
}
function destroy() {
popup.destroy();
}
function remove() {
map.removePopup(popup);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
<div style="background-color:purple" onclick="add()"> click to add Popup to map</div>
<div style="background-color:green" onclick="addAnchor()"> click to add an Popup.Anchored</div>
<div style="background-color:orange" onclick="addAnchorBubble()"> click to add Popup.AnchoredBubble</div>
<div style="background-color:blue" onclick="changer()"> click to modify popup's attributes</div>
<div style="background-color:red" onclick="remove()"> click to remove the popup from map</div>
</body>
</html>