File: mouse-position.html

package info (click to toggle)
openlayers 2.11%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 60,144 kB
  • ctags: 10,906
  • sloc: xml: 7,435; python: 778; sh: 68; makefile: 30
file content (47 lines) | stat: -rw-r--r-- 1,821 bytes parent folder | download
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" debug="true">
  <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>MousePosition Control</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>
    <script type="text/javascript">
        var map;
        function init(){
            var map = new OpenLayers.Map('map');

            map.addControl(new OpenLayers.Control.MousePosition());

            var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                "http://vmap0.tiles.osgeo.org/wms/vmap0",
                {layers: 'basic'} );

            map.addLayers([ol_wms]);
            if (!map.getCenter()) map.zoomToMaxExtent();
            
            map.events.register("mousemove", map, function(e) { 
                var position = this.events.getMousePosition(e);
                OpenLayers.Util.getElement("coords").innerHTML = position;
            });
        }
    </script>
  </head>
  <body onload="init()">
    <h1 id="title">MousePosition Control</h1>
    <div id="tags">
        coordinate
    </div>
    <p id="shortdesc">
      Use the MousePosition Control to display the coordinates of the cursor
      inside or outside the map div.
    </p>  
    <div id="map" class="smallmap"></div>
    <div id="coords"></div>
    <p>Moving your mouse to the upper left corner of this map should return
    'x=0,y=0' -- in the past, it didn't in IE. If it returns 2,2, consider it a
    bug, and report it.</p> 
  </body>
</html>