[OpenLayers-Commits] r11512 - in sandbox/ahocevar/layercontainer: . build examples lib/OpenLayers/Handler lib/OpenLayers/Layer tests/Control tests/Handler tools

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Feb 25 10:25:12 EST 2011


Author: ahocevar
Date: 2011-02-25 07:25:11 -0800 (Fri, 25 Feb 2011)
New Revision: 11512

Added:
   sandbox/ahocevar/layercontainer/examples/mobile-base.js
Modified:
   sandbox/ahocevar/layercontainer/
   sandbox/ahocevar/layercontainer/build/build.py
   sandbox/ahocevar/layercontainer/examples/accelerometer.html
   sandbox/ahocevar/layercontainer/examples/bing.html
   sandbox/ahocevar/layercontainer/examples/mobile-jq.html
   sandbox/ahocevar/layercontainer/examples/mobile-navigation.js
   sandbox/ahocevar/layercontainer/examples/mobile-sencha.html
   sandbox/ahocevar/layercontainer/examples/mobile.html
   sandbox/ahocevar/layercontainer/examples/mobile.js
   sandbox/ahocevar/layercontainer/examples/spherical-mercator.html
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Click.js
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Feature.js
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/VirtualEarth.js
   sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html
   sandbox/ahocevar/layercontainer/tests/Handler/Click.html
   sandbox/ahocevar/layercontainer/tests/Handler/Feature.html
   sandbox/ahocevar/layercontainer/tools/release.sh
Log:
merging from trunk


Property changes on: sandbox/ahocevar/layercontainer
___________________________________________________________________
Modified: svn:mergeinfo
   - /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11266-11374,11376-11383,11385-11397,11400-11413,11415-11446,11448-11486,11489-11492
   + /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11266-11374,11376-11383,11385-11397,11400-11413,11415-11446,11448-11486,11489-11492,11494-11511

Modified: sandbox/ahocevar/layercontainer/build/build.py
===================================================================
--- sandbox/ahocevar/layercontainer/build/build.py	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/build/build.py	2011-02-25 15:25:11 UTC (rev 11512)
@@ -15,7 +15,7 @@
     try:
         import closure
         have_compressor.append("closure")
-    except ImportError, E:
+    except Exception, E:
         print "No closure (%s) % E"
     try:
         import closure_ws

Modified: sandbox/ahocevar/layercontainer/examples/accelerometer.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/accelerometer.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/accelerometer.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -70,10 +70,16 @@
 <h1 id="title">Accelerometer</h1>
 
 <p id="shortdesc">
-    The goal of this script is to demonstrate the usage of accelerometer.<br>
-    The orientation specification can be found <a href="http://dev.w3.org/geo/api/spec-source-orientation.html">here</a>.
+    The goal of this script is to demonstrate the usage of accelerometer.
 </p>
+<p>
+  The orientation specification can be found <a href="http://dev.w3.org/geo/api/spec-source-orientation.html">here</a>.
+</p>
 
+<div id="tags">
+  browser, vendor, mobile, orientation 
+</div>  
+
 <h1>Device motion</h1>
 
 <div id="resultDeviceMotion">

Modified: sandbox/ahocevar/layercontainer/examples/bing.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/bing.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/bing.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -12,9 +12,18 @@
     <script>
 
         var map;
