OpenLayers OpenLayers

root/sandbox/follower/b-singlefile/popups.html

Revision 253, 2.2 kB (checked in by euzuro, 3 years ago)

update popups.html demo to changes from r252

Line 
1 <html xmlns="http://www.w3.org/1999/xhtml">
2   <head>
3     <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
4     <style type="text/css">
5         #map {
6             width: 800px;
7             height: 475px;
8             border: 1px solid black;
9         }
10     </style>
11     <script src="lib/OpenLayers.js"></script>
12     <script type="text/javascript">
13         <!--
14         var map, layer, popup;
15
16         function init(){
17             map = new OpenLayers.Map('map');
18             layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
19                 "http://octo.metacarta.com/cgi-bin/mapserv",
20                 {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} );
21                
22             map.addLayer(layer);
23
24             map.setCenter(new OpenLayers.LonLat(0, 0), 0);
25             map.addControl(new OpenLayers.Control.LayerSwitcher());
26         }
27        
28         function changer() {
29             popup.setBackgroundColor("red");
30             popup.setSize(new OpenLayers.Size(200,20));
31             popup.moveTo(new OpenLayers.Pixel(120,120));
32             popup.setOpacity(.9);
33             popup.setBorder("2px solid");   
34             popup.setContentHTML("High Chickens");           
35         }
36
37         function add() {
38             popup = new OpenLayers.Popup("chicken",
39                                          new OpenLayers.Size(200,200),
40                                          "example popup");
41        
42             map.addPopup(popup, new OpenLayers.Pixel(50,50));
43         }       
44        
45         function destroy() {
46             popup.destroy();
47         }
48
49         function remove() {
50             map.removePopup(popup);
51         }
52
53
54         // -->
55     </script>
56   </head>
57   <body onload="init()">
58     <h1>OpenLayers Example</h1>
59     <div id="map"></div>
60     <div style="background-color:purple" onclick="add()"> click to add popup to map</div>
61     <div style="background-color:blue" onclick="changer()"> click to modify popup's attributes</div>
62     <div style="background-color:red" onclick="destroy()"> click to destroy the popup</div>
63     <div style="background-color:green" onclick="remove()"> click to remove the popup from map</div>
64   </body>
65 </html>
Note: See TracBrowser for help on using the browser.