[OpenLayers-Commits] r11324 - in sandbox/camptocamp/mobile/openlayers: . examples lib/OpenLayers lib/OpenLayers/Control tests/Control tests/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 23 09:19:11 EST 2011


Author: pgiraud
Date: 2011-02-23 06:19:11 -0800 (Wed, 23 Feb 2011)
New Revision: 11324

Modified:
   sandbox/camptocamp/mobile/openlayers/
   sandbox/camptocamp/mobile/openlayers/examples/controls.html
   sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
   sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.js
   sandbox/camptocamp/mobile/openlayers/examples/mobile-navigation.html
   sandbox/camptocamp/mobile/openlayers/examples/mobile.js
   sandbox/camptocamp/mobile/openlayers/examples/style.css
   sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Control/Geolocate.js
   sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Kinetic.js
   sandbox/camptocamp/mobile/openlayers/tests/Control/Geolocate.html
   sandbox/camptocamp/mobile/openlayers/tests/Control/PanZoom.html
   sandbox/camptocamp/mobile/openlayers/tests/Layer/EventPane.html
Log:
svn merge -r11284:HEAD http://svn.openlayers.org/trunk/openlayers ., + adding the geolocation example features


Property changes on: sandbox/camptocamp/mobile/openlayers
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11233,11236-11238,11240-11279
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11233,11236-11238,11240-11279,11285-11316

Modified: sandbox/camptocamp/mobile/openlayers/examples/controls.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/controls.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/controls.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -64,8 +64,8 @@
             Attach zooming, panning, layer switcher, overview map, and permalink map controls to an OpenLayers window.
         </p>
 
-        <a style="float:right" href="" id="permalink">Permalink</a>
         <div id="map" class="smallmap"></div>
+        <a href="#" id="permalink">Permalink</a>
 
         <div id="docs"></div>
     </body>

Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -10,7 +10,7 @@
         <script src="http://code.jquery.com/jquery-1.5.min.js"></script>
         <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
         <link rel="stylesheet" href="style.mobile.css" type="text/css">
-        <script src="../build/OpenLayers.js"></script>
+        <script src="../lib/OpenLayers.js"></script>
         <script src="mobile.js"></script>
         <script src="mobile-jq.js"></script>
         <style>

Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.js
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.js	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.js	2011-02-23 14:19:11 UTC (rev 11324)
@@ -33,7 +33,12 @@
         map.zoomOut();
     });
     $("#locate").click(function(){
-        map.getControlsBy("id", "locate-control")[0].activate();
+        var control = map.getControlsBy("id", "locate-control")[0];
+        if (control.active) {
+            control.getCurrentLocation();
+        } else {
+            control.activate();
+        }
     });
     $('#query').keyup(function(e){
         if (e.which === 13) { // enter

Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile-navigation.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile-navigation.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile-navigation.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -3,7 +3,7 @@
   <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 TouchNavigation Control</title>
+    <title>Mobile Navigation Example</title>
     <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
     <link rel="stylesheet" href="style.mobile.css" type="text/css" />
     <link rel="stylesheet" href="style.css" type="text/css" />

Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile.js
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile.js	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile.js	2011-02-23 14:19:11 UTC (rev 11324)
@@ -8,6 +8,12 @@
     // layer for drawn features
     var vector = new OpenLayers.Layer.Vector();
 
+    var geolocate = new OpenLayers.Control.Geolocate({
+        id: "locate-control",
+        options: {
+            enableHighAccuracy: true
+        }
+    });
     // create map
     map = new OpenLayers.Map({
         div: "map",
@@ -36,17 +42,45 @@
                 vector, OpenLayers.Handler.Polygon, {id: "poly-control"}
             ),
             new OpenLayers.Control.ModifyFeature(vector, {id: "mod-control"}),
-            new OpenLayers.Control.Geolocate({
-                id: "locate-control",
-                options: {
-                    enableHighAccuracy: true
-                }
-            })
+            geolocate
         ],
         layers: [new OpenLayers.Layer.OSM(), vector],
         center: new OpenLayers.LonLat(0, 0),
         zoom: 1
     });
+    var style = {
+        fillOpacity: 0.1,
+        fillColor: '#000',
+        strokeColor: '#f00',
+        strokeOpacity: 0.6
+    };
+    geolocate.events.register("locationupdated",this,function(e) {
+        vector.removeAllFeatures();
+        vector.addFeatures([
+            new OpenLayers.Feature.Vector(
+                e.point,
+                {},
+                {
+                    graphicName: 'cross',
+                    strokeColor: '#f00',
+                    strokeWidth: 2,
+                    fillOpacity: 0,
+                    pointRadius: 10
+                }
+            ),
+            new OpenLayers.Feature.Vector(
+                OpenLayers.Geometry.Polygon.createRegularPolygon(
+                    new OpenLayers.Geometry.Point(e.point.x, e.point.y),
+                    e.position.coords.accuracy/2,
+                    50,
+                    0
+                ),
+                {},
+                style
+            )
+        ]);
+        map.zoomToExtent(vector.getDataExtent());
+    });
 };
 
 function pan(fx, fy) {

Modified: sandbox/camptocamp/mobile/openlayers/examples/style.css
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/style.css	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/examples/style.css	2011-02-23 14:19:11 UTC (rev 11324)
@@ -121,7 +121,7 @@
         display : none;
     }
 }