-
+ 
         function init(){
-            map = new OpenLayers.Map("map");
+            // setting restrictedExtent so that we can use the 
+            // VirtualEarth-layers, see e.g. 
+            // http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/VirtualEarth-js.html
+            var restrictedExtent = new OpenLayers.Bounds(-20037508, -20037508, 
+                20037508, 20037508);
+            
+            map = new OpenLayers.Map("map", {
+                restrictedExtent: restrictedExtent
+            });
+            
             map.addControl(new OpenLayers.Control.LayerSwitcher());
 
             var shaded = new OpenLayers.Layer.VirtualEarth("Shaded", {

Copied: sandbox/ahocevar/layercontainer/examples/mobile-base.js (from rev 11511, trunk/openlayers/examples/mobile-base.js)
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile-base.js	                        (rev 0)
+++ sandbox/ahocevar/layercontainer/examples/mobile-base.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -0,0 +1,108 @@
+// API key for http://openlayers.org. Please get your own at
+// http://bingmapsportal.com/ and use that instead.
+var apiKey = "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf";
+
+// initialize map when page ready
+var map;
+var gg = new OpenLayers.Projection("EPSG:4326");
+var sm = new OpenLayers.Projection("EPSG:900913");
+
+var init = function () {
+
+    var vector = new OpenLayers.Layer.Vector("Vector Layer", {});
+
+    var geolocate = new OpenLayers.Control.Geolocate({
+        id: 'locate-control',
+        geolocationOptions: {
+            enableHighAccuracy: false,
+            maximumAge: 0,
+            timeout: 7000
+        }
+    });
+    // create map
+    map = new OpenLayers.Map({
+        div: "map",
+        theme: null,
+        projection: sm,
+        units: "m",
+        numZoomLevels: 18,
+        maxResolution: 156543.0339,
+        maxExtent: new OpenLayers.Bounds(
+            -20037508.34, -20037508.34, 20037508.34, 20037508.34
+        ),
+        controls: [
+            new OpenLayers.Control.Attribution(),
+            new OpenLayers.Control.TouchNavigation({
+                dragPanOptions: {
+                    interval: 100,
+                    enableKinetic: true
+                }
+            }),
+            geolocate
+        ],
+        layers: [
+            new OpenLayers.Layer.OSM("OpenStreetMap", null, {
+                transitionEffect: 'resize'
+            }),
+            new OpenLayers.Layer.Bing({
+                key: apiKey,
+                type: "Road",
+                // custom metadata parameter to request the new map style - only useful
+                // before May 1st, 2011
+                metadataParams: {
+                    mapVersion: "v1"
+                },
+                name: "Bing Road",
+                transitionEffect: 'resize'
+            }),
+            new OpenLayers.Layer.Bing({
+                key: apiKey,
+                type: "Aerial",
+                name: "Bing Aerial",
+                transitionEffect: 'resize'
+            }),
+            new OpenLayers.Layer.Bing({
+                key: apiKey,
+                type: "AerialWithLabels",
+                name: "Bing Aerial + Labels",
+                transitionEffect: 'resize'
+            }), 
+            vector
+        ]
+    });
+    map.zoomToMaxExtent();
+
+    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());
+    });
+};

Modified: sandbox/ahocevar/layercontainer/examples/mobile-jq.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile-jq.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/mobile-jq.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -11,7 +11,7 @@
         <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="../lib/OpenLayers.js"></script>
-        <script src="mobile.js"></script>
+        <script src="mobile-base.js"></script>
         <style>
             html {
                 height: 100%;

Modified: sandbox/ahocevar/layercontainer/examples/mobile-navigation.js
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile-navigation.js	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/mobile-navigation.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -1,17 +1,30 @@
-var map, layer;
+var map;
+
 function init() {
-    map = new OpenLayers.Map('map', { controls: [
-        new OpenLayers.Control.TouchNavigation({
-            dragPanOptions: {
-                interval: 0, // non-zero kills performance on some mobile phones
-                enableKinetic: true
-            }
-        }),
-        new OpenLayers.Control.ZoomPanel()
-    ] });
-    layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
-            "http://vmap0.tiles.osgeo.org/wms/vmap0",
-            {layers: 'basic'} );
-    map.addLayer(layer);
-    map.setCenter(new OpenLayers.LonLat(5, 40), 2);
+    map = new OpenLayers.Map({
+        div: "map",
+        theme: null,
+        projection: new OpenLayers.Projection("EPSG:900913"),
+        units: "m",
+        numZoomLevels: 18,
+        maxResolution: 156543.0339,
+        maxExtent: new OpenLayers.Bounds(
+            -20037508.34, -20037508.34, 20037508.34, 20037508.34
+        ),
+        controls: [
+            new OpenLayers.Control.TouchNavigation({
+                dragPanOptions: {
+                    interval: 100,
+                    enableKinetic: true
+                }
+            }),
+            new OpenLayers.Control.ZoomPanel()
+        ],
+        layers: [
+            new OpenLayers.Layer.OSM("OpenStreetMap", null, {
+                transitionEffect: 'resize'
+            })
+        ]
+    });
+    map.setCenter(new OpenLayers.LonLat(0, 0), 3);
 }

