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),
39 popup.closeOnMove = true;
44 function addAnchor() {
45 popup = new OpenLayers.Popup.Anchored("chicken",
46 new OpenLayers.LonLat(5,40),
47 new OpenLayers.Size(200,200),
48 "example popup", true);
53 function addMarker() {
55 markers = new OpenLayers.Layer.Markers("zibo");
56 map.addLayer(markers);
58 feature = new OpenLayers.Feature(layer,
59 new OpenLayers.LonLat(0,0));
62 marker = feature.createMarker();
64 markers.addMarker(marker);
65 marker.events.register("mousedown", marker, mousedown);
69 function mousedown(evt) {
71 popup = feature.createPopup(true);
72 popup.setContentHTML("<div style='background-color:red; width:150;height:100'><a href='http://www.somethingconstructive.net' target='_blank'>click me</a></div>");
73 popup.setBackgroundColor("yellow");
74 popup.setOpacity(0.7);
75 markers.map.addPopup(popup);
79 OpenLayers.Event.stop(evt);
85 function onPopupMouseDown(evt) {
86 markers.map.removePopup(popup);
89 OpenLayers.Event.stop(evt);
98 markers.removeMarker(marker);
101 function removelayer() {
103 // map.removeLayer(markers);
107 <body onload="init()">
108 <h1 id="title">Popup Mayhem</h1>
113 All kinds of ways to create and interact with Popups.
116 <div id="map" class="smallmap"></div>
117 <p>If you open an anchoredbubble and switch to google, it shouldn't crash. If it does, don't release OpenLayers.</p>
118 <div style="background-color:purple" onclick="add()"> click to add Popup to map</div>
119 <div style="background-color:green" onclick="addMarker()"> click to add a Marker with an AnchoredBubble popup</div>
120 <div style="background-color:blue" onclick="changer()"> click to modify popup's attributes</div>
121 <div style="background-color:red" onclick="remove()"> click to remove the popup from map</div>
122 <div style="background-color:grey" onclick="removelayer()"> click to remove the markers layer</div>
123 <div style="background-color:orange" onclick="alert(marker.onScreen())"> marker.onscreen()?</div>
124 <div style="background-color:yellow" onclick="destroy()"> click to destroy the popup from map</div>
126 Detailed description of this example needs to be written.