summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/overviewmap.html
blob: 5a8cc3fbc95f8a436e1deca5c5d48fd65a0fb3ed (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<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>Overview Map 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" type="text/javascript"></script>
        <style>
        #map1 {
            width: 500px; 
            height: 300px;
            border: 1px solid gray;
        }
        #map2 {
            width: 500px; 
            height: 300px;
            border: 1px solid gray;
        }
        </style>
    </head>
    <body>
        <h1 id="title">Overview Map</h1>

        <div id="tags">
            overview, mapOptions, basic
        </div>
        <p id="shortdesc">
            Enable a small Overview Map that moves/interacts with your main map.
        </p>
        <div id="map1"></div>
        <p>The above map has an overview map control that is created with
        the default options.  Much like a regular map, the map contained by
        the overview map control defaults to a geographic projection.</p>
        <div id="map2"></div>
        <p>The second map has an overview map control that is created with
        non-default options.  In this case, the mapOptions property of the
        control has been set to use non-default projection related properties,
        and the layers property has been set to use a layer different from the main
        map. In addition, any other properties of the overview map control can be
        set in this way.</p>
        <script defer="defer" type="text/javascript">
        
        // set up some layers
        
        var ol = new OpenLayers.Layer.WMS(
            "OpenLayers WMS", 
            "http://vmap0.tiles.osgeo.org/wms/vmap0",
            {layers: 'basic'}
        );
        
        var jpl = new OpenLayers.Layer.WMS(
            "NASA Global Mosaic", 
            "http://t1.hypercube.telascience.org/cgi-bin/landsat7",
            {layers: "landsat7"}
        );
        
        // A clone of the above layer that we will use as overview for map2.
        // We need to clone jpl before the it gets added to a map, so the
        // clone can have its own maxExtent and maxResolution instead of
        // getting these settings initialized from map1.
        var jplOverview = jpl.clone();
        
        // A more detailled layer of Manhattan for map2
        var ny = new OpenLayers.Layer.WMS(
            "Manhattan", 
            "http://demo.opengeo.org/geoserver/wms",
            {
                layers: 'tiger-ny', 
                format: 'image/png'
            }
        );
        
        // create the top map (with default overview map control)
        var map1 = new OpenLayers.Map('map1');
        
        map1.addLayers([ol, jpl]);
        map1.addControl(new OpenLayers.Control.LayerSwitcher());
        
        // create an overview map control with the default options
        var overview1 = new OpenLayers.Control.OverviewMap({
            maximized: true,
            maximizeTitle: 'Show the overview map',
            minimizeTitle: 'Hide the overview map'
        });
        map1.addControl(overview1);
        
        map1.setCenter(new OpenLayers.LonLat(0, 0), 2);
        
        // create the bottom map (with advanced overview map control)
        var mapOptions = {
            maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195,
                    -8227290.161511, 4994963.723637), 
            maxResolution: 116.24879860156216,
            projection: "EPSG:900913"
        };

        var map2 = new OpenLayers.Map('map2', mapOptions);
        
        map2.addLayers([ny]);
        
        // create an overview map control with non-default options
        var controlOptions = {
            maximized: true,
            mapOptions: OpenLayers.Util.extend(mapOptions, {
                maxResolution: 156543.0339,
                maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
                                     20037508.34, 20037508.34)
            }),
            layers: [jplOverview]
        };
        var overview2 = new OpenLayers.Control.OverviewMap(controlOptions);
        map2.addControl(overview2);
        
        map2.setCenter(new OpenLayers.LonLat(-8233165.3575055, 4980298.21113769), 3);
        
        </script>
    </body>
</html>