Modified: sandbox/ahocevar/layercontainer/examples/mobile-sencha.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile-sencha.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/mobile-sencha.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -10,7 +10,7 @@
         <link rel="stylesheet" href="http://dev.sencha.com/deploy/touch/resources/css/sencha-touch.css">
         <script src="http://dev.sencha.com/deploy/touch/sencha-touch.js"></script>
         <script src="mobile-sencha.js"></script>
-        <script src="mobile.js"></script>
+        <script src="mobile-base.js"></script>
         <style>
             .searchList {
                 min-height: 150px;

Modified: sandbox/ahocevar/layercontainer/examples/mobile.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/mobile.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -2,6 +2,7 @@
 <html>
     <head>
         <title>OpenLayers Mobile</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
         <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0;">
         <meta name="apple-mobile-web-app-capable" content="yes">
         <link rel="stylesheet" href="style.mobile.css" type="text/css">
@@ -9,20 +10,61 @@
         <script src="mobile.js"></script>
         <style>
             html, body {
-                margin: 0;
-                padding: 0;
-                height: 100%;
+                margin  : 0;
+                padding : 0;
+                height  : 100%;
+                width   : 100%;
             }
+            @media only screen and (max-width: 600px) {
+                html, body {
+                    height  : 117%;
+                }
+            }
             #map {
-                position: relative;
-                width: 100%;
-                height: 100%;
+                width    : 100%;
+                position : relative;
+                height   : 100%;
             }
             .olControlAttribution {
-                font-size: 10px;
-                bottom: 5px;
-                right: 5px;
+                position      : absolute;
+                font-size     : 10px;
+                bottom        : 0 !important;
+                right         : 0 !important;
+                background    : rgba(0,0,0,0.1);
+                font-family   : Arial;
+                padding       : 2px 4px;
+                border-radius : 5px 0 0 0;
             }
+            div.olControlZoomPanel .olControlZoomInItemInactive,
+            div.olControlZoomPanel .olControlZoomOutItemInactive {
+                background: rgba(0,0,0,0.2);
+                position: absolute;
+            }
+            div.olControlZoomPanel .olControlZoomInItemInactive {
+                border-radius: 5px 5px 0 0;
+            }
+            div.olControlZoomPanel .olControlZoomOutItemInactive {
+                border-radius: 0 0 5px 5px ;
+                top: 37px;
+            }
+            div.olControlZoomPanel .olControlZoomOutItemInactive:after ,
+            div.olControlZoomPanel .olControlZoomInItemInactive:after{
+                font-weight: bold;
+                content   : '+';
+                font-size : 36px;
+                padding:  7px;
+                z-index: 2000;
+                color     : #fff;
+                line-height: 1em;
+            }
+            div.olControlZoomPanel .olControlZoomOutItemInactive:after{
+                content: '–';
+                line-height: 0.9em;
+                padding: 0 8px;
+            }
+            div.olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
+                display: none;
+            }
             #title, #tags, #shortdesc {
                 display: none;
             }

Modified: sandbox/ahocevar/layercontainer/examples/mobile.js
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile.js	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/mobile.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -1,107 +1,40 @@
-// API key for http://openlayers.org. Please get your own at
-// http://bingmapsportal.com/ and use that instead.
-var apiKey = "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf";
-
 // initialize map when page ready
 var map;
