1
<html xmlns="http://www.w3.org/1999/xhtml">
3
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
4
<link rel="stylesheet" href="style.css" type="text/css" />
5
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
6
<script src="../lib/OpenLayers.js"></script>
7
<script type="text/javascript">
9
var markers, feature, marker;
12
map = new OpenLayers.Map('map');
13
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
14
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
16
layer = new OpenLayers.Layer.Google( "Google" );
19
map.addControl(new OpenLayers.Control.LayerSwitcher());
20
map.zoomToMaxExtent();
25
popup.setBackgroundColor("red");
26
popup.setSize(new OpenLayers.Size(100,600));
27
// popup.moveTo(new OpenLayers.Pixel(120,120));
28
// popup.setOpacity(.5);
29
popup.setBorder("2px solid");
30
popup.setContentHTML("High Chickens");
34
popup = new OpenLayers.Popup("chicken",
35
new OpenLayers.LonLat(5,40),
36
new OpenLayers.Size(200,200),
43
function addAnchor() {
44
popup = new OpenLayers.Popup.Anchored("chicken",
45
new OpenLayers.LonLat(5,40),
46
new OpenLayers.Size(200,200),
47
"example popup", true);
52
function addMarker() {
54
markers = new OpenLayers.Layer.Markers("zibo");
55
map.addLayer(markers);
57
feature = new OpenLayers.Feature(layer,
58
new OpenLayers.LonLat(0,0));
61
marker = feature.createMarker();
63
markers.addMarker(marker);
64
marker.events.register("mousedown", marker, mousedown);
68
function mousedown(evt) {
70
popup = feature.createPopup(true);
71
popup.setContentHTML("<div style='background-color:red; width:150;height:100'><a href='http://www.somethingconstructive.net' target='_blank'>click me</a></div>");
72
popup.setBackgroundColor("yellow");
73
popup.setOpacity(0.7);
74
markers.map.addPopup(popup);
78
OpenLayers.Event.stop(evt);
84
function onPopupMouseDown(evt) {
85
markers.map.removePopup(popup);
88
OpenLayers.Event.stop(evt);
97
markers.removeMarker(marker);
100
function removelayer() {
102
// map.removeLayer(markers);
106
<body onload="init()">
107
<h1 id="title">Popup Mayhem</h1>
112
All kinds of ways to create and interact with Popups.
115
<div id="map" class="smallmap"></div>
116
<p>If you open an anchoredbubble and switch to google, it shouldn't crash. If it does, don't release OpenLayers.</p>
117
<div style="background-color:purple" onclick="add()"> click to add Popup to map</div>
118
<div style="background-color:green" onclick="addMarker()"> click to add a Marker with an AnchoredBubble popup</div>
119
<div style="background-color:blue" onclick="changer()"> click to modify popup's attributes</div>
120
<div style="background-color:red" onclick="remove()"> click to remove the popup from map</div>
121
<div style="background-color:grey" onclick="removelayer()"> click to remove the markers layer</div>
122
<div style="background-color:orange" onclick="alert(marker.onScreen())"> marker.onscreen()?</div>
123
<div style="background-color:yellow" onclick="destroy()"> click to destroy the popup from map</div>
125
Detailed description of this example needs to be written.