1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
---|
5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> |
---|
6 | <meta name="apple-mobile-web-app-capable" content="yes"> |
---|
7 | <title>OpenLayers Mousewheel Interval Example</title> |
---|
8 | <link rel="stylesheet" href="../theme/default/style.css" type="text/css"> |
---|
9 | <link rel="stylesheet" href="style.css" type="text/css"> |
---|
10 | <script src="../lib/OpenLayers.js"></script> |
---|
11 | <script type="text/javascript"> |
---|
12 | var map, layer; |
---|
13 | |
---|
14 | function setCumulative() { |
---|
15 | var nav = map.getControlsByClass("OpenLayers.Control.Navigation")[0]; |
---|
16 | var cumulative = document.getElementById("cumulative"); |
---|
17 | nav.handlers.wheel.cumulative = cumulative.checked; |
---|
18 | } |
---|
19 | |
---|
20 | function init(){ |
---|
21 | map = new OpenLayers.Map( 'map', {controls: [ |
---|
22 | new OpenLayers.Control.Navigation( |
---|
23 | {mouseWheelOptions: {interval: 100}} |
---|
24 | ), |
---|
25 | new OpenLayers.Control.PanZoom(), |
---|
26 | new OpenLayers.Control.ArgParser(), |
---|
27 | new OpenLayers.Control.Attribution() |
---|
28 | ]} ); |
---|
29 | layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", |
---|
30 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
---|
31 | {layers: 'basic'} ); |
---|
32 | map.addLayer(layer); |
---|
33 | map.zoomToMaxExtent(); |
---|
34 | } |
---|
35 | </script> |
---|
36 | </head> |
---|
37 | <body onload="init()"> |
---|
38 | <h1 id="title">OpenLayers Mousewheel Interval Example</h1> |
---|
39 | |
---|
40 | <div id="tags"> |
---|
41 | performance, zoom by wheel |
---|
42 | </div> |
---|
43 | |
---|
44 | <div id="shortdesc">Let OpenLayers send less tile requests to the server when wheel-zooming.</div> |
---|
45 | |
---|
46 | <div id="map" class="smallmap"></div> |
---|
47 | |
---|
48 | <div id="docs"> |
---|
49 | <p>This example shows how to configure the Navigation control to use |
---|
50 | the mousewheel in a less server resource consuming way: as long as you |
---|
51 | spin the mousewheel, no request will be sent to the server. Instead, |
---|
52 | the zoomlevel delta will be recorded. After a delay (in this example |
---|
53 | 100ms), a zoom action with the cumulated delta will be performed.</p> |
---|
54 | <div> |
---|
55 | <input id="cumulative" type="checkbox" checked="checked" |
---|
56 | onchange="setCumulative()"/> |
---|
57 | <label for="cumulative">Cumulative mode. If this mode is deactivated, |
---|
58 | only one zoom event will be performed after the delay.</label> |
---|
59 | </div> |
---|
60 | |
---|
61 | </div> |
---|
62 | </body> |
---|
63 | </html> |
---|