-var gg = new OpenLayers.Projection("EPSG:4326");
-var sm = new OpenLayers.Projection("EPSG:900913");
-var init = function () {
 
-    var vector = new OpenLayers.Layer.Vector("Vector Layer", {});
-
-    var geolocate = new OpenLayers.Control.Geolocate({
-        id: 'locate-control',
-        geolocationOptions: {
-            enableHighAccuracy: false,
-            maximumAge: 0,
-            timeout: 7000
+// Get rid of address bar on iphone/ipod
+var fixSize = function() {
+    window.scrollTo(0,0);
+    document.body.style.height = '100%';
+    if (!(/(iphone|ipod)/.test(navigator.userAgent.toLowerCase()))) {
+        if (document.body.parentNode) {
+            document.body.parentNode.style.height = '100%';
         }
-    });
+    }
+};
+setTimeout(fixSize, 700);
+setTimeout(fixSize, 1500);
+
+var init = function () {
     // create map
     map = new OpenLayers.Map({
         div: "map",
         theme: null,
-        projection: sm,
-        units: "m",
-        numZoomLevels: 18,
-        maxResolution: 156543.0339,
-        maxExtent: new OpenLayers.Bounds(
-            -20037508.34, -20037508.34, 20037508.34, 20037508.34
-        ),
         controls: [
             new OpenLayers.Control.Attribution(),
             new OpenLayers.Control.TouchNavigation({
                 dragPanOptions: {
-                    interval: 0, // non-zero kills performance on some mobile phones
+                    interval: 100,
                     enableKinetic: true
                 }
             }),
-            geolocate
+            new OpenLayers.Control.ZoomPanel()
         ],
         layers: [
             new OpenLayers.Layer.OSM("OpenStreetMap", null, {
                 transitionEffect: 'resize'
-            }),
-            new OpenLayers.Layer.Bing({
-                key: apiKey,
-                type: "Road",
-                // custom metadata parameter to request the new map style - only useful
-                // before May 1st, 2011
-                metadataParams: {
-                    mapVersion: "v1"
-                },
-                name: "Bing Road",
-                transitionEffect: 'resize'
-            }),
-            new OpenLayers.Layer.Bing({
-                key: apiKey,
-                type: "Aerial",
-                name: "Bing Aerial",
-                transitionEffect: 'resize'
-            }),
-            new OpenLayers.Layer.Bing({
-                key: apiKey,
-                type: "AerialWithLabels",
-                name: "Bing Aerial + Labels",
-                transitionEffect: 'resize'
-            }), 
-            vector
-        ]
+            })
+        ],
+        center: new OpenLayers.LonLat(742000, 5861000),
+        zoom: 3
     });
-    map.zoomToMaxExtent();
-
-    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());
-    });
 };

Modified: sandbox/ahocevar/layercontainer/examples/spherical-mercator.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/spherical-mercator.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/examples/spherical-mercator.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -24,107 +24,111 @@
     <script src="../lib/OpenLayers.js"></script>
     <script type="text/javascript">
 
-        // make map available for easy debugging
-        var map;
+// make map available for easy debugging
+var map;
 
-        // increase reload attempts 
-        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
+// increase reload attempts 
+OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
 
-        function init(){
-            var options = {
-                projection: new OpenLayers.Projection("EPSG:900913"),
-                displayProjection: new OpenLayers.Projection("EPSG:4326"),
-                units: "m",
-                numZoomLevels: 18,
-                maxResolution: 156543.0339,
-                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
-                                                 20037508, 20037508.34)
-            };
-            map = new OpenLayers.Map('map', options);
+function init(){
+    var maxExtent = new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),
+        restrictedExtent = maxExtent.clone(-20037508, -20037508, 20037508, 20037508),
+        maxResolution = 156543.0339;
+    
+    var options = {
+        projection: new OpenLayers.Projection("EPSG:900913"),
+        displayProjection: new OpenLayers.Projection("EPSG:4326"),
+        units: "m",
+        numZoomLevels: 18,
+        maxResolution: maxResolution,
+        maxExtent: maxExtent,
+        restrictedExtent: restrictedExtent
+    };
+    map = new OpenLayers.Map('map', options);
 
-            // create Google Mercator layers
-            var gmap = new OpenLayers.Layer.Google(
-                "Google Streets",
-                {'sphericalMercator': true}
-            );
-            var gsat = new OpenLayers.Layer.Google(
-                "Google Satellite",
-                {type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 22}
-            );
-            var ghyb = new OpenLayers.Layer.Google(
-                "Google Hybrid",
-                {type: G_HYBRID_MAP, 'sphericalMercator': true}
-            );
+    // create Google Mercator layers
+    var gmap = new OpenLayers.Layer.Google(
+        "Google Streets",
+        {sphericalMercator: true}
+    );
+    var gsat = new OpenLayers.Layer.Google(
+        "Google Satellite",
+        {type: G_SATELLITE_MAP, sphericalMercator: true, numZoomLevels: 22}
+    );
+    var ghyb = new OpenLayers.Layer.Google(
+        "Google Hybrid",
+        {type: G_HYBRID_MAP, sphericalMercator: true}
+    );
 