- at media only screen and (orientation: landscape) {
+ at media only screen and (orientation: landscape) and (max-width: 600px) {
     #shortdesc {
        float: right;
        width: 25%;

Modified: sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Control/Geolocate.js
===================================================================
--- sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Control/Geolocate.js	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Control/Geolocate.js	2011-02-23 14:19:11 UTC (rev 11324)
@@ -94,8 +94,7 @@
             this.events.triggerEvent("locationuncapable");
             return false;
         }
-        var options = this.options || {};
-        if (!this.active) {
+        if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
             if (this.watch) {
                 this.watchId = this.geolocation.watchPosition(
                     OpenLayers.Function.bind(this.geolocate, this),
@@ -103,16 +102,11 @@
                     options
                 );
             } else {
-                this.geolocation.getCurrentPosition(
-                    OpenLayers.Function.bind(this.geolocate, this),
-                    OpenLayers.Function.bind(this.failure, this),
-                    options
-                );
+                this.getCurrentLocation();
             }
+            return true;
         }
-        return OpenLayers.Control.prototype.activate.apply(
-            this, arguments
-        );
+        return false;
     },
 
     /**
@@ -156,6 +150,25 @@
     },
 
     /**
+     * APIMethod: getCurrentLocation
+     *
+     * Returns:
+     * {Boolean} Returns true if a event will be fired (successfull
+     * registration)
+     */
+    getCurrentLocation: function() {
+        if (!this.active || this.watch) {
+            return false;
+        }
+        this.geolocation.getCurrentPosition(
+            OpenLayers.Function.bind(this.geolocate, this),
+            OpenLayers.Function.bind(this.failure, this),
+            this.geolocationOptions
+        );
+        return true;
+    },
+
+    /**
      * Method: failure
      * method called on browser's geolocation failure
      *

Modified: sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Kinetic.js
===================================================================
--- sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Kinetic.js	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/lib/OpenLayers/Kinetic.js	2011-02-23 14:19:11 UTC (rev 11324)
@@ -63,7 +63,6 @@
 
     /**
      * Method: begin
-     *
      * Begins the dragging.
      */
     begin: function() {
@@ -74,8 +73,10 @@
 
     /**
      * Method: update
+     * Updates during the dragging.
      *
-     * Updates during the dragging.
+     * Parameters:
+     * xy - {<OpenLayers.Pixel>} The new position.
      */
     update: function(xy) {
         this.points.unshift({xy: xy, tick: new Date().getTime()});
@@ -86,8 +87,15 @@
 
     /**
      * Method: end
+     * Ends the dragging, start the kinetic.
      *
-     * Ends the dragging, start the kinetic.
+     * Parameters:
+     * xy - {<OpenLayers.Pixel>} The last position.
+     *
+     * Returns:
+     * {Object} An object with two properties: "speed", and "theta". The
+     *     "speed" and "theta" values are to be passed to the move 
+     *     function when starting the animation.
      */
     end: function(xy) {
         var last, now = new Date().getTime();
@@ -117,12 +125,13 @@
 
     /**
      * Method: move
-     *
      * Launch the kinetic move pan.
      *
      * Parameters:
-     * info - {Object}
-     * callback - arguments x, y (values to pan), end (is the last point)
+     * info - {Object} An object with two properties, "speed", and "theta".
+     *     These values are those returned from the "end" call.
+     * callback - {Function} Function called on every step of the animation,
+     *     receives x, y (values to pan), end (is the last point).
      */
     move: function(info, callback) {
         var v0 = info.speed;

Modified: sandbox/camptocamp/mobile/openlayers/tests/Control/Geolocate.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/tests/Control/Geolocate.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/tests/Control/Geolocate.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -62,6 +62,31 @@
         map.removeControl(control);
         map.setCenter(centerLL);
     }
+    function test_getCurrentLocation(t) {
+        t.plan(5);
+        var control = new OpenLayers.Control.Geolocate({
+            geolocation: geolocation
+        });
+        map.addControl(control);
+        t.eq(control.getCurrentLocation(), false, 'getCurrentLocation return false if control hasnt been activated');
+        control.activate();
+        map.setCenter(centerLL);
+        t.eq(control.getCurrentLocation(), true, 'getCurrentLocation return true if control has been activated');
+        var center = map.getCenter();
+        t.eq(center.lon, 10, 'bound control sets the map lon when calling getCurrentLocation');
+        t.eq(center.lat, 10, 'bound control sets the map lat when calling getCurrentLocation');
+        control.deactivate();
+        map.removeControl(control);
+        map.setCenter(centerLL);
+        var control2 = new OpenLayers.Control.Geolocate({
+            geolocation: geolocation
+        });
+        map.addControl(control2);
+        t.eq(control2.getCurrentLocation(), false, 'getCurrentLocation return false if control is in watch mode');
+        control2.deactivate();
+        map.removeControl(control2);
+        map.setCenter(centerLL);
+    }
     function test_watch(t) {
         t.plan(2);
         var control = new OpenLayers.Control.Geolocate({

Modified: sandbox/camptocamp/mobile/openlayers/tests/Control/PanZoom.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/tests/Control/PanZoom.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/tests/Control/PanZoom.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -72,65 +72,65 @@
                     
                     simulateClick(wnd, wnd.control.buttons[0]);
                     t.delay_call(2, function() {
-                        t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" );
-                        t.ok(!flag.mousedown, "mousedown does not get to the map");
-                        t.ok(flag.mouseup, "mouseup does get to the map");
-                        t.ok(!flag.click, "click does not get to the map");
-                        t.ok(!flag.dblclick, "dblclick does not get to the map");
+                        t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "1) Pan up works correctly" );
+                        t.ok(!flag.mousedown, "1) mousedown does not get to the map");
+                        t.ok(flag.mouseup, "1) mouseup does get to the map");
+                        t.ok(!flag.click, "1) click does not get to the map");
+                        t.ok(!flag.dblclick, "1) dblclick does not get to the map");
                         resetFlags();
 
                         simulateClick(wnd, wnd.control.buttons[1]);
                     }, 2, function() {    
-                    t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "2) Pan left works correctly" );
+                    t.ok(!flag.mousedown, "2) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "2) mouseup does get to the map");
+                    t.ok(!flag.click, "2) click does not get to the map");
+                    t.ok(!flag.dblclick, "2) dblclick does not get to the map");
                     resetFlags();
 
                     simulateClick(wnd, wnd.control.buttons[2]);
                     }, 2, function() {
-                    t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "3) Pan right works correctly" );
+                    t.ok(!flag.mousedown, "3) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "3) mouseup does get to the map");
+                    t.ok(!flag.click, "3) click does not get to the map");
+                    t.ok(!flag.dblclick, "3) dblclick does not get to the map");
                     resetFlags();
 
                     simulateClick(wnd, wnd.control.buttons[3]);
                     }, 2, function() {
-                    t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "4) Pan down works correctly" );
+                    t.ok(!flag.mousedown, "4) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "4) mouseup does get to the map");
+                    t.ok(!flag.click, "4) click does not get to the map");
+                    t.ok(!flag.dblclick, "4) dblclick does not get to the map");
                     resetFlags();
 
                     simulateClick(wnd, wnd.control.buttons[4]);
                     }, 2, function() {
-                    t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.eq( wnd.mapper.getZoom(), 6, "5) zoomin works correctly" );
+                    t.ok(!flag.mousedown, "5) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "5) mouseup does get to the map");
+                    t.ok(!flag.click, "5) click does not get to the map");
+                    t.ok(!flag.dblclick, "5) dblclick does not get to the map");
                     resetFlags();
 
                     simulateClick(wnd, wnd.control.buttons[6]);
                     }, 2, function() {
-                    t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.eq( wnd.mapper.getZoom(), 5, "6) zoomout works correctly" );
+                    t.ok(!flag.mousedown, "6) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "6) mouseup does get to the map");
+                    t.ok(!flag.click, "6) click does not get to the map");
+                    t.ok(!flag.dblclick, "6) dblclick does not get to the map");
                     resetFlags();
 
                     simulateClick(wnd, wnd.control.buttons[5]);
                     }, 2, function() {
-                    t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" );
-                    t.ok(!flag.mousedown, "mousedown does not get to the map");
-                    t.ok(flag.mouseup, "mouseup does get to the map");
-                    t.ok(!flag.click, "click does not get to the map");
-                    t.ok(!flag.dblclick, "dblclick does not get to the map");
+                    t.eq( wnd.mapper.getZoom(), 2, "7) zoomworld works correctly" );
+                    t.ok(!flag.mousedown, "7) mousedown does not get to the map");
+                    t.ok(flag.mouseup, "7) mouseup does get to the map");
+                    t.ok(!flag.click, "7) click does not get to the map");
+                    t.ok(!flag.dblclick, "7) dblclick does not get to the map");
                     resetFlags();
                     });
                 });

