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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
<!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 Accessible Example</title>
<link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
table {
border: 1 px solid white;
padding: 0;
}
td {
text-align: center;
}
a {
text-decoration: none;
font-size: 1.2em;
}
a em {
font-style: normal;
font-weight: normal;
text-decoration: underline;
}
a:hover {
text-decoration: underline;
}
a.api {
font-size:1em;
text-decoration:underline;
}
a.accesskey {
color: white;
}
a.accesskey:focus {
color: #436976;
}
a.zoom {
padding-right: 20px;
}
</style>
<script src="openlayers/OpenLayers.js"></script>
<script type="text/javascript">
var map = null;
function init(){
var options = {
controls: [
new OpenLayers.Control.KeyboardDefaults({
observeElement: 'map'
})
]
};
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'}
);
map.addLayer(wms);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
<h1 id="title">Accessible Example</h1>
<div id="tags">
keyboard, pan, panning, zoom, zooming, accesskey
</div>
<a class="accesskey"
href=""
accesskey="1"
onclick="document.getElementById('map').focus(); return false;">
Go to map
</a>
<p id="shortdesc">
Demonstrate the KeyboardDefaults control and how to use links
with Access Keys to navigate the map with the keyboard.
</p>
<a class="zoom"
href="javascript: void map.zoomIn();"
accesskey="i">
zoom <em>i</em>n</a>
<a class="zoom"
href="javascript: void map.zoomOut();"
accesskey="o">
zoom <em>o</em>ut</a>
<table>
<tbody>
<tr>
<td> </td>
<td>
<a href="javascript: void map.pan(0, -map.getSize().h / 4);"
accesskey="n">
pan <em>n</em>orth
</a>
</td>
</tr>
<tr>
<td>
<a href="javascript: void map.pan(-map.getSize().w / 4, 0);"
accesskey="w">
pan <em>w</em>est
</a>
</td>
<td id="map" class="smallmap" tabindex="0"></td>
<td>
<a href="javascript: void map.pan(map.getSize().w / 4, 0);"
accesskey="e">
pan <em>e</em>ast
</a>
</td>
</tr>
<tr>
<td> </td>
<td>
<a href="javascript: void map.pan(0, map.getSize().h / 4);"
accesskey="s">
pan <em>s</em>outh
</a>
</td>
<td> </td>
</tr>
</tbody>
</table>
<div id="docs">
<p>Navigate the map in one of three ways:</p>
<ol>
<li>Use Access Key "1" (alt + 1) to focus the map element, and
use following keys to pan and zoom:
<ul>
<li>+ (zoom in)</li>
<li>- (zoom out)</li>
<li>up-arrow (pan north)</li>
<li>down-arrow (pan south)</li>
<li>left-arrow (pan east)</li>
<li>right-arrow (pan west)</li>
</ul>
See <a href=http://en.wikipedia.org/wiki/Access_key>wikipedia</a> for
more detail about Access Keys.
</li>
<li>Navigate to pan and zoom links using the "tab" key, and
press "enter" to pan and zoom</li>
<li>If Access Keys work for links in your browser, use:
<ul>
<li>i (zoom in)</li>
<li>o (zoom out)</li>
<li>n (pan north)</li>
<li>s (pan south)</li>
<li>e (pan east)</li>
<li>w (pan west)</li>
</ul>
</li>
</ol>
<p>
This is an example of using alternate methods to control panning and zooming. This approach uses map.pan() and map.zoom(). You'll note that to pan, additional math is necessary along with map.size() in order to set the distance to pan.
</div>
</body>
</html>
|