-            // create Virtual Earth layers
-            var veroad = new OpenLayers.Layer.VirtualEarth(
-                "Virtual Earth Roads",
-                {'type': VEMapStyle.Road, 'sphericalMercator': true}
-            );
-            var veaer = new OpenLayers.Layer.VirtualEarth(
-                "Virtual Earth Aerial",
-                {'type': VEMapStyle.Aerial, 'sphericalMercator': true}
-            );
-            var vehyb = new OpenLayers.Layer.VirtualEarth(
-                "Virtual Earth Hybrid",
-                {'type': VEMapStyle.Hybrid, 'sphericalMercator': true}
-            );
+    // create Virtual Earth layers
+    var veroad = new OpenLayers.Layer.VirtualEarth(
+        "Virtual Earth Roads",
+        {'type': VEMapStyle.Road, sphericalMercator: true}
+    );
+    var veaer = new OpenLayers.Layer.VirtualEarth(
+        "Virtual Earth Aerial",
+        {'type': VEMapStyle.Aerial, sphericalMercator: true}
+    );
+    var vehyb = new OpenLayers.Layer.VirtualEarth(
+        "Virtual Earth Hybrid",
+        {'type': VEMapStyle.Hybrid, sphericalMercator: true}
+    );
 
-            // create Yahoo layer
-            var yahoo = new OpenLayers.Layer.Yahoo(
-                "Yahoo Street",
-                {'sphericalMercator': true}
-            );
-            var yahoosat = new OpenLayers.Layer.Yahoo(
-                "Yahoo Satellite",
-                {'type': YAHOO_MAP_SAT, 'sphericalMercator': true}
-            );
-            var yahoohyb = new OpenLayers.Layer.Yahoo(
-                "Yahoo Hybrid",
-                {'type': YAHOO_MAP_HYB, 'sphericalMercator': true}
-            );
+    // create Yahoo layer
+    var yahoo = new OpenLayers.Layer.Yahoo(
+        "Yahoo Street",
+        {sphericalMercator: true}
+    );
+    var yahoosat = new OpenLayers.Layer.Yahoo(
+        "Yahoo Satellite",
+        {'type': YAHOO_MAP_SAT, sphericalMercator: true}
+    );
+    var yahoohyb = new OpenLayers.Layer.Yahoo(
+        "Yahoo Hybrid",
+        {'type': YAHOO_MAP_HYB, sphericalMercator: true}
+    );
 
-            // create OSM layer
-            var mapnik = new OpenLayers.Layer.OSM();
-            // create OAM layer
-            var oam = new OpenLayers.Layer.XYZ(
-                "OpenAerialMap",
-                "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/${z}/${x}/${y}.png",
-                {
-                    sphericalMercator: true
-                }
-            );
+    // create OSM layer
+    var mapnik = new OpenLayers.Layer.OSM();
+    // create OAM layer
+    var oam = new OpenLayers.Layer.XYZ(
+        "OpenAerialMap",
+        "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/${z}/${x}/${y}.png",
+        {
+            sphericalMercator: true
+        }
+    );
 
-            // create OSM layer
-            var osmarender = new OpenLayers.Layer.OSM(
-                "OpenStreetMap (Tiles at Home)",
-                "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
-            );
+    // create OSM layer
+    var osmarender = new OpenLayers.Layer.OSM(
+        "OpenStreetMap (Tiles at Home)",
+        "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
+    );
 
 
-            // create WMS layer
-            var wms = new OpenLayers.Layer.WMS(
-                "World Map",
-                "http://world.freemap.in/tiles/",
-                {'layers': 'factbook-overlay', 'format':'png'},
-                {
-                    'opacity': 0.4, visibility: false,
-                    'isBaseLayer': false,'wrapDateLine': true
-                }
-            );
+    // create WMS layer
+    var wms = new OpenLayers.Layer.WMS(
+        "World Map",
+        "http://world.freemap.in/tiles/",
+        {'layers': 'factbook-overlay', 'format':'png'},
+        {
+            'opacity': 0.4, visibility: false,
+            'isBaseLayer': false,'wrapDateLine': true
+        }
+    );
 
-            // create a vector layer for drawing
-            var vector = new OpenLayers.Layer.Vector("Editable Vectors");
+    // create a vector layer for drawing
+    var vector = new OpenLayers.Layer.Vector("Editable Vectors");
 
