[OpenLayers-Commits] r11471 - sandbox/pgiraud/playground

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Feb 25 04:38:40 EST 2011


Author: pgiraud
Date: 2011-02-25 01:38:40 -0800 (Fri, 25 Feb 2011)
New Revision: 11471

Added:
   sandbox/pgiraud/playground/locateMe.html
Log:
a locate me quick example

Added: sandbox/pgiraud/playground/locateMe.html
===================================================================
--- sandbox/pgiraud/playground/locateMe.html	                        (rev 0)
+++ sandbox/pgiraud/playground/locateMe.html	2011-02-25 09:38:40 UTC (rev 11471)
@@ -0,0 +1,76 @@
+<html xmlns="http://www.w3.org/1999/xhtml"> 
+    <head> 
+    <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 Click Event Example</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"> 
+            OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {                
+                defaultHandlerOptions: {
+                    'single': true,
+                    'double': false,
+                    'pixelTolerance': 0,
+                    'stopSingle': false,
+                    'stopDouble': false
+                },
+ 
+                initialize: function(options) {
+                    this.handlerOptions = OpenLayers.Util.extend(
+                        {}, this.defaultHandlerOptions
+                    );
+                    OpenLayers.Control.prototype.initialize.apply(
+                        this, arguments
+                    ); 
+                    this.handler = new OpenLayers.Handler.Click(
+                        this, {
+                            'click': this.trigger
+                        }, this.handlerOptions
+                    );
+                }, 
+ 
+                trigger: function(e) {
+                    var lonlat = map.getLonLatFromViewPortPx(e.xy);
+                    alert(lonlat.lon + ', ' + lonlat.lat) ;
+                }
+ 
+            });
+            var map;
+            function init(){
+                map = new OpenLayers.Map('map');
+ 
+                var osm = new OpenLayers.Layer.OSM();
+ 
+ 
+                map.addLayers([osm]);
+                // map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+                map.zoomToMaxExtent();
+                
+                var click = new OpenLayers.Control.Click();
+                map.addControl(click);
+                click.activate();
+ 
+            }
+        </script> 
+    </head> 
+    <body onload="init()"> 
+        <h1 id="title">Click Event Example</h1> 
+ 
+        <div id="tags"> 
+            click control, double, doubleclick, double-click, event, events, 
+            propagation
+        </div> 
+ 
+        <p id="shortdesc"> 
+            This example shows the use of the click handler and 
+            getLonLatFromViewPortPx functions to trigger events on mouse click. 
+        </p> 
+ 
+        <div id="map" class="smallmap"></div> 
+    
+        <div id="docs"> 
+        </div> 
+    </body> 
+</html> 



More information about the Commits mailing list