Modified: sandbox/camptocamp/mobile/openlayers/tests/Layer/EventPane.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/tests/Layer/EventPane.html	2011-02-23 14:13:37 UTC (rev 11323)
+++ sandbox/camptocamp/mobile/openlayers/tests/Layer/EventPane.html	2011-02-23 14:19:11 UTC (rev 11324)
@@ -58,11 +58,11 @@
 //         t.plan( 2 );    
 
         if (OpenLayers.BROWSER_NAME != "firefox" && OpenLayers.BROWSER_NAME != "mozilla") {
-          t.plan(4);
+            t.plan(5);
         } else {
-          t.plan(0);
-          t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.") 
-          return;
+            t.plan(0);
+            t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.") 
+            return;
         }
         var map = new OpenLayers.Map('map');
         
@@ -84,19 +84,24 @@
         layer2.getWarningHTML = function() { this.warning = true; return ""; }
 
         map.addLayer(layer2);
-        t.ok( !layer2.warning, "warning not registered on mapObject load" );
+        t.ok(!layer2.warning, "warning not registered on mapObject load");
 
-        map.events.register("mousemove", map, function () {
-            t.ok(true, "got mouse move");
+        var log = [];
+        map.events.register("mousemove", map, function(event) {
+            log.push(event);
         });
         
-        if( document.createEvent ) { // Mozilla
-          var evObj = document.createEvent('MouseEvents');
-          evObj.initEvent( 'mousemove', true, false );
-          layer.pane.dispatchEvent(evObj);
-        } else if( document.createEventObject ) { // IE
-          layer.pane.fireEvent('onmousemove');
+        if (document.createEvent) { // Mozilla
+            var evObj = document.createEvent('MouseEvents');
+            evObj.initEvent('mousemove', true, false);
+            layer.pane.dispatchEvent(evObj);
+        } else if(document.createEventObject) { // IE
+            layer.pane.fireEvent('onmousemove');
         }
+        
+        t.eq(log.length, 1, "got one event");
+        t.eq(log[0] && log[0].type, "mousemove", "got mousemove event");
+        
     }
 
     function test_Layer_EventPane_setVisibility (t) {



More information about the Commits mailing list