-            map.addLayers([gmap, gsat, ghyb, veroad, veaer, vehyb,
-                           yahoo, yahoosat, yahoohyb, oam, mapnik, osmarender,
-                           wms, vector]);
-            map.addControl(new OpenLayers.Control.LayerSwitcher());
-            map.addControl(new OpenLayers.Control.EditingToolbar(vector));
-            map.addControl(new OpenLayers.Control.Permalink());
-            map.addControl(new OpenLayers.Control.MousePosition());
-            if (!map.getCenter()) {map.zoomToMaxExtent()}
-        }
+    map.addLayers([gmap, gsat, ghyb, veroad, veaer, vehyb,
+                   yahoo, yahoosat, yahoohyb, oam, mapnik, osmarender,
+                   wms, vector]);
+    map.addControl(new OpenLayers.Control.LayerSwitcher());
+    map.addControl(new OpenLayers.Control.EditingToolbar(vector));
+    map.addControl(new OpenLayers.Control.Permalink());
+    map.addControl(new OpenLayers.Control.MousePosition());
+    if (!map.getCenter()) {map.zoomToMaxExtent()}
+}
 
     </script>
   </head>

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Click.js	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Click.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -85,24 +85,23 @@
     
     /**
      * Property: down
-     * {<OpenLayers.Pixel>} The pixel location of the last mousedown.
+     * {Object} Object that store relevant information about the last
+     *     mousedown or touchstart. Its 'xy' OpenLayers.Pixel property gives
+     *     the average location of the mouse/touch event. Its 'touches'
+     *     property records clientX/clientY of each touches.
      */
     down: null,
 
     /** 
      * Property: last
-     * {<OpenLayers.Pixel>} The pixel for the last touchmove. This is
-     * used to 
+     * {Object} Object that store relevant information about the last
+     *     touchmove. Its 'xy' OpenLayers.Pixel property gives
+     *     the average location of the mouse/touch event. Its 'touches'
+     *     property records clientX/clientY of each touches.
      */
     last: null,
 
     /**
-     * Property: touch
-     * {Boolean} Are we on a touch enabled device? Default is false.
-     */
-    touch: false,
-
-    /**
      * Property: rightclickTimerId
      * {Number} The id of the right mouse timeout waiting to clear the 
      *     <delayedEvent>.
@@ -130,7 +129,7 @@
         // optionally register for mouseup and mousedown
         if(this.pixelTolerance != null) {
             this.mousedown = function(evt) {
-                this.down = evt;
+                this.down = this.getEventInfo(evt);
                 return true;
             };
         }
@@ -154,8 +153,7 @@
      * {Boolean} Continue propagating this event.
      */
     touchstart: function(evt) {
-        this.touch = true;
-        this.down = evt;
+        this.down = this.getEventInfo(evt);
         this.last = null;
         return true;
     },
