Last active
January 2, 2016 09:49
-
-
Save pgiraud/8285919 to your computer and use it in GitHub Desktop.
OpenLayers - "buttonclick" event triggered twice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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>Button click</title> | |
| <link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css"> | |
| <link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css"> | |
| <script src="http://openlayers.org/dev/OpenLayers.js"></script> | |
| <script type="text/javascript" src="index.js"></script> | |
| </head> | |
| <body onload="init()"> | |
| <div id="map" class="smallmap"></div> | |
| Try to click on the zoom buttons. On some devices, it results in "click" being written twice in the textarea below.<br> | |
| <textarea id="clicks"></textarea><br> | |
| <button id="clear" onclick="document.getElementById('clicks').value = ''">clear</button> | |
| <br> | |
| <img src="http://chart.apis.google.com/chart?cht=qr&chs=100x100&chl=http%3A//bl.ocks.org/pgiraud/raw/8285919/&chld=H|0"> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var map, drawControls; | |
| function init() { | |
| map = new OpenLayers.Map('map'); | |
| var wmsLayer = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0?", { | |
| layers: 'basic' | |
| }); | |
| map.addLayers([wmsLayer]); | |
| map.setCenter(new OpenLayers.LonLat(0, 0), 3); | |
| map.events.register("buttonclick", null, function(){ | |
| $('clicks').value += 'click '; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment