summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/teleportation.html
blob: 3154c56b729a852e6e55a06e7695a3729f910c96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <title>OpenLayers Teleporter Example</title>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
    <link rel="stylesheet" href="style.css" type="text/css">
    <script src="../lib/OpenLayers.js"></script>
    
    <style type="text/css">
        #wrapper {
            position: relative;
        }
        .spot1 {
            width: 250px;
        }
        .spot2 {
            width: 300px;
            position: absolute;
            left: 300px;
            top: 0;
        }
    </style>
    
    <script type="text/javascript">
    
        var map, layer, spot=1;
        function init(){
            map = new OpenLayers.Map({
                div: "spot1"
            });
            map.addControl(new OpenLayers.Control.OverviewMap());
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0",
                    {layers: 'basic'} );
            map.addLayer(layer);
            map.zoomTo(2);
        }
        
        function teleport() {
            if (spot == 1) {
                spot = 2;
            } else {
                spot = 1;
            }
            map.render("spot" + spot);
        }

    </script>
  </head>
  <body onload="init()">
    <h1 id="title">Map "Teleportation" and Rendering</h1>

    <div id="tags">
        map, rendering
    </div>

    <p id="shortdesc">Call the map's render method to change its container.</p>

    <div id="wrapper">
        <div id="spot1" class="smallmap spot1"></div>
        <div id="spot2" class="smallmap spot2"></div>
    </div>
    
    <input type="button" onclick="teleport()" value="Teleport!"></input>

    <div id="docs">
        <p>This example demonstrates how a map can be rendered initially in one
        container and then moved to a new container.  At any point after map
        construction, the map's render method can be called with the id of
        an empty container, moving the map to the new container.</p>
    </div>
  </body>
</html>