@@ -244,8 +242,9 @@
     dblclick: function(evt) {
         // for touch devices trigger dblclick only for
         // "one finger" touch
-        if(this.passesTolerance(evt) &&
-           (!evt.lastTouches || evt.lastTouches.length == 1)) {
+        var last = this.down || this.last;
+        if (this.passesTolerance(evt) &&
+            (!last || !last.touches || last.touches.length == 1)) {
             if(this["double"]) {
                 this.callback('dblclick', [evt]);
             }
@@ -260,7 +259,7 @@
      *    an empty "touches" property.
      */
     touchmove: function(evt) {
-        this.last = evt;
+        this.last = this.getEventInfo(evt);
     },
 
     /**
@@ -287,13 +286,14 @@
      */
     click: function(evt) {
         // Sencha Touch emulates click events, see ticket 3079 for more info
-        if (this.touch === true && evt.type === "click") {
+        if (this.down && this.down.touches && evt.type === "click") {
             return !this.stopSingle;
         }
         if(this.passesTolerance(evt)) {
             if(this.timerId != null) {
                 // already received a click
-                if(evt.lastTouches) {
+                var last = this.down || this.last;
+                if (last && last.touches && last.touches.length > 0) {
                     // touch device - we may trigger dblclick
                     this.dblclick(evt);
                 } else {
@@ -367,6 +367,35 @@
     },
 
     /**
+     * Method: getEventInfo
+     * This method allows us to store event information without storing the
+     *     actual event.  In touch devices (at least), the same event is 
+     *     modified between touchstart, touchmove, and touchend.
+     *
+     * Returns:
+     * {Object} An object with event related info.
+     */
+    getEventInfo: function(evt) {
+        var touches;
+        if (evt.touches) {
+            var len = evt.touches.length;
+            touches = new Array(len);
+            var touch;
+            for (var i=0; i<len; i++) {
+                touch = evt.touches[i];
+                touches[i] = {
+                    clientX: touch.clientX,
+                    clientY: touch.clientY
+                };
+            }
+        }
+        return {
+            xy: evt.xy,
+            touches: touches
+        };
+    },
+
+    /**
      * APIMethod: deactivate
      * Deactivate the handler.
      *

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Feature.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Feature.js	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Feature.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -29,7 +29,8 @@
         'mousemove': {'in': 'over', 'out': 'out'},
         'dblclick': {'in': 'dblclick', 'out': null},
         'mousedown': {'in': null, 'out': null},
-        'mouseup': {'in': null, 'out': null}
+        'mouseup': {'in': null, 'out': null},
+        'touchstart': {'in': 'click', 'out': 'clickout'}
     },
 
     /**
@@ -117,6 +118,19 @@
         this.layer = layer;
     },
 
+    /**
+     * Method: touchstart
+     * Handle touchmove events
+     *
+     * Parameters:
+     * evt - {Event}
+     *
+     * Returns:
+     * {Boolean} Let the event propagate.
+     */
+    touchstart: function(evt) {
+        return this.mousedown(evt);
+    },
 
     /**
      * Method: mousedown

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/VirtualEarth.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/VirtualEarth.js	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/VirtualEarth.js	2011-02-25 15:25:11 UTC (rev 11512)
@@ -13,7 +13,11 @@
 
 /**
  * Class: OpenLayers.Layer.VirtualEarth
- * 
+ * Instances of OpenLayers.Layer.VirtualEarth are used to display the data from
+ *     the Bing Maps AJAX Control (see e.g. 
+ *     http://msdn.microsoft.com/library/bb429619.aspx). Create a VirtualEarth 
+ *     layer with the <OpenLayers.Layer.VirtualEarth> constructor.
+ *     
  * Inherits from:
  *  - <OpenLayers.Layer.EventPane>
  *  - <OpenLayers.Layer.FixedZoomLevels>
@@ -94,7 +98,23 @@
 
     /** 
      * Constructor: OpenLayers.Layer.VirtualEarth
+     * Creates a new instance of a OpenLayers.Layer.VirtualEarth. If you use an
+     *     instance of OpenLayers.Layer.VirtualEarth in you map, you should set 
+     *     the <OpenLayers.Map> option restrictedExtent to a meaningful value,
+     *     e.g.:
+     * (code)
+     * var map = new OpenLayers.Map( 'map', {
+     *     // other map options
+     *     restrictedExtent : OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)
+     * } );
      * 
+     * var veLayer = new OpenLayers.Layer.VirtualEarth (
+     *     "Virtual Earth Layer"
+     * );
+     * 
+     * map.addLayer( veLayer );
+     * (end)
+     * 
      * Parameters:
      * name - {String}
      * options - {Object}

Modified: sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -1,6 +1,6 @@
 <html>
 <head>
-  <script src="../../lib/OpenLayers.js"></script>
+  <script src="../OLLoader.js"></script>
   <script type="text/javascript">
     var map, control, centerLL
         watch = null,

Modified: sandbox/ahocevar/layercontainer/tests/Handler/Click.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Handler/Click.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/tests/Handler/Click.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -316,14 +316,14 @@
 
         log = null;
         handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
-        handler.touchend({});
+        handler.touchend({touches: ["foo"]});
 
         t.delay_call(1, function() {
             t.ok(log != null, "click callback called");
             if(log != null) {
                 t.eq(log.x, 1, "evt.xy.x as expected");
                 t.eq(log.y, 1, "evt.xy.y as expected");
-                t.eq(log.lastTouches, ["foo"], "evt.lastTouches as expected");
+                t.ok(log.lastTouches, "evt.lastTouches as expected");
             }
             // tear down
             map.destroy();
@@ -359,7 +359,7 @@
         handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
         handler.touchend({type: "click"});
 
-        t.eq(handler.touch, true, "Touch property should be true");
+        t.eq(!!handler.down.touches, true, "Handler down touches property should be truthy");
         
         t.ok(log.dblclick == undefined, "dblclick callback not called with simulated click");
 
@@ -395,9 +395,9 @@
         // test
 
         log = {};
-        handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
+        handler.touchstart({xy: {x: 1, y: 1}, touches: [{clientX:0, clientY:10}]});
         handler.touchend({});
-        handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
+        handler.touchstart({xy: {x: 1, y: 1}, touches: [{clientX:0, clientY:10}]});
         handler.touchend({});
 
         t.eq(log.click, undefined, "click callback not called");
@@ -405,7 +405,7 @@
         if(log.dblclick != undefined) {
             t.eq(log.dblclick.x, 1, "evt.xy.x as expected");
             t.eq(log.dblclick.y, 1, "evt.xy.y as expected");
-            t.eq(log.dblclick.lastTouches, ["foo"], "evt.lastTouches as expected");
+            t.ok(log.dblclick.lastTouches, "evt.lastTouches on evt");
         }
 
         // tear down

Modified: sandbox/ahocevar/layercontainer/tests/Handler/Feature.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Handler/Feature.html	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/tests/Handler/Feature.html	2011-02-25 15:25:11 UTC (rev 11512)
@@ -53,7 +53,7 @@
         
     }
     function test_events(t) {
-        t.plan(25);
+        t.plan(30);
         
         var map = new OpenLayers.Map('map');
         var control = new OpenLayers.Control();
@@ -64,7 +64,7 @@
  
         // list below events that should be handled (events) and those
         // that should not be handled (nonevents) by the handler
-        var events = ["mousedown", "mouseup", "mousemove", "click", "dblclick"];
+        var events = ["mousedown", "mouseup", "mousemove", "click", "dblclick", "touchstart"];
         var nonevents = ["mouseout", "resize", "focus", "blur"];
         map.events.registerPriority = function(type, obj, func) {
             var output = func();
@@ -123,7 +123,7 @@
     }
 
     function test_callbacks(t) {
-        t.plan(9);
+        t.plan(13);
         
         var map = new OpenLayers.Map('map', {controls: []});
         var control = new OpenLayers.Control();
@@ -223,6 +223,36 @@
         callbacks['dblclick'] = getCallback('dblclick', newFeature);
         evtPx.type = "dblclick";
         map.events.triggerEvent('dblclick', evtPx);
+
+        // test touchstart on a feature
+        // 'click' callback should be called
+        handler.feature = null;
+        lastFeature = null;
+        newFeature = new OpenLayers.Feature.Vector();
+        newFeature.layer = layer;
+        callbacks['click'] = getCallback('click (touch)', newFeature);
+        callbacks['clickout'] = getCallback('clickout (touch)', lastFeature);
+        evtPx.type = "touchstart";
+        map.events.triggerEvent('touchstart', evtPx);
+
+        // test touchstart in new feature and out of last feature
+        // both 'click' and 'clickout' callbacks should be called
+        lastFeature = newFeature;
+        newFeature = new OpenLayers.Feature.Vector();
+        newFeature.layer = layer;
+        callbacks['click'] = getCallback('click (touch)', newFeature);
+        callbacks['clickout'] = getCallback('clickout (touch)', lastFeature);
+        evtPx.type = "touchstart";
+        map.events.triggerEvent('touchstart', evtPx);
+
+        // test touchstart out of last feature
+        // only 'clickout' callback should be called
+        lastFeature = newFeature;
+        newFeature = null;
+        callbacks['click'] = getCallback('click (touch)', newFeature);
+        callbacks['clickout'] = getCallback('clickout (touch)', lastFeature);
+        evtPx.type = "touchstart";
+        map.events.triggerEvent('touchstart', evtPx);
     }
 
     function test_deactivate(t) {

Modified: sandbox/ahocevar/layercontainer/tools/release.sh
===================================================================
--- sandbox/ahocevar/layercontainer/tools/release.sh	2011-02-25 15:22:50 UTC (rev 11511)
+++ sandbox/ahocevar/layercontainer/tools/release.sh	2011-02-25 15:25:11 UTC (rev 11512)
@@ -13,7 +13,9 @@
 rm ../tools/closure-compiler.jar
 
 cd ..
-
+cd tools
+python exampleparser.py
+cd ..
 for i in google ie6-style style; do
     csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css
 done    



More information about the Commits mailing list