[OpenLayers-Commits] r11553 - in sandbox/tschaub/canvas: . build
examples examples/img img lib lib/Firebug lib/OpenLayers
lib/OpenLayers/BaseTypes lib/OpenLayers/Control
lib/OpenLayers/Handler lib/OpenLayers/Layer tests
tests/BaseTypes tests/Control tests/Handler tests/Layer
tests/node.js theme/default/img tools
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Sun Feb 27 05:37:40 EST 2011
Author: tschaub
Date: 2011-02-27 02:37:39 -0800 (Sun, 27 Feb 2011)
New Revision: 11553
Added:
sandbox/tschaub/canvas/build/mobile.cfg
sandbox/tschaub/canvas/examples/accelerometer.html
sandbox/tschaub/canvas/examples/game-accel-ball.html
sandbox/tschaub/canvas/examples/img/check-round-green.png
sandbox/tschaub/canvas/examples/img/check-round-grey.png
sandbox/tschaub/canvas/examples/img/list.png
sandbox/tschaub/canvas/examples/img/locate.png
sandbox/tschaub/canvas/examples/img/minus1.png
sandbox/tschaub/canvas/examples/img/mobile-layers.png
sandbox/tschaub/canvas/examples/img/mobile-loc.png
sandbox/tschaub/canvas/examples/img/openlayers.png
sandbox/tschaub/canvas/examples/mobile-base.js
sandbox/tschaub/canvas/examples/mobile-jq.js
sandbox/tschaub/canvas/examples/mobile-sencha.js
sandbox/tschaub/canvas/examples/multitouch.html
sandbox/tschaub/canvas/examples/style.mobile-jq.css
sandbox/tschaub/canvas/lib/OpenLayers/Control/PinchZoom.js
sandbox/tschaub/canvas/tests/Control/PinchZoom.html
sandbox/tschaub/canvas/tests/node.js/
sandbox/tschaub/canvas/tests/node.js/mockdom.js
sandbox/tschaub/canvas/tests/node.js/node-tests.cfg
sandbox/tschaub/canvas/tests/node.js/node.js
sandbox/tschaub/canvas/tests/node.js/run-test.js
sandbox/tschaub/canvas/tests/node.js/run.sh
sandbox/tschaub/canvas/tools/closure.py
sandbox/tschaub/canvas/tools/closure_ws.py
Removed:
sandbox/tschaub/canvas/tests/node.js/mockdom.js
sandbox/tschaub/canvas/tests/node.js/node-tests.cfg
sandbox/tschaub/canvas/tests/node.js/node.js
sandbox/tschaub/canvas/tests/node.js/run-test.js
sandbox/tschaub/canvas/tests/node.js/run.sh
Modified:
sandbox/tschaub/canvas/
sandbox/tschaub/canvas/build/README.txt
sandbox/tschaub/canvas/build/build.py
sandbox/tschaub/canvas/examples/bing.html
sandbox/tschaub/canvas/examples/browser.html
sandbox/tschaub/canvas/examples/browser.js
sandbox/tschaub/canvas/examples/controls.html
sandbox/tschaub/canvas/examples/mobile-jq.html
sandbox/tschaub/canvas/examples/mobile-navigation.js
sandbox/tschaub/canvas/examples/mobile-sencha.html
sandbox/tschaub/canvas/examples/mobile.html
sandbox/tschaub/canvas/examples/mobile.js
sandbox/tschaub/canvas/examples/spherical-mercator.html
sandbox/tschaub/canvas/examples/tile-origin.html
sandbox/tschaub/canvas/img/cloud-popup-relative.png
sandbox/tschaub/canvas/img/drag-rectangle-off.png
sandbox/tschaub/canvas/img/drag-rectangle-on.png
sandbox/tschaub/canvas/img/east-mini.png
sandbox/tschaub/canvas/img/layer-switcher-maximize.png
sandbox/tschaub/canvas/img/layer-switcher-minimize.png
sandbox/tschaub/canvas/img/marker-blue.png
sandbox/tschaub/canvas/img/marker-gold.png
sandbox/tschaub/canvas/img/marker-green.png
sandbox/tschaub/canvas/img/marker.png
sandbox/tschaub/canvas/img/measuring-stick-off.png
sandbox/tschaub/canvas/img/measuring-stick-on.png
sandbox/tschaub/canvas/img/north-mini.png
sandbox/tschaub/canvas/img/panning-hand-off.png
sandbox/tschaub/canvas/img/panning-hand-on.png
sandbox/tschaub/canvas/img/slider.png
sandbox/tschaub/canvas/img/south-mini.png
sandbox/tschaub/canvas/img/west-mini.png
sandbox/tschaub/canvas/img/zoom-minus-mini.png
sandbox/tschaub/canvas/img/zoom-plus-mini.png
sandbox/tschaub/canvas/img/zoom-world-mini.png
sandbox/tschaub/canvas/img/zoombar.png
sandbox/tschaub/canvas/lib/Firebug/firebugx.js
sandbox/tschaub/canvas/lib/OpenLayers.js
sandbox/tschaub/canvas/lib/OpenLayers/BaseTypes/Pixel.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/Geolocate.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseDefaults.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseToolbar.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/Navigation.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/OverviewMap.js
sandbox/tschaub/canvas/lib/OpenLayers/Control/TouchNavigation.js
sandbox/tschaub/canvas/lib/OpenLayers/Events.js
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Box.js
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Feature.js
sandbox/tschaub/canvas/lib/OpenLayers/Handler/Pinch.js
sandbox/tschaub/canvas/lib/OpenLayers/Layer.js
sandbox/tschaub/canvas/lib/OpenLayers/Layer/EventPane.js
sandbox/tschaub/canvas/lib/OpenLayers/Layer/Grid.js
sandbox/tschaub/canvas/lib/OpenLayers/Layer/VirtualEarth.js
sandbox/tschaub/canvas/lib/OpenLayers/Map.js
sandbox/tschaub/canvas/tests/BaseTypes/Pixel.html
sandbox/tschaub/canvas/tests/Control/Geolocate.html
sandbox/tschaub/canvas/tests/Control/Navigation.html
sandbox/tschaub/canvas/tests/Handler/Click.html
sandbox/tschaub/canvas/tests/Handler/Feature.html
sandbox/tschaub/canvas/tests/Layer/ArcGIS93Rest.html
sandbox/tschaub/canvas/tests/Layer/Grid.html
sandbox/tschaub/canvas/tests/Layer/Image.html
sandbox/tschaub/canvas/tests/Layer/KaMap.html
sandbox/tschaub/canvas/tests/Layer/MapGuide.html
sandbox/tschaub/canvas/tests/Layer/MapServer.html
sandbox/tschaub/canvas/tests/Layer/TMS.html
sandbox/tschaub/canvas/tests/Layer/WMS.html
sandbox/tschaub/canvas/tests/Layer/WrapDateLine.html
sandbox/tschaub/canvas/tests/Layer/XYZ.html
sandbox/tschaub/canvas/tests/Map.html
sandbox/tschaub/canvas/tests/list-tests.html
sandbox/tschaub/canvas/theme/default/img/add_point_off.png
sandbox/tschaub/canvas/theme/default/img/drag-rectangle-off.png
sandbox/tschaub/canvas/theme/default/img/drag-rectangle-on.png
sandbox/tschaub/canvas/theme/default/img/draw_line_off.png
sandbox/tschaub/canvas/theme/default/img/draw_line_on.png
sandbox/tschaub/canvas/theme/default/img/draw_point_off.png
sandbox/tschaub/canvas/theme/default/img/draw_point_on.png
sandbox/tschaub/canvas/theme/default/img/draw_polygon_off.png
sandbox/tschaub/canvas/theme/default/img/draw_polygon_on.png
sandbox/tschaub/canvas/theme/default/img/editing_tool_bar.png
sandbox/tschaub/canvas/theme/default/img/move_feature_off.png
sandbox/tschaub/canvas/theme/default/img/move_feature_on.png
sandbox/tschaub/canvas/theme/default/img/navigation_history.png
sandbox/tschaub/canvas/theme/default/img/pan-panel-NOALPHA.png
sandbox/tschaub/canvas/theme/default/img/pan-panel.png
sandbox/tschaub/canvas/theme/default/img/pan_on.png
sandbox/tschaub/canvas/theme/default/img/panning-hand-off.png
sandbox/tschaub/canvas/theme/default/img/panning-hand-on.png
sandbox/tschaub/canvas/theme/default/img/remove_point_on.png
sandbox/tschaub/canvas/theme/default/img/save_features_off.png
sandbox/tschaub/canvas/theme/default/img/save_features_on.png
sandbox/tschaub/canvas/theme/default/img/view_next_off.png
sandbox/tschaub/canvas/theme/default/img/view_previous_off.png
sandbox/tschaub/canvas/theme/default/img/zoom-panel.png
sandbox/tschaub/canvas/tools/
sandbox/tschaub/canvas/tools/release.sh
sandbox/tschaub/canvas/tools/update_dev_dir.sh
Log:
Merge r11422:11552 from trunk.
Property changes on: sandbox/tschaub/canvas
___________________________________________________________________
Modified: svn:mergeinfo
- /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:10737-11416
+ /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:10737-11416,11422-11552
Modified: sandbox/tschaub/canvas/build/README.txt
===================================================================
--- sandbox/tschaub/canvas/build/README.txt 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/build/README.txt 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,14 +1,43 @@
+The OpenLayers build tool supports several different
+forms of compressing your javascript code, and a method
+of describing build profiles to create customized
+OpenLayers builds with only the components you need.
-## HowTo: Build & deploy "Shrunk" Single File Library version of OpenLayers ##
+When building a file, you can choose to build with several
+different compression options to the Python-based build.py
+script. The following is an example script:
- * Build:
+python build.py -c closure full OpenLayers-closure.js
- cd build
- ./build.py
- cd ..
+This script selects the 'closure' compression mechanism,
+uses a config file called 'full.cfg', and writes the output
+to OpenLayers-closure.js.
- * Upload the result to the server: e.g.
+The options available for compression are:
- scp build/OpenLayers.js openlayers at openlayers.org:openlayers.org/htdocs/code/
+ * closure
+ This requires you to have a closure-compiler.jar in your
+ tools directory. You can do this by fetching the compiler
+ from:
+ http://closure-compiler.googlecode.com/files/compiler-latest.zip
+ Then unzipping that file, and placing compiler.jar into tools
+ and renaming it closure-compiler.jar.
+
+ * closure_ws
+ This uses the closure compiler webservice. This will only work
+ for files source Javascript files which are under 1MB. (Note that
+ the default OpenLayers full build is not under 1MB.)
+
+ * jsmin
+ jsmin is the default compiler, and uses the Python-based
+ jsmin script to compress the Javascript.
+
+ * minimize
+ This is a simple whitespace removing Python script, designed
+ to fill in when other tools are unavailable.
+
+ * none
+ None will leave the Javascript uncompressed.
+
Modified: sandbox/tschaub/canvas/build/build.py
===================================================================
--- sandbox/tschaub/canvas/build/build.py 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/build/build.py 2011-02-27 10:37:39 UTC (rev 11553)
@@ -12,6 +12,16 @@
have_compressor.append("jsmin")
except ImportError:
print "No jsmin"
+ try:
+ import closure
+ have_compressor.append("closure")
+ except Exception, E:
+ print "No closure (%s) % E"
+ try:
+ import closure_ws
+ have_compressor.append("closure_ws")
+ except ImportError:
+ print "No closure_ws"
try:
import minimize
@@ -39,14 +49,16 @@
print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
+ print "Compressing using %s" % use_compressor
if use_compressor == "jsmin":
- print "Compressing using jsmin."
minimized = jsmin.jsmin(merged)
elif use_compressor == "minimize":
- print "Compressing using minimize."
minimized = minimize.minimize(merged)
+ elif use_compressor == "closure_ws":
+ minimized = closure_ws.minimize(merged)
+ elif use_compressor == "closure":
+ minimized = closure.minimize(merged)
else: # fallback
- print "Not compressing."
minimized = merged
print "Adding license file."
minimized = file("license.txt").read() + minimized
@@ -60,4 +72,11 @@
opt = optparse.OptionParser(usage="%s [options] [config_file] [output_file]\n Default config_file is 'full.cfg', Default output_file is 'OpenLayers.js'")
opt.add_option("-c", "--compressor", dest="compressor", help="compression method: one of 'jsmin', 'minimize', or 'none'", default="jsmin")
(options, args) = opt.parse_args()
- build(*args, options=options)
+ if not len(args):
+ build(options=options)
+ elif len(args) == 1:
+ build(args[0], options=options)
+ elif len(args) == 2:
+ build(args[0], args[1], options=options)
+ else:
+ print "Wrong number of arguments"
Copied: sandbox/tschaub/canvas/build/mobile.cfg (from rev 11552, trunk/openlayers/build/mobile.cfg)
===================================================================
--- sandbox/tschaub/canvas/build/mobile.cfg (rev 0)
+++ sandbox/tschaub/canvas/build/mobile.cfg 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,24 @@
+[first]
+
+[last]
+
+[include]
+OpenLayers/Map.js
+OpenLayers/Kinetic.js
+OpenLayers/Projection.js
+OpenLayers/Layer/SphericalMercator.js
+OpenLayers/Layer/XYZ.js
+OpenLayers/Layer/Bing.js
+OpenLayers/Control/TouchNavigation.js
+OpenLayers/Control/Geolocate.js
+OpenLayers/Control/ZoomPanel.js
+OpenLayers/Control/Attribution.js
+OpenLayers/Control/SelectFeature.js
+OpenLayers/Layer/Vector.js
+OpenLayers/Renderer/SVG.js
+OpenLayers/Renderer/Canvas.js
+OpenLayers/Format/GeoJSON.js
+
+[exclude]
+
+
Copied: sandbox/tschaub/canvas/examples/accelerometer.html (from rev 11552, trunk/openlayers/examples/accelerometer.html)
===================================================================
--- sandbox/tschaub/canvas/examples/accelerometer.html (rev 0)
+++ sandbox/tschaub/canvas/examples/accelerometer.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<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 Accelerometer Usage</title>
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css"/>
+ <link rel="stylesheet" href="style.css" type="text/css"/>
+ <script type="text/javascript" src="browser.js"></script>
+
+ <style type="text/css">
+ .olControlAttribution {
+ bottom: 5px;
+ }
+ </style>
+ <script type="text/javascript">
+ function init() {
+ if (isEventSupported('deviceorientation', window) || isEventSupported('mozorientation', window) || isEventSupported('devicemotion', window)) {
+ if (window.DeviceOrientationEvent) {
+ window.addEventListener("deviceorientation", function (event) {
+ document.getElementById('resultDeviceOrientation').innerHTML = '';
+ if (typeof(event.alpha) != 'undefined') {
+ document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Alpha: " + event.alpha + "<br>";
+ document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Beta: " + event.beta + "<br>";
+ document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.gamma + "<br>";
+ }
+ if (typeof(event.absolute) != 'undefined') {
+ document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.absolute + "<br>";
+ }
+ if (typeof(event.compassCalibrate) != 'undefined') {
+ document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.compassCalibrated + "<br>";
+ }
+ }, true);
+ }
+ if (window.DeviceMotionEvent) {
+ window.addEventListener('devicemotion', function (event) {
+ document.getElementById('resultDeviceMotion').innerHTML = '';
+ if (typeof(event.accelerationIncludingGravity) != 'undefined') {
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.x: " + event.accelerationIncludingGravity.x + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.y: " + event.accelerationIncludingGravity.y + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.z: " + event.accelerationIncludingGravity.z + "<br>";
+ }
+ if (typeof(event.acceleration) != 'undefined') {
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.x: " + event.acceleration.x + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.y: " + event.acceleration.y + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.z: " + event.acceleration.z + "<br>";
+ }
+ if (typeof(event.rotationRate) != 'undefined') {
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.alpha: " + event.rotationRate.alpha + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.beta: " + event.rotationRate.beta + "<br>";
+ document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.gamma: " + event.rotationRate.gamma + "<br>";
+ }
+ }, true);
+ }
+ if (window.MozOrientation) {
+ window.addEventListener("MozOrientation", function (orientation) {
+ document.getElementById('resultMozOrientation').innerHTML = "orientation.x: " + orientation.x + "<br>";
+ document.getElementById('resultMozOrientation').innerHTML = document.getElementById('resultMozOrientation').innerHTML + "orientation.y: " + orientation.y + "<br>";
+ document.getElementById('resultMozOrientation').innerHTML = document.getElementById('resultMozOrientation').innerHTML + "orientation.z: " + orientation.z + "<br>";
+ }, true);
+ }
+ } else {
+ alert("Unfortunately, your brower doesn't support the orientation usage");
+ }
+
+ }
+ </script>
+</head>
+<body onload="init()">
+<h1 id="title">Accelerometer</h1>
+
+<p id="shortdesc">
+ 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">
+
+</div>
+<h1>Device orientation</h1>
+
+<div id="resultDeviceOrientation">
+
+</div>
+<h1>MOZ orientation</h1>
+
+<div id="resultMozOrientation">
+
+</div>
+</body>
+</html>
Modified: sandbox/tschaub/canvas/examples/bing.html
===================================================================
--- sandbox/tschaub/canvas/examples/bing.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/bing.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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", {
Modified: sandbox/tschaub/canvas/examples/browser.html
===================================================================
--- sandbox/tschaub/canvas/examples/browser.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/browser.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -11,6 +11,10 @@
.olControlAttribution {
bottom: 5px;
}
+
+ .tester {
+ margin: 3px;
+ }
</style>
<script type="text/javascript">
function init() {
@@ -79,12 +83,15 @@
</head>
<body onload="init()">
<h1 id="title">Browser detection</h1>
+
<div id="tags">
- browser, vendor, mobile, events, HTML5, gesture, touch
-</div>
+ browser, vendor, mobile, events, HTML5, gesture, touch
+</div>
+
<p id="shortdesc">
The goal of this script is to inform about the capacity of the browser used by the user.
</p>
+
<div id="docs">
<p>
See the <a href="browser.js" target="_blank">
@@ -95,7 +102,50 @@
<h1>Your browser information</h1>
<div id="result">
+</div>
+<h1>Click or touch the red square to get information about the selected events</h1>
+
+<div>
+ <div class="tester">
+ <INPUT TYPE=CHECKBOX ID="clickID" checked>click<BR>
+ <INPUT TYPE=CHECKBOX ID="dblclickID">dblclick<BR>
+ <INPUT TYPE=CHECKBOX ID="mousedownID">mousedown<BR>
+ <INPUT TYPE=CHECKBOX ID="mouseupID">mouseup<BR>
+ <INPUT TYPE=CHECKBOX ID="mouseoverID">mouseover<BR>
+ <INPUT TYPE=CHECKBOX ID="mousemoveID">mousemove<BR>
+ <INPUT TYPE=CHECKBOX ID="mouseoutID">mouseout<BR>
+ <INPUT TYPE=CHECKBOX ID="touchstartID">touchstart<BR>
+ <INPUT TYPE=CHECKBOX ID="touchendID">touchend<BR>
+ <INPUT TYPE=CHECKBOX ID="touchmoveID">touchmove<BR>
+ <INPUT TYPE=CHECKBOX ID="touchcancelID">touchcancel<BR>
+ <INPUT TYPE=CHECKBOX ID="gesturestartID">gesturestart<BR>
+ <INPUT TYPE=CHECKBOX ID="gesturechangeID">gesturechange<BR>
+ <INPUT TYPE=CHECKBOX ID="gestureendID">gestureend<BR>
+ </div>
+
+ <div style="height: 200px;width: 200px;" class="tester">
+ <div id="box" style="height: 200px; width: 200px; background: none repeat scroll 0% 0% red; "
+ onclick="click(event)"
+ ondblclick="dblclick(event)"
+ onmousedown="mousedown(event)"
+ onmouseup="mouseup(event)"
+ onmouseover="mouseover(event)"
+ onmousemove="mousemove(event)"
+ onmouseout="mouseout(event)"
+ ontouchstart="touchstart(event)"
+ ontouchend="touchend(event)"
+ ontouchmove="touchmove(event)"
+ ontouchcancel="touchcancel(event)"
+ ongesturestart="gesturestart(event)"
+ ongesturechange="gesturechange(event)"
+ ongestureend="gestureend(event)">
+ </div>
+ </div>
+
+ <div id="log" class="tester"></div>
</div>
+
+
</body>
</html>
Modified: sandbox/tschaub/canvas/examples/browser.js
===================================================================
--- sandbox/tschaub/canvas/examples/browser.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/browser.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -49,4 +49,193 @@
);
div.innerHTML = div.innerHTML + "<br>";
}
+var counter = 1;
+function log(title, detail) {
+ var logDiv = document.getElementById("log");
+ idString = "'id" + counter + "'";
+ var newlink = document.createElement('a');
+ newlink.setAttribute('href', "javascript:toggle_visibility(" + idString + ")");
+ newlink.innerHTML = counter + ". " + title;
+ var br1 = document.createElement('br');
+ logDiv.appendChild(newlink);
+ logDiv.appendChild(br1);
+
+ var childDiv = document.createElement('div');
+ childDiv.setAttribute("id", idString.replace("'", "").replace("'", ""));
+ childDiv.setAttribute("style", 'display: none; margin-left : 5px;');
+ childDiv.innerHTML = detail;
+ var br2 = document.createElement('br');
+ logDiv.appendChild(childDiv);
+
+ counter = counter + 1;
+}
+
+function inspect(obj) {
+ if (typeof obj === "undefined") {
+ return "undefined";
+ }
+ var _props = [];
+
+ for (var i in obj) {
+ _props.push(i + " : " + obj[i]);
+ }
+ return " {" + _props.join(",<br>") + "} ";
+}
+
+function click(e) {
+ if (document.getElementById("clickID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function dblclick(e) {
+ if (document.getElementById("dblclickID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function mousedown(e) {
+ if (document.getElementById("mousedownID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function mouseup(e) {
+ if (document.getElementById("mouseupID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function mouseover(e) {
+ if (document.getElementById("mouseoverID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function mousemove(e) {
+ if (document.getElementById("mousemoveID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function mouseout(e) {
+ if (document.getElementById("mouseoutID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function touchstart(e) {
+ if (document.getElementById("touchstartID").checked) {
+ var box = document.getElementById("box");
+ var result = inspect(e);
+ for (var i = 0; i < e.touches.length; i++) {
+ result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
+ }
+ log(e.type, result);
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function touchend(e) {
+ if (document.getElementById("touchendID").checked) {
+ var box = document.getElementById("box");
+ var result = inspect(e);
+ for (var i = 0; i < e.touches.length; i++) {
+ result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
+ }
+ log(e.type, result);
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function touchmove(e) {
+ if (document.getElementById("touchmoveID").checked) {
+ var targetEvent = e.touches.item(0);
+ var box = document.getElementById("box");
+ box.style.left = targetEvent.clientX + "px";
+ box.style.top = targetEvent.clientY + "px";
+ var result = inspect(e);
+ for (var i = 0; i < e.touches.length; i++) {
+ result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
+ }
+ log(e.type, result);
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function touchcancel(e) {
+ if (document.getElementById("touchcancelID").checked) {
+ var box = document.getElementById("box");
+ var result = inspect(e);
+ for (var i = 0; i < e.touches.length; i++) {
+ result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
+ }
+ log(e.type, result);
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function gesturestart(e) {
+ if (document.getElementById("gesturestartID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function gesturechange(e) {
+ if (document.getElementById("gesturechangeID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function gestureend(e) {
+ if (document.getElementById("gestureendID").checked) {
+ var box = document.getElementById("box");
+ log(e.type, inspect(e));
+ if (e.preventDefault) e.preventDefault();
+ }
+ return false;
+}
+
+function toggle_visibility(id) {
+ var e = document.getElementById(id);
+ if (e.style.display == 'block') {
+ e.style.display = 'none';
+ } else {
+ e.style.display = 'block';
+ }
+}
+
+
+
Modified: sandbox/tschaub/canvas/examples/controls.html
===================================================================
--- sandbox/tschaub/canvas/examples/controls.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/controls.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -25,7 +25,6 @@
numZoomLevels: 6
});
-
var ol_wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
@@ -49,7 +48,10 @@
);
map.addLayers([ol_wms, gwc, dm_wms]);
- map.zoomToMaxExtent();
+
+ if (!map.getCenter()) {
+ map.zoomToMaxExtent();
+ }
}
</script>
</head>
Copied: sandbox/tschaub/canvas/examples/game-accel-ball.html (from rev 11552, trunk/openlayers/examples/game-accel-ball.html)
===================================================================
--- sandbox/tschaub/canvas/examples/game-accel-ball.html (rev 0)
+++ sandbox/tschaub/canvas/examples/game-accel-ball.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,80 @@
+<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 Game: Bounce Ball</title>
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+ <link rel="stylesheet" href="style.css" type="text/css" />
+ <script src="../lib/OpenLayers.js?mobile"></script>
+ <style type="text/css">
+ html, body { height: 100%; }
+ #shortdesc { display: none; }
+ #tags { display: none; }
+ </style>
+
+ <script type="text/javascript">
+ var map, vlayer;
+ function adjustLocation(delta, feature) {
+ feature.geometry.move(delta.x, delta.y);
+ var me = map.maxExtent;
+ var rad = 6;
+ if (feature.geometry.x > (me.right - rad)) {
+ feature.geometry.x = me.right - rad;
+ } else if (feature.geometry.x < (me.left+rad)) {
+ feature.geometry.x = me.left+rad;
+ }
+ if (feature.geometry.y > (me.top-rad)) {
+ feature.geometry.y = me.top-rad;
+ } else if (feature.geometry.y < (me.bottom+rad)) {
+ feature.geometry.y = me.bottom+rad;
+ }
+ vlayer.drawFeature(feature);
+ }
+ function init() {
+ map = new OpenLayers.Map( 'map',
+ {
+ 'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight),
+ controls: [],
+ maxResolution: 'auto'}
+ );
+ var layer = new OpenLayers.Layer("",
+ {isBaseLayer: true} );
+ map.addLayer(layer);
+ map.zoomToMaxExtent();
+ vlayer = new OpenLayers.Layer.Vector();
+ var feature = new OpenLayers.Feature.Vector(
+ new OpenLayers.Geometry.Point(map.getCenter().lon, map.getCenter().lat));
+ vlayer.addFeatures(feature);
+ map.addLayer(vlayer);
+ if (window.DeviceMotionEvent) {
+ window.addEventListener('devicemotion', function (evt) {
+ var delta = null;
+ if (typeof(evt.accelerationIncludingGravity) != 'undefined') {
+ delta = {
+ 'x': evt.accelerationIncludingGravity.x * 3,
+ 'y': evt.accelerationIncludingGravity.y * 3,
+ 'z': evt.accelerationIncludingGravity.z
+ }
+ }
+ adjustLocation(delta, feature);
+ }, true);
+ } else {
+ alert("This demo does not work on your browser.");
+ }
+ }
+ </script>
+ </head>
+ <body onload="init()">
+ <h1 id="title">Accelerometer Example</h1>
+ <div id="tags">
+ mobile, game
+ </div>
+ <div id="shortdesc">Simple acceleration demo; roll a vector feature around
+ on a map. (Only tested on iOS 4.)</div>
+
+ <div id="map" width="100%" height="100%" style="background-color: grey"></div>
+ <div id="docs">
+ Demo works best when device is locked in portrait mode.
+ </div>
+ </body>
+</html>
Copied: sandbox/tschaub/canvas/examples/img/check-round-green.png (from rev 11552, trunk/openlayers/examples/img/check-round-green.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/check-round-grey.png (from rev 11552, trunk/openlayers/examples/img/check-round-grey.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/list.png (from rev 11552, trunk/openlayers/examples/img/list.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/locate.png (from rev 11552, trunk/openlayers/examples/img/locate.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/minus1.png (from rev 11552, trunk/openlayers/examples/img/minus1.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/mobile-layers.png (from rev 11552, trunk/openlayers/examples/img/mobile-layers.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/mobile-loc.png (from rev 11552, trunk/openlayers/examples/img/mobile-loc.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/img/openlayers.png (from rev 11552, trunk/openlayers/examples/img/openlayers.png)
===================================================================
(Binary files differ)
Copied: sandbox/tschaub/canvas/examples/mobile-base.js (from rev 11552, trunk/openlayers/examples/mobile-base.js)
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-base.js (rev 0)
+++ sandbox/tschaub/canvas/examples/mobile-base.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,109 @@
+// 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
+ ],
+ 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());
+ });
+};
Modified: sandbox/tschaub/canvas/examples/mobile-jq.html
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-jq.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/mobile-jq.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,8 +1,7 @@
<!DOCTYPE html>
<html>
<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" />
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>OpenLayers with jQuery Mobile</title>
<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">
@@ -10,135 +9,67 @@
<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="../lib/OpenLayers.js"></script>
- <script src="mobile.js"></script>
- <style>
- html {
- height: 100%;
- }
- body {
- margin: 0;
- padding: 0;
- height: 100%;
- }
- .ui-content {
- padding: 0;
- }
- .ui-footer, .ui-header {
- text-align: center;
- padding: 5px 0;
- }
- #map {
- width: 100%;
- height: 100%;
- }
- .olControlAttribution {
- font-size: 10px;
- bottom: 5px;
- right: 5px;
- }
- #title, #tags, #shortdesc {
- display: none;
- }
- </style>
- <script>
- $(document).ready(function() {
- // fix height of content to allow for header & footer
- function fixContentHeight() {
- var header = $("div[data-role='header']:visible");
- var footer = $("div[data-role='footer']:visible");
- var content = $("div[data-role='content']:visible:visible");
- var viewHeight = $(window).height();
-
- var contentHeight = viewHeight - header.outerHeight() - footer.outerHeight();
- if ((content.outerHeight() + header.outerHeight() + footer.outerHeight()) !== viewHeight) {
- contentHeight -= (content.outerHeight() - content.height());
- content.height(contentHeight);
- }
- if (window.map) {
- map.updateSize();
- } else {
- // initialize map
- init();
- }
- }
- $(window).bind("orientationchange resize pageshow", fixContentHeight);
- fixContentHeight();
-
- // add behavior to navigation buttons
- $("#west").click(function() {
- pan(-0.25, 0);
- });
- $("#north").click(function() {
- pan(0, -0.25);
- });
- $("#south").click(function() {
- pan(0, 0.25);
- });
- $("#east").click(function() {
- pan(0.25, 0);
- });
-
- // add behavior to drawing controls
- function deactivateControls() {
- $.each(map.getControlsByClass(/DrawFeature/), function(index, control) {
- control.deactivate();
- });
- map.getControlsBy("id", "mod-control")[0].deactivate();
- }
- $("#nav, #point, #line, #poly, #mod").change(function(event) {
- deactivateControls();
- // jquery mobile bug regarding change makes us go through all inputs
- // https://github.com/jquery/jquery-mobile/issues/issue/1088
- var val = $("input:radio[name=controls]:checked").val();
- if (val !== "nav") {
- map.getControlsBy("id", val + "-control")[0].activate();
- }
- });
-
- $("#nav").click();
- $("#nav").click(); // jquery mobile bug forces 2 calls to refresh radio ui
-
- });
-
- </script>
+ <link rel="stylesheet" href="style.mobile-jq.css" type="text/css">
+ <script src="../lib/OpenLayers.js?mobile"></script>
+ <script src="mobile-base.js"></script>
+ <script src="mobile-jq.js"></script>
</head>
<body>
<h1 id="title">OpenLayers with jQuery Mobile</h1>
<div id="tags">
- mobile, jquery
+ mobile, jquery
</div>
<p id="shortdesc">
- Using jQuery Mobile to display an OpenLayers map.
+ Using jQuery Mobile to display an OpenLayers map.
</p>
- <div data-role="page">
- <div data-role="header">
- <input id="west" type="button" data-icon="arrow-l" value="west">
- <input id="north" type="button" data-icon="arrow-u" value="north">
- <input id="south" type="button" data-icon="arrow-d" value="south">
- <input id="east" type="button" data-icon="arrow-r" value="east">
- </div>
- <div data-role="content">
- <div id="map"></div>
- </div>
+ <div data-role="page" id="mappage">
+ <div data-role="content">
+ <div id="map"></div>
+ </div>
- <div data-role="footer">
- <form id="controls">
- <fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain">
- <input id="nav" type="radio" name="controls" value="nav" checked="checked">
- <label for="nav">navigate</label>
- <input id="point" type="radio" name="controls" value="point">
- <label for="point">point</label>
- <input id="line" type="radio" name="controls" value="line">
- <label for="line">line</label>
- <input id="poly" type="radio" name="controls" value="poly">
- <label for="poly">poly</label>
- <input id="mod" type="radio" name="controls" value="mod">
- <label for="mod">modify</label>
- </fieldset>
- </form>
+ <div data-role="footer">
+ <a href="#searchpage" data-icon="search" data-role="button">Search</a>
+ <a href="#" id="locate" data-icon="locate" data-role="button">Locate</a>
+ <a href="#layerspage" data-icon="layers" data-role="button">Layers</a>
+ </div>
+ <div id="navigation" data-role="controlgroup" data-type="vertical">
+ <a href="#" data-role="button" data-icon="plus" id="plus"
+ data-iconpos="notext"></a>
+ <a href="#" data-role="button" data-icon="minus" id="minus"
+ data-iconpos="notext"></a>
+ </div>
+ </div>
+
+ <div data-role="page" id="searchpage">
+ <div data-role="header">
+ <h1>Search</h1>
+ </div>
+ <div data-role="fieldcontain">
+ <input type="search" name="query" id="query"
+ value="" placeholder="Search for places"
+ autocomplete="off"/>
+ </div>
+ <ul data-role="listview" data-inset="true" id="search_results"></ul>
+ </div>
+
+ <div data-role="page" id="layerspage">
+ <div data-role="header">
+ <h1>Layers</h1>
+ </div>
+ <div data-role="content">
+ <ul data-role="listview" data-inset="true" data-theme="d" data-dividertheme="c" id="layerslist">
+ </div>
+ </div>
+
+ <div id="popup" data-role="dialog">
+ <div data-position="inline" data-theme="d" data-role="header">
+ <h1>Details</h1>
</div>
+ <div data-theme="c" data-role="content">
+ <ul id="details-list" data-role="listview">
+ </ul>
+ </div>
</div>
</body>
</html>
Copied: sandbox/tschaub/canvas/examples/mobile-jq.js (from rev 11552, trunk/openlayers/examples/mobile-jq.js)
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-jq.js (rev 0)
+++ sandbox/tschaub/canvas/examples/mobile-jq.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,213 @@
+var selectedFeature = null;
+
+$(document).ready(function() {
+
+ // Start with the map page
+ if (window.location.hash && window.location.hash!='#mappage') {
+ $.mobile.changePage('mappage');
+ }
+
+ // fix height of content
+ function fixContentHeight() {
+ var footer = $("div[data-role='footer']:visible"),
+ content = $("div[data-role='content']:visible:visible"),
+ viewHeight = $(window).height(),
+ contentHeight = viewHeight - footer.outerHeight();
+
+ if ((content.outerHeight() + footer.outerHeight()) !== viewHeight) {
+ contentHeight -= (content.outerHeight() - content.height());
+ content.height(contentHeight);
+ }
+ if (window.map) {
+ map.updateSize();
+ } else {
+ // initialize map
+ init();
+ }
+ }
+ $(window).bind("orientationchange resize pageshow", fixContentHeight);
+ fixContentHeight();
+ //init();
+
+ // Map zoom
+ $("#plus").click(function(){
+ map.zoomIn();
+ });
+ $("#minus").click(function(){
+ map.zoomOut();
+ });
+ $("#locate").click(function(){
+ var control = map.getControlsBy("id", "locate-control")[0];
+ if (control.active) {
+ control.getCurrentLocation();
+ } else {
+ control.activate();
+ }
+ });
+
+ var sprintersLayer = new OpenLayers.Layer.Vector("Sprinters", {
+ styleMap: new OpenLayers.StyleMap({
+ externalGraphic : "img/mobile-loc.png",
+ graphicOpacity : 1.0,
+ graphicWith:16,
+ graphicHeight:26
+ })
+ });
+
+ var sprinters = getFeatures();
+ sprintersLayer.addFeatures(sprinters);
+
+ map.addLayer(sprintersLayer);
+
+ var selectControl = new OpenLayers.Control.SelectFeature(sprintersLayer, {onSelect: function(feature){
+ selectedFeature = feature;
+ $.mobile.changePage($("#popup"), "pop");
+ }});
+
+ map.addControl(selectControl);
+ selectControl.activate();
+
+ $('div#popup').live('pageshow',function(event, ui){
+ var li = "";
+ for(var attr in selectedFeature.attributes){
+ li += "<li><div style='width:25%;float:left'>" + attr + "</div><div style='width:75%;float:right'>"
+ + selectedFeature.attributes[attr] + "</div></li>";
+ }
+ $("ul#details-list").empty().append(li).listview("refresh");
+ });
+
+ $('#searchpage').live('pageshow',function(event, ui){
+ $('#query').bind('change', function(e){
+ $('#search_results').empty();
+ if ($('#query')[0].value === '') {
+ return;
+ }
+ $.mobile.pageLoading();
+
+ // Prevent form send
+ e.preventDefault();
+
+ var searchUrl = 'http://ws.geonames.org/searchJSON?featureClass=P&maxRows=10';
+ searchUrl += '&name_startsWith=' + $('#query')[0].value;
+ $.getJSON(searchUrl, function(data) {
+ $.each(data.geonames, function() {
+ var place = this;
+ $('<li>')
+ .hide()
+ .append($('<h2 />', {
+ text: place.name
+ }))
+ .append($('<p />', {
+ html: '<b>' + place.countryName + '</b> ' + place.fcodeName
+ }))
+ .appendTo('#search_results')
+ .click(function() {
+ $.mobile.changePage('mappage');
+ var lonlat = new OpenLayers.LonLat(place.lng, place.lat);
+ map.setCenter(lonlat.transform(gg, sm), 10);
+ })
+ .show();
+ });
+ $('#search_results').listview('refresh');
+ $.mobile.pageLoading(true);
+ });
+ });
+ // only listen to the first event triggered
+ $('#searchpage').die('pageshow', arguments.callee);
+ });
+
+ $('#layerslist').listview();
+ $('<li>', {
+ "data-role": "list-divider",
+ text: "Base Layers"
+ })
+ .appendTo('#layerslist');
+ var baseLayers = map.getLayersBy("isBaseLayer", true);
+ $.each(baseLayers, function() {
+ addLayerToList(this);
+ });
+
+ $('<li>', {
+ "data-role": "list-divider",
+ text: "Overlay Layers"
+ })
+ .appendTo('#layerslist');
+ var overlayLayers = map.getLayersBy("isBaseLayer", false);
+ $.each(overlayLayers, function() {
+ addLayerToList(this);
+ });
+ $('#layerslist').listview('refresh');
+
+ map.events.register("addlayer", this, function(e) {
+ addLayerToList(e.layer);
+ });
+});
+
+function addLayerToList(layer) {
+ var item = $('<li>', {
+ "data-icon": "check",
+ "class": layer.visibility ? "checked" : ""
+ })
+ .append($('<a />', {
+ text: layer.name
+ })
+ .click(function() {
+ $.mobile.changePage('mappage');
+ if (layer.isBaseLayer) {
+ layer.map.setBaseLayer(layer);
+ } else {
+ layer.setVisibility(!layer.getVisibility());
+ }
+ })
+ )
+ .appendTo('#layerslist');
+ layer.events.on({
+ 'visibilitychanged': function() {
+ $(item).toggleClass('checked');
+ }
+ });
+}
+
+function getFeatures(){
+ var features = {
+ "type": "FeatureCollection",
+ "features": [
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [1332700, 7906300]},
+ "properties": {"Name": "Igor Tihonov", "Country":"Sweden", "City":"Gothenburg"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [790300, 6573900]},
+ "properties": {"Name": "Marc Jansen", "Country":"Germany", "City":"Bonn"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [568600, 6817300]},
+ "properties": {"Name": "Bart van den Eijnden", "Country":"Netherlands", "City":"Utrecht"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-7909900, 5215100]},
+ "properties": {"Name": "Christopher Schmidt", "Country":"United States of America", "City":"Boston"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-937400, 5093200]},
+ "properties": {"Name": "Jorge Gustavo Rocha", "Country":"Portugal", "City":"Braga"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-355300, 7547800]},
+ "properties": {"Name": "Jennie Fletcher ", "Country":"Scotland", "City":"Edinburgh"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [657068.53608487, 5712321.2472725]},
+ "properties": {"Name": "Bruno Binet ", "Country":"France", "City":"Chambéry"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [667250.8958124, 5668048.6072737]},
+ "properties": {"Name": "Eric Lemoine", "Country":"France", "City":"Theys"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [653518.03606319, 5721118.5122914]},
+ "properties": {"Name": "Antoine Abt", "Country":"France", "City":"La Motte Servolex"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [657985.78042416, 5711862.6251028]},
+ "properties": {"Name": "Pierre Giraud", "Country":"France", "City":"Chambéry"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [742941.93818208, 5861818.9477535]},
+ "properties": {"Name": "Stéphane Brunner", "Country":"Switzerland", "City":"Paudex"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [736082.61064069, 5908165.4649505]},
+ "properties": {"Name": "Frédéric Junod", "Country":"Switzerland", "City":"Montagny-près-Yverdon"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [771595.97057525, 5912284.7041793]},
+ "properties": {"Name": "Cédric Moullet", "Country":"Switzerland", "City":"Payerne"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [744205.23922364, 5861277.319748]},
+ "properties": {"Name": "Benoit Quartier", "Country":"Switzerland", "City":"Lutry"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [1717430.147101, 5954568.7127565]},
+ "properties": {"Name": "Andreas Hocevar", "Country":"Austria", "City":"Graz"}},
+ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [-12362007.067301,5729082.2365672]},
+ "properties": {"Name": "Tim Schaub", "Country":"United States of America", "City":"Bozeman"}}
+ ]
+ };
+
+ var reader = new OpenLayers.Format.GeoJSON();
+
+ return reader.read(features);
+}
Modified: sandbox/tschaub/canvas/examples/mobile-navigation.js
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-navigation.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/mobile-navigation.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/examples/mobile-sencha.html
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-sencha.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/mobile-sencha.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -5,12 +5,30 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OpenLayers with Sencha Touch</title>
- <script src="../lib/OpenLayers.js"></script>
+ <script src="../lib/OpenLayers.js?mobile"></script>
<link rel="stylesheet" href="style.mobile.css" type="text/css">
<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.js"></script>
+ <script src="mobile-sencha.js"></script>
+ <script src="mobile-base.js"></script>
<style>
+ .searchList {
+ min-height: 150px;
+ }
+ .close-btn {
+ position: absolute;
+ right: 10px;
+ top: 10px;
+ }
+ img.minus {
+ -webkit-mask-image: url(img/minus1.png);
+ }
+ img.layers {
+ -webkit-mask-image: url(img/list.png);
+ }
+ .gx-layer-item {
+ margin-left: 10px;
+ }
#map {
width: 100%;
height: 100%;
@@ -25,100 +43,96 @@
}
</style>
<script>
-
- new Ext.Application({
+
+ var app = new Ext.Application({
name: "ol",
launch: function() {
this.viewport = new Ext.Panel({
fullscreen: true,
dockedItems: [{
- dock: "top",
+ dock: "bottom",
xtype: "toolbar",
ui: "light",
layout: {
pack: "center"
},
- defaults: {
- ui: "plain",
- iconMask: true
- },
items: [{
- iconCls: "arrow_left",
+ iconCls: "search",
+ iconMask: true,
+ handler: function(){
+ // this is the app
+ if (!app.searchFormPopupPanel) {
+ app.searchFormPopupPanel = new App.SearchFormPopupPanel({
+ map: map
+ });
+ }
+ app.searchFormPopupPanel.show('pop');
+ }
+ }, {
+ iconCls: "locate",
+ iconMask: true,
handler: function() {
- pan(-0.25, 0);
+ var geolocate = map.getControlsBy("id", "locate-control")[0];
+ if (geolocate.active) {
+ geolocate.getCurrentLocation();
+ } else {
+ geolocate.activate();
+ }
}
}, {
- iconCls: "arrow_up",
+ xtype: "spacer"
+ }, {
+ iconMask: true,
+ iconCls: "add",
handler: function() {
- pan(0, -0.25);
+ map.zoomIn();
}
}, {
- iconCls: "arrow_down",
+ iconMask: true,
+ iconCls: "minus",
handler: function() {
- pan(0, 0.25);
+ map.zoomOut();
}
}, {
- iconCls: "arrow_right",
+ xtype: "spacer"
+ }, {
+ iconMask: true,
+ iconCls: "layers",
handler: function() {
- pan(0.25, 0);
- }
- }]
- }, {
- dock: "bottom",
- xtype: "toolbar",
- ui: "light",
- layout: {
- pack: "center"
- },
- items: [{
- xtype: "segmentedbutton",
- items: [{
- text: "navigate",
- pressed: true
- }, {
- text: "point",
- id: "point"
- }, {
- text: "line",
- id: "line"
- }, {
- text: "poly",
- id: "poly"
- }, {
- text: "modify",
- id: "mod"
- }],
- listeners: {
- toggle: function(container, button, pressed) {
- Ext.each(map.getControlsByClass(/DrawFeature/), function(control) {
- control.deactivate();
+ if (!app.popup) {
+ app.popup = new Ext.Panel({
+ floating: true,
+ modal: true,
+ centered: true,
+ hideOnMaskTap: true,
+ width: 240,
+ items: [{
+ xtype: 'app_layerlist',
+ map: map
+ }],
+ scroll: 'vertical'
});
- map.getControlsBy("id", "mod-control")[0].deactivate();
- if (pressed) {
- var id = button.id + "-control";
- var control = map.getControlsBy("id", id)[0];
- if (control) {
- control.activate();
- }
- }
}
+ app.popup.show('pop');
}
}]
}],
- items: [{
- xtype: "component",
- scroll: false,
- monitorResize: true,
- id: "map",
- listeners: {
- render: init,
- resize: function() {
- if (window.map) {
- map.updateSize();
+ items: [
+ {
+ xtype: "component",
+ scroll: false,
+ monitorResize: true,
+ id: "map",
+ listeners: {
+ render: init,
+ resize: function() {
+ if (window.map) {
+ map.updateSize();
+ }
}
}
}
- }]
+ ]
});
}
});
Copied: sandbox/tschaub/canvas/examples/mobile-sencha.js (from rev 11552, trunk/openlayers/examples/mobile-sencha.js)
===================================================================
--- sandbox/tschaub/canvas/examples/mobile-sencha.js (rev 0)
+++ sandbox/tschaub/canvas/examples/mobile-sencha.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,198 @@
+Ext.ns('App');
+
+/**
+ * The model for the geonames records used in the search
+ */
+Ext.regModel('Geonames', {
+ fields: ['countryName', 'toponymName', 'name', 'lat', 'lng']
+});
+
+/**
+ * Custom class for the Search
+ */
+App.SearchFormPopupPanel = Ext.extend(Ext.Panel, {
+ map: null,
+ floating: true,
+ modal: true,
+ centered: true,
+ hideOnMaskTap: true,
+ width: Ext.is.Phone ? undefined : 400,
+ height: Ext.is.Phone ? undefined : 400,
+ scroll: false,
+ layout: 'fit',
+ fullscreen: Ext.is.Phone ? true : undefined,
+ url: 'http://ws.geonames.org/searchJSON?',
+ errorText: 'Sorry, we had problems communicating with geonames.org. Please try again.',
+ errorTitle: 'Communication error',
+ maxResults: 6,
+ featureClass: "P",
+
+ createStore: function(){
+ this.store = new Ext.data.Store({
+ model: 'Geonames',
+ proxy: {
+ type: 'scripttag',
+ timeout: 5000,
+ listeners: {
+ exception: function(){
+ this.hide();
+ Ext.Msg.alert(this.errorTitle, this.errorText, Ext.emptyFn);
+ },
+ scope: this
+ },
+ url: this.url,
+ reader: {
+ type: 'json',
+ root: 'geonames'
+ }
+ }
+ });
+ },
+
+ doSearch: function(searchfield, evt){
+ var q = searchfield.getValue();
+ this.store.load({
+ params: {
+ featureClass: this.featureClass,
+ maxRows: this.maxResults,
+ name_startsWith: encodeURIComponent(q)
+ }
+ });
+ },
+
+ onItemTap: function(dataView, index, item, event){
+ var record = this.store.getAt(index);
+ var lon = record.get('lng');
+ var lat = record.get('lat');
+ var lonlat = new OpenLayers.LonLat(lon, lat);
+ map.setCenter(lonlat.transform(gg, sm), 12);
+ this.hide("pop");
+ },
+
+ initComponent: function(){
+ this.createStore();
+ this.resultList = new Ext.List({
+ scroll: 'vertical',
+ cls: 'searchList',
+ loadingText: "Searching ...",
+ store: this.store,
+ itemTpl: '<div>{name} ({countryName})</div>',
+ listeners: {
+ itemtap: this.onItemTap,
+ scope: this
+ }
+ });
+ this.formContainer = new Ext.form.FormPanel({
+ scroll: false,
+ items: [{
+ xtype: 'button',
+ cls: 'close-btn',
+ ui: 'decline-small',
+ text: 'Close',
+ handler: function(){
+ this.hide();
+ },
+ scope: this
+ }, {
+ xtype: 'fieldset',
+ scroll: false,
+ title: 'Search for a place',
+ items: [{
+ xtype: 'searchfield',
+ label: 'Search',
+ placeHolder: 'placename',
+ listeners: {
+ action: this.doSearch,
+ scope: this
+ }
+ },
+ this.resultList
+ ]
+ }]
+ });
+ this.items = [{
+ xtype: 'panel',
+ layout: 'fit',
+ items: [this.formContainer]
+ }];
+ App.SearchFormPopupPanel.superclass.initComponent.call(this);
+ }
+});
+
+App.LayerList = Ext.extend(Ext.List, {
+
+ map: null,
+
+ createStore: function(){
+ Ext.regModel('Layer', {
+ fields: ['id', 'name', 'visibility', 'zindex']
+ });
+ var data = [];
+ Ext.each(this.map.layers, function(layer){
+ if (layer.displayInLayerSwitcher === true) {
+ var visibility = layer.isBaseLayer ? (this.map.baseLayer == layer) : layer.getVisibility();
+ data.push({
+ id: layer.id,
+ name: layer.name,
+ visibility: visibility,
+ zindex: layer.getZIndex()
+ });
+ }
+ });
+ return new Ext.data.Store({
+ model: 'Layer',
+ sorters: 'zindex',
+ data: data
+ });
+ },
+
+ initComponent: function(){
+ this.store = this.createStore();
+ this.itemTpl = new Ext.XTemplate(
+ '<tpl if="visibility == true">',
+ '<img width="20" src="img/check-round-green.png">',
+ '</tpl>',
+ '<tpl if="visibility == false">',
+ '<img width="20" src="img/check-round-grey.png">',
+ '</tpl>',
+ '<span class="gx-layer-item">{name}</span>'
+ );
+ this.listeners = {
+ itemtap: function(dataview, index, item, e){
+ var record = dataview.getStore().getAt(index);
+ var layer = this.map.getLayersBy("id", record.get("id"))[0];
+ if (layer.isBaseLayer) {
+ this.map.setBaseLayer(layer);
+ }
+ else {
+ layer.setVisibility(!layer.getVisibility());
+ }
+ record.set("visibility", layer.getVisibility());
+ }
+ };
+ this.map.events.on({
+ "changelayer": this.onChangeLayer,
+ scope: this
+ });
+ App.LayerList.superclass.initComponent.call(this);
+ },
+
+ findLayerRecord: function(layer){
+ var found;
+ this.store.each(function(record){
+ if (record.get("id") === layer.id) {
+ found = record;
+ }
+ }, this);
+ return found;
+ },
+
+ onChangeLayer: function(evt){
+ if (evt.property == "visibility") {
+ var record = this.findLayerRecord(evt.layer);
+ record.set("visibility", evt.layer.getVisibility());
+ }
+ }
+
+});
+Ext.reg('app_layerlist', App.LayerList);
Modified: sandbox/tschaub/canvas/examples/mobile.html
===================================================================
--- sandbox/tschaub/canvas/examples/mobile.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/mobile.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/examples/mobile.js
===================================================================
--- sandbox/tschaub/canvas/examples/mobile.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/mobile.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,77 +1,40 @@
-
// initialize map when page ready
var map;
-var gg = new OpenLayers.Projection("EPSG:4326");
-var sm = new OpenLayers.Projection("EPSG:900913");
-function init() {
-
- // layer for drawn features
- var vector = new OpenLayers.Layer.Vector();
+// 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",
- projection: sm,
- units: "m",
- numZoomLevels: 18,
- maxResolution: 156543.0339,
- maxExtent: new OpenLayers.Bounds(
- -20037508.34, -20037508.34, 20037508.34, 20037508.34
- ),
+ theme: null,
controls: [
+ new OpenLayers.Control.Attribution(),
new OpenLayers.Control.TouchNavigation({
dragPanOptions: {
- interval: 0, // non-zero kills performance on some mobile phones
+ interval: 100,
enableKinetic: true
}
}),
- new OpenLayers.Control.Attribution(),
- new OpenLayers.Control.DrawFeature(
- vector, OpenLayers.Handler.Point, {id: "point-control"}
- ),
- new OpenLayers.Control.DrawFeature(
- vector, OpenLayers.Handler.Path, {id: "line-control"}
- ),
- new OpenLayers.Control.DrawFeature(
- vector, OpenLayers.Handler.Polygon, {id: "poly-control"}
- ),
- new OpenLayers.Control.ModifyFeature(vector, {id: "mod-control"}),
new OpenLayers.Control.ZoomPanel()
],
- layers: [new OpenLayers.Layer.OSM(), vector],
- center: new OpenLayers.LonLat(0, 0),
- zoom: 1
+ layers: [
+ new OpenLayers.Layer.OSM("OpenStreetMap", null, {
+ transitionEffect: 'resize'
+ })
+ ],
+ center: new OpenLayers.LonLat(742000, 5861000),
+ zoom: 3
});
-
- // attempt to get position
- if (window.navigator && navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(
- updatePosition,
- function failure(error) {
- OpenLayers.Console.log(error.message);
- },
- {
- enableHighAccuracy: true
- }
- );
- }
-
};
-
-// get position if possible
-var position;
-function updatePosition(pos) {
- position = pos;
- var lon = position.coords.longitude;
- var lat = position.coords.latitude;
- OpenLayers.Console.log("position: lon " + lon + ", lat " + lat);
- map.setCenter(
- new OpenLayers.LonLat(lon, lat).transform(gg, sm)
- );
-}
-
-function pan(fx, fy) {
- var size = map.getSize();
- map.pan(size.w * fx, size.h * fy);
-}
-
Copied: sandbox/tschaub/canvas/examples/multitouch.html (from rev 11552, trunk/openlayers/examples/multitouch.html)
===================================================================
--- sandbox/tschaub/canvas/examples/multitouch.html (rev 0)
+++ sandbox/tschaub/canvas/examples/multitouch.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,22 @@
+<html>
+ <head>
+ <title>Multitouch Test</title>
+ </head>
+ <body>
+ <div style="width:80%; height: 80%; border: 1px solid black; font-size: 5em;" id="box">
+ </div>
+ Touch inside the box. On a touch enabled browser, you will get the number
+ of detected touch events. If the box is red, your browser does not support
+ touch events.
+ <script>
+ var box = document.getElementById("box");
+ box.addEventListener("touchstart", function(evt) {
+ box.innerHTML = evt.touches.length;
+ evt.preventDefault();
+ });
+ if (!(typeof box.ontouchstart != 'undefined')) {
+ box.style.backgroundColor = "red";
+ }
+ </script>
+ </body>
+</html>
Modified: sandbox/tschaub/canvas/examples/spherical-mercator.html
===================================================================
--- sandbox/tschaub/canvas/examples/spherical-mercator.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/spherical-mercator.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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>
Copied: sandbox/tschaub/canvas/examples/style.mobile-jq.css (from rev 11552, trunk/openlayers/examples/style.mobile-jq.css)
===================================================================
--- sandbox/tschaub/canvas/examples/style.mobile-jq.css (rev 0)
+++ sandbox/tschaub/canvas/examples/style.mobile-jq.css 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,120 @@
+html ,
+body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+}
+.ui-content {
+ padding: 0;
+}
+.ui-footer {
+ text-align: center;
+ padding: 5px 0;
+}
+.portrait, .portrait #mappage {
+ min-height: 0;
+}
+/*.portrait, .portrait .ui-page{*/
+ /*min-height: 0;*/
+/*}*/
+#mappage, #mappage .ui-content, #map {
+ width: 100%;
+ height: 100%;
+}
+.olControlAttribution {
+ font-size: 10px;
+ bottom: 5px;
+ right: 5px;
+}
+#navigation {
+ position: absolute;
+ bottom: 70px;
+ left: 10px;
+ z-index: 1000;
+}
+#navigation .ui-btn-icon-notext {
+ display: block;
+ padding: 7px 6px 7px 8px;
+}
+#title, #tags, #shortdesc {
+ display: none;
+}
+.ui-icon-check {
+ opacity: 0.3;
+}
+.checked .ui-icon-check {
+ opacity: 1;
+}
+.ui-icon-locate {
+ background-image: url(img/locate.png);
+}
+.ui-icon-layers {
+ background-image: url(img/openlayers.png);
+}
+.ui-content .ui-listview-inset, #search_results {
+ margin: 1em;
+}
+.ui-content .ui-listview {
+ margin: 0px;
+}
+#details-list li{
+ padding:15px 10px;
+}
+html {
+ height: 100%;
+}
+body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+}
+.ui-content {
+ padding: 0;
+}
+.ui-footer {
+ text-align: center;
+ padding: 5px 0;
+}
+#map {
+ width: 100%;
+ height: 100%;
+}
+.olControlAttribution {
+ font-size: 10px;
+ bottom: 5px;
+ right: 5px;
+}
+#navigation {
+ position: absolute;
+ bottom: 70px;
+ left: 10px;
+ z-index: 1000;
+}
+#navigation .ui-btn-icon-notext {
+ display: block;
+ padding: 7px 6px 7px 8px;
+}
+#title, #tags, #shortdesc {
+ display: none;
+}
+.ui-icon-check {
+ opacity: 0.3;
+}
+.checked .ui-icon-check {
+ opacity: 1;
+}
+.ui-icon-locate {
+ background-image: url(img/locate.png);
+}
+.ui-icon-layers {
+ background-image: url(img/openlayers.png);
+}
+.ui-content .ui-listview-inset, #search_results {
+ margin: 1em;
+}
+.ui-content .ui-listview {
+ margin: 0px;
+}
+#details-list li{
+ padding:15px 10px;
+}
\ No newline at end of file
Modified: sandbox/tschaub/canvas/examples/tile-origin.html
===================================================================
--- sandbox/tschaub/canvas/examples/tile-origin.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/examples/tile-origin.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -5,7 +5,6 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>OpenLayers Tile Origin Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
- <link rel="stylesheet" href="../theme/default/google.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
Modified: sandbox/tschaub/canvas/img/cloud-popup-relative.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/drag-rectangle-off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/drag-rectangle-on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/east-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/layer-switcher-maximize.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/layer-switcher-minimize.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/marker-blue.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/marker-gold.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/marker-green.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/marker.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/measuring-stick-off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/measuring-stick-on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/north-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/panning-hand-off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/panning-hand-on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/slider.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/south-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/west-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/zoom-minus-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/zoom-plus-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/zoom-world-mini.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/img/zoombar.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/lib/Firebug/firebugx.js
===================================================================
--- sandbox/tschaub/canvas/lib/Firebug/firebugx.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/Firebug/firebugx.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,9 +1,10 @@
+(function() {
+ if (!window.console || !console.firebug) {
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
-if (!window.console || !console.firebug) {
- var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
- "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
-
- window.console = {};
- for (var i = 0; i < names.length; ++i)
- window.console[names[i]] = function() {}
-}
+ window.console = {};
+ for (var i = 0; i < names.length; ++i)
+ window.console[names[i]] = function() {}
+ }
+})();
Modified: sandbox/tschaub/canvas/lib/OpenLayers/BaseTypes/Pixel.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/BaseTypes/Pixel.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/BaseTypes/Pixel.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -86,6 +86,24 @@
},
/**
+ * APIMethod: distanceTo
+ * Returns the distance to the pixel point passed in as a parameter.
+ *
+ * Parameters:
+ * px - {<OpenLayers.Pixel>}
+ *
+ * Returns:
+ * {Float} The pixel point passed in as parameter to calculate the
+ * distance to.
+ */
+ distanceTo:function(px) {
+ return Math.sqrt(
+ Math.pow(this.x - px.x, 2) +
+ Math.pow(this.y - px.y, 2)
+ );
+ },
+
+ /**
* APIMethod: add
*
* Parameters:
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/Geolocate.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/Geolocate.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/Geolocate.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -74,6 +74,14 @@
},
/**
+ * Method: destroy
+ */
+ destroy: function() {
+ this.deactivate();
+ OpenLayers.Control.prototype.destroy.apply(this, arguments);
+ },
+
+ /**
* Method: activate
* Activates the control.
*
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseDefaults.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseDefaults.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseDefaults.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -165,7 +165,7 @@
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
}
document.onselectstart = OpenLayers.Function.False;
OpenLayers.Event.stop(evt);
@@ -302,7 +302,7 @@
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
- this.map.viewPortDiv.removeChild(this.zoomBox);
+ this.map.eventsDiv.removeChild(this.zoomBox);
this.zoomBox = null;
},
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseToolbar.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseToolbar.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/MouseToolbar.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -207,7 +207,7 @@
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
this.performedDrag = true;
break;
case "measure":
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/Navigation.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/Navigation.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/Navigation.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -163,6 +163,7 @@
}
var clickCallbacks = {
+ 'click': this.defaultClick,
'dblclick': this.defaultDblClick,
'dblrightclick': this.defaultDblRightClick
};
@@ -190,6 +191,18 @@
},
/**
+ * Method: defaultClick
+ *
+ * Parameters:
+ * evt - {Event}
+ */
+ defaultClick: function (evt) {
+ if (evt.lastTouches && evt.lastTouches.length == 2) {
+ this.map.zoomOut();
+ }
+ },
+
+ /**
* Method: defaultDblClick
*
* Parameters:
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/OverviewMap.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/OverviewMap.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/OverviewMap.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -157,7 +157,7 @@
this.handlers.drag.destroy();
}
- this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);
+ this.ovmap && this.ovmap.eventsDiv.removeChild(this.extentRectangle);
this.extentRectangle = null;
if (this.rectEvents) {
@@ -489,7 +489,7 @@
{controls: [], maxResolution: 'auto',
fallThrough: false}, this.mapOptions);
this.ovmap = new OpenLayers.Map(this.mapDiv, options);
- this.ovmap.viewPortDiv.appendChild(this.extentRectangle);
+ this.ovmap.eventsDiv.appendChild(this.extentRectangle);
// prevent ovmap from being destroyed when the page unloads, because
// the OverviewMap control has to do this (and does it).
Copied: sandbox/tschaub/canvas/lib/OpenLayers/Control/PinchZoom.js (from rev 11552, trunk/openlayers/lib/OpenLayers/Control/PinchZoom.js)
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/PinchZoom.js (rev 0)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/PinchZoom.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,192 @@
+/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
+ * full list of contributors). Published under the Clear BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Handler/Pinch.js
+ */
+
+/**
+ * Class: OpenLayers.Control.PinchZoom
+ *
+ * Inherits:
+ * - <OpenLayers.Control>
+ */
+OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, {
+
+ /**
+ * Property: type
+ * {OpenLayers.Control.TYPES}
+ */
+ type: OpenLayers.Control.TYPE_TOOL,
+
+ /**
+ * Property: containerOrigin
+ * {Object} Cached object representing the layer container origin (in pixels).
+ */
+ containerOrigin: null,
+
+ /**
+ * Property: pinchOrigin
+ * {Object} Cached object representing the pinch start (in pixels).
+ */
+ pinchOrigin: null,
+
+ /**
+ * Property: currentCenter
+ * {Object} Cached object representing the latest pinch center (in pixels).
+ */
+ currentCenter: null,
+
+ /**
+ * APIProperty: autoActivate
+ * {Boolean} Activate the control when it is added to a map. Default is
+ * true.
+ */
+ autoActivate: true,
+
+ /**
+ * Constructor: OpenLayers.Control.PinchZoom
+ * Create a control for zooming with pinch gestures. This works on devices
+ * with multi-touch support.
+ *
+ * Parameters:
+ * options - {Object} An optional object whose properties will be set on
+ * the control
+ */
+ initialize: function(options) {
+ OpenLayers.Control.prototype.initialize.apply(this, arguments);
+ this.handler = new OpenLayers.Handler.Pinch(this, {
+ start: this.pinchStart,
+ move: this.pinchMove,
+ done: this.pinchDone
+ }, this.handlerOptions);
+ },
+
+ /**
+ * APIMethod: activate
+ * Activate this control. Must be called after the control is added to a
+ * map.
+ *
+ * Returns:
+ * {Boolean} The control was successfully activated.
+ */
+ activate: function() {
+ var activated = OpenLayers.Control.prototype.activate.apply(this,arguments);
+ if (activated) {
+ this.map.events.on({
+ moveend: this.updateContainerOrigin,
+ scope: this
+ });
+ this.updateContainerOrigin();
+ }
+ return activated;
+ },
+
+ /**
+ * APIMethod: deactivate
+ * Deactivate this control.
+ *
+ * Returns:
+ * {Boolean} The control was successfully deactivated.
+ */
+ deactivate: function() {
+ var deactivated = OpenLayers.Control.prototype.deactivate.apply(this,arguments);
+ if (this.map && this.map.events) {
+ this.map.events.un({
+ moveend: this.updateContainerOrigin,
+ scope: this
+ });
+ }
+ return deactivated;
+ },
+
+ /**
+ * Method: updateContainerOrigin
+ * Must be called each time the layer container origin changes.
+ */
+ updateContainerOrigin: function() {
+ var container = this.map.layerContainerDiv;
+ this.containerOrigin = {
+ x: parseInt(container.style.left, 10),
+ y: parseInt(container.style.top, 10)
+ };
+ },
+
+ /**
+ * Method: pinchStart
+ *
+ * Parameters:
+ * evt - {Event}
+ * pinchData - {Object} pinch data object related to the current touchmove
+ * of the pinch gesture. This give us the current scale of the pinch.
+ */
+ pinchStart: function(evt, pinchData) {
+ this.pinchOrigin = evt.xy;
+ },
+
+ /**
+ * Method: pinchMove
+ *
+ * Parameters:
+ * evt - {Event}
+ * pinchData - {Object} pinch data object related to the current touchmove
+ * of the pinch gesture. This give us the current scale of the pinch.
+ */
+ pinchMove: function(evt, pinchData) {
+ var scale = pinchData.scale;
+ var containerOrigin = this.containerOrigin;
+ var pinchOrigin = this.pinchOrigin;
+ var current = evt.xy;
+
+ var dx = Math.round((current.x - pinchOrigin.x) + (scale - 1) * (containerOrigin.x - pinchOrigin.x));
+ var dy = Math.round((current.y - pinchOrigin.y) + (scale - 1) * (containerOrigin.y - pinchOrigin.y));
+
+ this.applyTransform(
+ "translate(" + dx + "px, " + dy + "px) scale(" + scale + ")"
+ );
+ this.currentCenter = current;
+ },
+
+ /**
+ * Method: applyTransform
+ * Applies the given transform to layers.
+ */
+ applyTransform: function(transform) {
+ var style = this.map.layerContainerDiv.style;
+ style['-webkit-transform'] = transform;
+ style['-moz-transform'] = transform;
+ },
+
+ /**
+ * Method: pinchDone
+ *
+ * Parameters:
+ * evt - {Event}
+ * start - {Object} pinch data object related to the touchstart event that
+ * started the pinch gesture.
+ * last - {Object} pinch data object related to the last touchmove event
+ * of the pinch gesture. This give us the final scale of the pinch.
+ */
+ pinchDone: function(evt, start, last) {
+ var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);
+ var resolution = this.map.getResolutionForZoom(zoom);
+
+ var location = this.map.getLonLatFromPixel(this.pinchOrigin);
+ var zoomPixel = this.currentCenter;
+ var size = this.map.getSize();
+
+ location.lon += resolution * ((size.w / 2) - zoomPixel.x);
+ location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
+
+ this.map.setCenter(location, zoom);
+
+ var style = this.map.layerContainerDiv.style;
+ style['-webkit-transform'] = "";
+ style['-moz-transform'] = "";
+ },
+
+ CLASS_NAME: "OpenLayers.Control.PinchZoom"
+
+});
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Control/TouchNavigation.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Control/TouchNavigation.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Control/TouchNavigation.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -5,14 +5,15 @@
/**
* @requires OpenLayers/Control/DragPan.js
+ * @requires OpenLayers/Control/PinchZoom.js
* @requires OpenLayers/Handler/Click.js
*/
/**
* Class: OpenLayers.Control.TouchNavigation
* The navigation control handles map browsing with touch events (dragging,
- * double-tapping, and tap with two fingers). Create a new navigation
- * control with the <OpenLayers.Control.TouchNavigation> control.
+ * double-tapping, tap with two fingers, and pinch zoom). Create a new
+ * control with the <OpenLayers.Control.TouchNavigation> constructor.
*
* Inherits:
* - <OpenLayers.Control>
@@ -32,6 +33,18 @@
dragPanOptions: null,
/**
+ * Property: pinchZoom
+ * {<OpenLayers.Control.PinchZoom>}
+ */
+ pinchZoom: null,
+
+ /**
+ * APIProprety: pinchZoomOptions
+ * {Object} Options passed to the PinchZoom control.
+ */
+ pinchZoomOptions: null,
+
+ /**
* APIProperty: documentDrag
* {Boolean} Allow panning of the map by dragging outside map viewport.
* Default is false.
@@ -70,6 +83,10 @@
this.dragPan.destroy();
}
this.dragPan = null;
+ if (this.pinchZoom) {
+ this.pinchZoom.destroy();
+ delete this.pinchZoom;
+ }
OpenLayers.Control.prototype.destroy.apply(this,arguments);
},
@@ -80,6 +97,7 @@
if(OpenLayers.Control.prototype.activate.apply(this,arguments)) {
this.dragPan.activate();
this.handlers.click.activate();
+ this.pinchZoom.activate();
return true;
}
return false;
@@ -92,11 +110,12 @@
if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)) {
this.dragPan.deactivate();
this.handlers.click.deactivate();
+ this.pinchZoom.deactivate();
return true;
}
return false;
},
-
+
/**
* Method: draw
*/
@@ -119,6 +138,9 @@
}, this.dragPanOptions)
);
this.dragPan.draw();
+ this.pinchZoom = new OpenLayers.Control.PinchZoom(
+ OpenLayers.Util.extend({map: this.map}, this.pinchZoomOptions)
+ );
},
/**
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Events.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Events.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Events.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -821,10 +821,20 @@
// noone's listening, bail out
return;
}
- // add clientX & clientY to all events - only corresponds to the first touch
- if (evt.touches && evt.touches[0]) {
- evt.clientX = evt.touches[0].clientX;
- evt.clientY = evt.touches[0].clientY;
+ // add clientX & clientY to all events - corresponds to average x, y
+ var touches = evt.touches;
+ if (touches && touches[0]) {
+ var x = 0;
+ var y = 0;
+ var num = touches.length;
+ var touch;
+ for (var i=0; i<num; ++i) {
+ touch = touches[i];
+ x += touch.clientX;
+ y += touch.clientY;
+ }
+ evt.clientX = x / num;
+ evt.clientY = y / num;
}
if (this.includeXY) {
evt.xy = this.getMousePosition(evt);
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Handler/Box.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Box.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Box.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -96,10 +96,10 @@
new OpenLayers.Pixel(-9999, -9999));
this.zoomBox.className = this.boxDivClassName;
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
+ this.map.eventsDiv.appendChild(this.zoomBox);
OpenLayers.Element.addClass(
- this.map.viewPortDiv, "olDrawBox"
+ this.map.eventsDiv, "olDrawBox"
);
},
@@ -157,11 +157,11 @@
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeBox: function() {
- this.map.viewPortDiv.removeChild(this.zoomBox);
+ this.map.eventsDiv.removeChild(this.zoomBox);
this.zoomBox = null;
this.boxCharacteristics = null;
OpenLayers.Element.removeClass(
- this.map.viewPortDiv, "olDrawBox"
+ this.map.eventsDiv, "olDrawBox"
);
},
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Click.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/lib/OpenLayers/Handler/Feature.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Feature.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Feature.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/lib/OpenLayers/Handler/Pinch.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Handler/Pinch.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Handler/Pinch.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -120,13 +120,15 @@
* {Boolean} Let the event propagate.
*/
touchmove: function(evt) {
+ var propagate = true;
if (this.started && OpenLayers.Event.isMultiTouch(evt)) {
this.pinching = true;
var current = this.getPinchData(evt);
this.callback("move", [evt, current]);
this.last = current;
+ propagate = false;
}
- return true;
+ return propagate;
},
/**
@@ -140,14 +142,16 @@
* {Boolean} Let the event propagate.
*/
touchend: function(evt) {
+ var propagate = true;
if (this.started) {
this.started = false;
this.pinching = false;
this.callback("done", [evt, this.start, this.last]);
this.start = null;
this.last = null;
+ propagate = false;
}
- return true;
+ return propagate;
},
/**
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Layer/EventPane.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Layer/EventPane.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Layer/EventPane.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -211,6 +211,22 @@
OpenLayers.Layer.prototype.setZIndex.apply(this, arguments);
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
},
+
+ /**
+ * Method: moveByPx
+ * Move the layer based on pixel vector. To be implemented by subclasses.
+ *
+ * Parameters:
+ * dx - {Number} The x coord of the displacement vector.
+ * dy - {Number} The y coord of the displacement vector.
+ */
+ moveByPx: function(dx, dy) {
+ OpenLayers.Layer.prototype.moveByPx.apply(this, arguments);
+
+ if (this.dragPanMapObject) {
+ this.dragPanMapObject(dx, -dy);
+ }
+ },
/**
* Method: moveTo
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Layer/Grid.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Layer/Grid.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -78,8 +78,11 @@
* {Integer} Used only when in gridded mode, this specifies the number of
* extra rows and colums of tiles on each side which will
* surround the minimum grid tiles to cover the map.
+ * For very slow loading layers, a larger value may increase
+ * performance somewhat when dragging, but will increase bandwidth
+ * use significantly.
*/
- buffer: 2,
+ buffer: 0,
/**
* APIProperty: numLoadingTiles
@@ -129,6 +132,20 @@
},
/**
+ * Method: removeMap
+ * Called when the layer is removed from the map.
+ *
+ * Parameters:
+ * map - {<OpenLayers.Map>} The map.
+ */
+ removeMap: function(map) {
+ if(this.timerId != null) {
+ window.clearTimeout(this.timerId);
+ this.timerId = null;
+ }
+ },
+
+ /**
* APIMethod: destroy
* Deconstruct the layer and clear the grid.
*/
@@ -234,19 +251,37 @@
if (forceReTile || !tilesBounds.containsBounds(bounds, true)) {
this.initGriddedTiles(bounds);
} else {
- // we might have to shift our buffer tiles, schedule
- // that
- if (this.timerId != null) {
- window.clearTimeout(this.timerId);
- }
- this.timerId = window.setTimeout(
- this._moveGriddedTiles,
- this.tileLoadingDelay
- );
+ this.scheduleMoveGriddedTiles();
}
}
}
},
+
+ /**
+ * Method: moveByPx
+ * Move the layer based on pixel vector.
+ *
+ * Parameters:
+ * dx - {Number}
+ * dy - {Number}
+ */
+ moveByPx: function(dx, dy) {
+ this.scheduleMoveGriddedTiles();
+ },
+
+ /**
+ * Method: scheduleMoveGriddedTiles
+ * Schedule the move of tiles.
+ */
+ scheduleMoveGriddedTiles: function() {
+ if (this.timerId != null) {
+ window.clearTimeout(this.timerId);
+ }
+ this.timerId = window.setTimeout(
+ this._moveGriddedTiles,
+ this.tileLoadingDelay
+ );
+ },
/**
* APIMethod: setTileSize
@@ -665,7 +700,9 @@
var shifted = true;
var buffer = this.buffer || 1;
var tlLayer = this.grid[0][0].position;
- var tlViewPort = this.map.getViewPortPxFromLayerPx(tlLayer);
+ var offsetX = parseInt(this.map.layerContainerDiv.style.left);
+ var offsetY = parseInt(this.map.layerContainerDiv.style.top);
+ tlViewPort = tlLayer.add(offsetX, offsetY);
if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) {
this.shiftColumn(true);
} else if (tlViewPort.x < -this.tileSize.w * buffer) {
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Layer/VirtualEarth.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Layer/VirtualEarth.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Layer/VirtualEarth.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Layer.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Layer.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -570,6 +570,17 @@
},
/**
+ * Method: moveByPx
+ * Move the layer based on pixel vector. To be implemented by subclasses.
+ *
+ * Parameters:
+ * dx - {Number} The x coord of the displacement vector.
+ * dy - {Number} The y coord of the displacement vector.
+ */
+ moveByPx: function(dx, dy) {
+ },
+
+ /**
* Method: setMap
* Set the map property for the layer. This is done through an accessor
* so that subclasses can override this and take special action once
@@ -815,13 +826,13 @@
// map
// 7. hope for the best!
- var i, len;
+ var i, len, p;
var props = {}, alwaysInRange = true;
// get resolution data from layer config
// (we also set alwaysInRange in the layer as appropriate)
for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
- var p = this.RESOLUTION_PROPERTIES[i];
+ p = this.RESOLUTION_PROPERTIES[i];
props[p] = this.options[p];
if(alwaysInRange && this.options[p]) {
alwaysInRange = false;
@@ -845,7 +856,7 @@
// in the map
if(props.resolutions == null) {
for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
- var p = this.RESOLUTION_PROPERTIES[i];
+ p = this.RESOLUTION_PROPERTIES[i];
props[p] = this.options[p] != null ?
this.options[p] : this.map[p];
}
@@ -960,6 +971,8 @@
*/
calculateResolutions: function(props) {
+ var viewSize, wRes, hRes;
+
// determine maxResolution
var maxResolution = props.maxResolution;
if(props.minScale != null) {
@@ -967,9 +980,9 @@
OpenLayers.Util.getResolutionFromScale(props.minScale,
this.units);
} else if(maxResolution == "auto" && this.maxExtent != null) {
- var viewSize = this.map.getSize();
- var wRes = this.maxExtent.getWidth() / viewSize.w;
- var hRes = this.maxExtent.getHeight() / viewSize.h;
+ viewSize = this.map.getSize();
+ wRes = this.maxExtent.getWidth() / viewSize.w;
+ hRes = this.maxExtent.getHeight() / viewSize.h;
maxResolution = Math.max(wRes, hRes);
}
@@ -980,9 +993,9 @@
OpenLayers.Util.getResolutionFromScale(props.maxScale,
this.units);
} else if(props.minResolution == "auto" && this.minExtent != null) {
- var viewSize = this.map.getSize();
- var wRes = this.minExtent.getWidth() / viewSize.w;
- var hRes = this.minExtent.getHeight()/ viewSize.h;
+ viewSize = this.map.getSize();
+ wRes = this.minExtent.getWidth() / viewSize.w;
+ hRes = this.minExtent.getHeight()/ viewSize.h;
minResolution = Math.max(wRes, hRes);
}
@@ -1141,14 +1154,14 @@
* value and the 'closest' specification.
*/
getZoomForResolution: function(resolution, closest) {
- var zoom;
+ var zoom, i, len;
if(this.map.fractionalZoom) {
var lowZoom = 0;
var highZoom = this.resolutions.length - 1;
var highRes = this.resolutions[lowZoom];
var lowRes = this.resolutions[highZoom];
var res;
- for(var i=0, len=this.resolutions.length; i<len; ++i) {
+ for(i=0, len=this.resolutions.length; i<len; ++i) {
res = this.resolutions[i];
if(res >= resolution) {
highRes = res;
@@ -1169,7 +1182,7 @@
} else {
var diff;
var minDiff = Number.POSITIVE_INFINITY;
- for(var i=0, len=this.resolutions.length; i<len; i++) {
+ for(i=0, len=this.resolutions.length; i<len; i++) {
if (closest) {
diff = Math.abs(this.resolutions[i] - resolution);
if (diff > minDiff) {
@@ -1199,22 +1212,17 @@
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
- if (viewPortPx != null) {
- var size = this.map.getSize();
- var center = this.map.getCenter();
- if (center) {
- var res = this.map.getResolution();
-
- var delta_x = viewPortPx.x - (size.w / 2);
- var delta_y = viewPortPx.y - (size.h / 2);
-
- lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
- center.lat - delta_y * res);
+ var map = this.map;
+ if (viewPortPx != null && map.minPx) {
+ var res = map.getResolution();
+ var maxExtent = map.getMaxExtent();
+ var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;
+ var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;
+ lonlat = new OpenLayers.LonLat(lon, lat);
- if (this.wrapDateLine) {
- lonlat = lonlat.wrapDateLine(this.maxExtent);
- }
- } // else { DEBUG STATEMENT }
+ if (this.wrapDateLine) {
+ lonlat = lonlat.wrapDateLine(this.maxExtent);
+ }
}
return lonlat;
},
Modified: sandbox/tschaub/canvas/lib/OpenLayers/Map.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers/Map.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers/Map.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -416,6 +416,23 @@
paddingForPopups : null,
/**
+ * Property: minPx
+ * {<OpenLayers.Pixel>} Lower left of maxExtent in viewport pixel space.
+ * Used to verify in moveByPx that the new location we're moving to
+ * is valid. It is also used in the getLonLatFromViewPortPx function
+ * of Layer.
+ */
+ minPx: null,
+
+ /**
+ * Property: maxPx
+ * {<OpenLayers.Pixel>} Top right of maxExtent in viewport pixel space.
+ * Used to verify in moveByPx that the new location we're moving to
+ * is valid.
+ */
+ maxPx: null,
+
+ /**
* Constructor: OpenLayers.Map
* Constructor for a new OpenLayers.Map instance. There are two possible
* ways to call the map constructor. See the examples below.
@@ -600,6 +617,14 @@
// add any initial layers
if (options && options.layers) {
+ /**
+ * If you have set options.center, the map center property will be
+ * set at this point. However, since setCenter has not been caleld,
+ * addLayers gets confused. So we delete the map center in this
+ * case. Because the check below uses options.center, it will
+ * be properly set below.
+ */
+ delete this.center;
this.addLayers(options.layers);
// set center (and optionally zoom)
if (options.center) {
@@ -643,7 +668,15 @@
/**
* APIMethod: destroy
- * Destroy this map
+ * Destroy this map.
+ * Note that if you are using an application which removes a container
+ * of the map from the DOM, you need to ensure that you destroy the
+ * map *before* this happens; otherwise, the page unload handler
+ * will fail because the DOM elements that map.destroy() wants
+ * to clean up will be gone. (See
+ * http://trac.osgeo.org/openlayers/ticket/2277 for more information).
+ * This will apply to GeoExt and also to other applications which
+ * modify the DOM of the container of the OpenLayers Map.
*/
destroy:function() {
// if unloadDestroy is null, we've already been destroyed
@@ -1124,7 +1157,7 @@
if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
// preserve center and scale when changing base layers
- var center = this.getCenter();
+ var center = this.getCachedCenter();
var newResolution = OpenLayers.Util.getResolutionFromScale(
this.getScale(), newBaseLayer.units
);
@@ -1386,7 +1419,7 @@
this.layers[i].onMapResize();
}
- var center = this.getCenter();
+ var center = this.getCachedCenter();
if (this.baseLayer != null && center != null) {
var zoom = this.getZoom();
@@ -1437,7 +1470,7 @@
var extent = null;
if (center == null) {
- center = this.getCenter();
+ center = this.getCachedCenter();
}
if (resolution == null) {
resolution = this.getResolution();
@@ -1477,12 +1510,27 @@
*/
getCenter: function () {
var center = null;
- if (this.center) {
- center = this.center.clone();
+ var cachedCenter = this.getCachedCenter();
+ if (cachedCenter) {
+ center = cachedCenter.clone();
}
return center;
},
+ /**
+ * Method: getCachedCenter
+ *
+ * Returns:
+ * {<OpenLayers.LonLat>}
+ */
+ getCachedCenter: function() {
+ if (!this.center && this.size) {
+ this.center = this.getLonLatFromViewPortPx(
+ new OpenLayers.Pixel(this.size.w / 2, this.size.h / 2)
+ );
+ }
+ return this.center;
+ },
/**
* APIMethod: getZoom
@@ -1511,22 +1559,30 @@
animate: true,
dragging: false
});
- // getCenter
- var centerPx = this.getViewPortPxFromLonLat(this.getCenter());
+ if (options.dragging) {
+ if (dx != 0 || dy != 0) {
+ this.moveByPx(dx, dy);
+ }
+ } else {
+ // if we don't have a center, we were using moveByPx previously
+ var forceSetCenter = !this.center;
+
+ // getCenter
+ var centerPx = this.getViewPortPxFromLonLat(this.getCachedCenter());
- // adjust
- var newCenterPx = centerPx.add(dx, dy);
-
- // only call setCenter if not dragging or there has been a change
- if (!options.dragging || !newCenterPx.equals(centerPx)) {
- var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);
- if (options.animate) {
- this.panTo(newCenterLonLat);
- } else {
- this.setCenter(newCenterLonLat, null, options.dragging);
- }
- }
+ // adjust
+ var newCenterPx = centerPx.add(dx, dy);
+ if (forceSetCenter || !newCenterPx.equals(centerPx)) {
+ var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);
+ if (options.animate) {
+ this.panTo(newCenterLonLat);
+ } else {
+ this.setCenter(newCenterLonLat, null, options.dragging);
+ }
+ }
+ }
+
},
/**
@@ -1542,7 +1598,7 @@
if (!this.panTween) {
this.panTween = new OpenLayers.Tween(this.panMethod);
}
- var center = this.getCenter();
+ var center = this.getCachedCenter();
// center will not change, don't do nothing
if (lonlat.lon == center.lon &&
@@ -1550,31 +1606,25 @@
return;
}
- var from = {
- lon: center.lon,
- lat: center.lat
- };
- var to = {
- lon: lonlat.lon,
- lat: lonlat.lat
- };
- this.panTween.start(from, to, this.panDuration, {
+ var from = this.getPixelFromLonLat(center);
+ var to = this.getPixelFromLonLat(lonlat);
+ var vector = { x: to.x - from.x, y: to.y - from.y };
+ var last = { x: 0, y: 0 };
+
+ this.panTween.start( { x: 0, y: 0 }, vector, this.panDuration, {
callbacks: {
- start: OpenLayers.Function.bind(function(lonlat) {
+ start: OpenLayers.Function.bind(function() {
this.events.triggerEvent("movestart");
}, this),
- eachStep: OpenLayers.Function.bind(function(lonlat) {
- lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat);
- this.moveTo(lonlat, this.zoom, {
- 'dragging': true,
- 'noEvent': true
- });
+ eachStep: OpenLayers.Function.bind(function(px) {
+ var x = px.x - last.x,
+ y = px.y - last.y;
+ this.moveByPx(x, y);
+ last.x = Math.round(px.x);
+ last.y = Math.round(px.y);
}, this),
- done: OpenLayers.Function.bind(function(lonlat) {
- lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat);
- this.moveTo(lonlat, this.zoom, {
- 'noEvent': true
- });
+ done: OpenLayers.Function.bind(function(px) {
+ this.moveTo(lonlat, this.zoom, {noEvent: true});
this.events.triggerEvent("moveend");
}, this)
}
@@ -1605,6 +1655,71 @@
'caller': 'setCenter'
});
},
+
+ /**
+ * Method: moveByPx
+ * Drag the map by pixels.
+ *
+ * Parameters:
+ * dx - {Number}
+ * dy - {Number}
+ */
+ moveByPx: function(dx, dy) {
+ dx = Math.round(dx);
+ dy = Math.round(dy);
+ var hw = this.size.w / 2;
+ var hh = this.size.h / 2;
+ var x = hw + dx;
+ var y = hh + dy;
+ var valid = y <= this.maxPx.y &&
+ y >= this.minPx.y;
+ var minX, maxX;
+ if (this.baseLayer.wrapDateLine === true) {
+ minX = this.minPx.x, maxX = this.maxPx.x;
+ } else {
+ valid = valid &&
+ x <= this.maxPx.x &&
+ x >= this.minPx.x;
+ }
+ if (this.restrictedExtent && valid) {
+ valid = !(this.maxPx.x - x < hw ||
+ x - this.minPx.x < hw ||
+ this.maxPx.y - y < hh ||
+ y - this.minPx.y < hh);
+ }
+ if (valid) {
+ this.center = null;
+ if (dx) {
+ this.layerContainerDiv.style.left =
+ parseInt(this.layerContainerDiv.style.left) - dx + "px";
+ this.minPx.x -= dx;
+ this.maxPx.x -= dx;
+ if (this.baseLayer.wrapDateLine === true) {
+ if (this.maxPx.x > maxX) {
+ this.maxPx.x -= (maxX - minX);
+ };
+ if (this.minPx.x < minX) {
+ this.minPx.x += (maxX - minX);
+ };
+ }
+ }
+ if (dy) {
+ this.layerContainerDiv.style.top =
+ parseInt(this.layerContainerDiv.style.top) - dy + "px";
+ this.minPx.y -= dy;
+ this.maxPx.y -= dy;
+ }
+ var layer, i, len;
+ for (i=0, len=this.layers.length; i<len; ++i) {
+ layer = this.layers[i];
+ if (layer.visibility) {
+ layer.moveByPx(dx, dy);
+ layer.events.triggerEvent("move");
+ }
+ }
+ this.events.triggerEvent("move");
+ }
+ },
/**
* Method: moveTo
@@ -1635,14 +1750,14 @@
this.panTween.stop();
}
- if (!this.center && !this.isValidLonLat(lonlat)) {
+ if (!this.getCachedCenter() && !this.isValidLonLat(lonlat)) {
lonlat = this.maxExtent.getCenterLonLat();
}
if(this.restrictedExtent != null) {
// In 3.0, decide if we want to change interpretation of maxExtent.
if(lonlat == null) {
- lonlat = this.getCenter();
+ lonlat = this.center;
}
if(zoom == null) {
zoom = this.getZoom();
@@ -1689,7 +1804,7 @@
}
if (centerChanged) {
- if ((!zoomChanged) && (this.center)) {
+ if (!zoomChanged && this.center) {
// if zoom hasnt changed, just slide layerContainer
// (must be done before setting this.center to new value)
this.centerLayerContainer(lonlat);
@@ -1697,16 +1812,28 @@
this.center = lonlat.clone();
}
+ var res = zoomChanged ?
+ this.getResolutionForZoom(zoom) : this.getResolution();
// (re)set the layerContainerDiv's location
- if ((zoomChanged) || (this.layerContainerOrigin == null)) {
- this.layerContainerOrigin = this.center.clone();
+ if (zoomChanged || this.layerContainerOrigin == null) {
+ this.layerContainerOrigin = this.getCachedCenter();
this.layerContainerDiv.style.left = "0px";
this.layerContainerDiv.style.top = "0px";
+ var maxExtent = this.getMaxExtent({restricted: true});
+ var maxExtentCenter = maxExtent.getCenterLonLat();
+ var lonDelta = this.center.lon - maxExtentCenter.lon;
+ var latDelta = maxExtentCenter.lat - this.center.lat;
+ var extentWidth = Math.round(maxExtent.getWidth() / res);
+ var extentHeight = Math.round(maxExtent.getHeight() / res);
+ var left = (this.size.w - extentWidth) / 2 - lonDelta / res;
+ var top = (this.size.h - extentHeight) / 2 - latDelta / res;
+ this.minPx = new OpenLayers.Pixel(left, top);
+ this.maxPx = new OpenLayers.Pixel(left + extentWidth, top + extentHeight);
}
if (zoomChanged) {
this.zoom = zoom;
- this.resolution = this.getResolutionForZoom(zoom);
+ this.resolution = res;
// zoom level has changed, increment viewRequestID.
this.viewRequestID++;
}
@@ -1788,14 +1915,23 @@
* lonlat - {<OpenLayers.LonLat>}
*/
centerLayerContainer: function (lonlat) {
-
var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin);
var newPx = this.getViewPortPxFromLonLat(lonlat);
if ((originPx != null) && (newPx != null)) {
- this.layerContainerDiv.style.left = Math.round(originPx.x - newPx.x) + "px";
- this.layerContainerDiv.style.top = Math.round(originPx.y - newPx.y) + "px";
- }
+ var oldLeft = parseInt(this.layerContainerDiv.style.left);
+ var oldTop = parseInt(this.layerContainerDiv.style.top);
+ var newLeft = Math.round(originPx.x - newPx.x);
+ var newTop = Math.round(originPx.y - newPx.y);
+ this.layerContainerDiv.style.left = newLeft + "px";
+ this.layerContainerDiv.style.top = newTop + "px";
+ var dx = oldLeft - newLeft;
+ var dy = oldTop - newTop;
+ this.minPx.x -= dx;
+ this.maxPx.x -= dx;
+ this.minPx.y -= dy;
+ this.maxPx.y -= dy;
+ }
},
/**
@@ -2209,7 +2345,7 @@
var size = this.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
- var center = this.getCenter();
+ var center = this.getCachedCenter();
var extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
@@ -2321,8 +2457,8 @@
* {<OpenLayers.Size>} The geodesic size of the pixel in kilometers.
*/
getGeodesicPixelSize: function(px) {
- var lonlat = px ? this.getLonLatFromPixel(px) : (this.getCenter() ||
- new OpenLayers.LonLat(0, 0));
+ var lonlat = px ? this.getLonLatFromPixel(px) : (
+ this.getCachedCenter() || new OpenLayers.LonLat(0, 0));
var res = this.getResolution();
var left = lonlat.add(-res / 2, 0);
var right = lonlat.add(res / 2, 0);
Modified: sandbox/tschaub/canvas/lib/OpenLayers.js
===================================================================
--- sandbox/tschaub/canvas/lib/OpenLayers.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/lib/OpenLayers.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -182,6 +182,7 @@
"OpenLayers/Control/ZoomToMaxExtent.js",
"OpenLayers/Control/DragPan.js",
"OpenLayers/Control/Navigation.js",
+ "OpenLayers/Control/PinchZoom.js",
"OpenLayers/Control/TouchNavigation.js",
"OpenLayers/Control/MouseDefaults.js",
"OpenLayers/Control/MousePosition.js",
Modified: sandbox/tschaub/canvas/tests/BaseTypes/Pixel.html
===================================================================
--- sandbox/tschaub/canvas/tests/BaseTypes/Pixel.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/BaseTypes/Pixel.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -40,11 +40,22 @@
t.eq( pixel.x, 5, "changing oldPixel.x doesn't change pixel.x");
}
+ function test_Pixel_distanceTo(t) {
+ t.plan( 2 );
+ var px = new OpenLayers.Pixel(0,-2);
+ pixel = new OpenLayers.Pixel(0,0);
+ t.eq( pixel.distanceTo(px), 2, "(0,0) distanceTo (0,-2) = 2");
+
+ px = new OpenLayers.Pixel(-4,6);
+ pixel = new OpenLayers.Pixel(4,6);
+ t.eq( pixel.distanceTo(px), 8, "(4,6) distanceTo (-4,6) = 8");
+ }
+
function test_Pixel_equals(t) {
t.plan( 5 );
pixel = new OpenLayers.Pixel(5,6);
- px = new OpenLayers.Pixel(5,6);
+ var px = new OpenLayers.Pixel(5,6);
t.eq( pixel.equals(px), true, "(5,6) equals (5,6)");
px = new OpenLayers.Pixel(1,6);
Modified: sandbox/tschaub/canvas/tests/Control/Geolocate.html
===================================================================
--- sandbox/tschaub/canvas/tests/Control/Geolocate.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Control/Geolocate.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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,
@@ -113,6 +113,17 @@
map.addControl(control);
control.activate();
}
+ function test_destroy(t) {
+ t.plan(1);
+ var control = new OpenLayers.Control.Geolocate({
+ geolocation: geolocation,
+ watch: true
+ });
+ control.activate();
+ control.destroy();
+ t.ok(control.active === false, "control deactivated before being destroyed");
+ }
+
function loader() {
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("Test Layer",
Modified: sandbox/tschaub/canvas/tests/Control/Navigation.html
===================================================================
--- sandbox/tschaub/canvas/tests/Control/Navigation.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Control/Navigation.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -118,6 +118,27 @@
t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
t.eq(wheel.active, true, "mouse wheel handler activated");
}
+
+ function test_touches_zoom(t) {
+ t.plan(3);
+ var nav = new OpenLayers.Control.Navigation({zoomWheelEnabled: false});
+ var map = new OpenLayers.Map({
+ div: "map",
+ controls: [nav],
+ layers: [
+ new OpenLayers.Layer(null, {isBaseLayer: true})
+ ],
+ center: new OpenLayers.LonLat(0, 0),
+ zoom: 3
+ });
+ t.eq(map.getZoom(), 3, "map zoom starts at 3");
+ nav.handlers.click.callback("click", [{lastTouches: ["foo", "bar"]}]);
+ t.eq(map.getZoom(), 2, "map zooms out with a two touch tap");
+ nav.handlers.click.callback("click", [{}]);
+ t.eq(map.getZoom(), 2, "map doesn't do anything with click");
+
+ map.destroy();
+ }
function test_documentDrag(t) {
@@ -149,5 +170,6 @@
</script>
</head>
<body>
+ <div id="map" style="width: 256px; height: 256px"></div>
</body>
</html>
Copied: sandbox/tschaub/canvas/tests/Control/PinchZoom.html (from rev 11552, trunk/openlayers/tests/Control/PinchZoom.html)
===================================================================
--- sandbox/tschaub/canvas/tests/Control/PinchZoom.html (rev 0)
+++ sandbox/tschaub/canvas/tests/Control/PinchZoom.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,87 @@
+<html>
+<head>
+ <script src="../OLLoader.js"></script>
+ <script type="text/javascript">
+
+ function test_constructor(t) {
+ t.plan(2);
+ var control = new OpenLayers.Control.PinchZoom();
+ t.ok(control instanceof OpenLayers.Control.PinchZoom, "got an instance");
+ t.ok(control.handler instanceof OpenLayers.Handler.Pinch, "control has pinch handler");
+ control.destroy();
+ }
+
+ function test_destroy(t) {
+ t.plan(1);
+ var control = new OpenLayers.Control.PinchZoom();
+ control.destroy();
+ t.ok(!control.handler, "handler destroyed");
+ }
+
+ function test_activate(t) {
+ t.plan(3);
+ var control = new OpenLayers.Control.PinchZoom();
+ t.ok(!control.active, "control not activated after construction");
+
+ var map = new OpenLayers.Map({
+ div: "map",
+ controls: [control]
+ });
+ t.ok(control.active, "control activated after being added to the map");
+
+ control.deactivate();
+ t.ok(!control.active, "control deactivated");
+
+ map.destroy();
+ }
+
+ function test_pinchMove(t) {
+
+ var control = new OpenLayers.Control.PinchZoom();
+
+ var map = new OpenLayers.Map({
+ div: "map",
+ controls: [control]
+ });
+
+ var log = [];
+ control.applyTransform = function(transform) {
+ log.push(transform);
+ }
+
+ control.containerOrigin = {
+ x: 0, y: 0
+ };
+
+ control.pinchOrigin = {
+ x: 100, y: 50
+ };
+
+ var cases = [
+ {x: 100, y: 60, scale: 1, transform: "translate(0px, 10px) scale(1)"},
+ {x: 150, y: 60, scale: 1, transform: "translate(50px, 10px) scale(1)"},
+ {x: 150, y: 60, scale: 2, transform: "translate(-50px, -40px) scale(2)"},
+ {x: 50, y: 20, scale: 2.5, transform: "translate(-200px, -105px) scale(2.5)"},
+ {x: 150, y: 60, scale: 2, transform: "translate(-50px, -40px) scale(2)"},
+ {x: 50, y: 20, scale: 0.25, transform: "translate(25px, 8px) scale(0.25)"}
+ ];
+
+ var len = cases.length;
+ t.plan(len*2);
+
+ var c;
+ for (var i=0; i<len; ++i) {
+ c = cases[i];
+ control.pinchMove({xy: {x: c.x, y: c.y}}, {scale: c.scale});
+ t.eq(log.length, i+1, i + " called once");
+ t.eq(log[i], c.transform, i + " correct transform");
+ }
+
+ }
+
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 256px; height: 256px;"></div>
+</body>
+</html>
Modified: sandbox/tschaub/canvas/tests/Handler/Click.html
===================================================================
--- sandbox/tschaub/canvas/tests/Handler/Click.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Handler/Click.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/tests/Handler/Feature.html
===================================================================
--- sandbox/tschaub/canvas/tests/Handler/Feature.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Handler/Feature.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -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/tschaub/canvas/tests/Layer/ArcGIS93Rest.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/ArcGIS93Rest.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/ArcGIS93Rest.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -94,7 +94,7 @@
var params = {layers: "show:0,2"};
t.plan( 2 );
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.ArcGIS93Rest(name, url, params);
+ layer = new OpenLayers.Layer.ArcGIS93Rest(name, url, params, {buffer: 2});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),5);
t.eq( layer.grid.length, 7, "Grid rows is correct." );
Modified: sandbox/tschaub/canvas/tests/Layer/Grid.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/Grid.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/Grid.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -27,7 +27,7 @@
layer = new OpenLayers.Layer.Grid(name, url, params, null);
t.ok( layer instanceof OpenLayers.Layer.Grid, "returns OpenLayers.Layer.Grid object" );
- t.eq( layer.buffer, 2, "buffer default is 2");
+ t.eq( layer.buffer, 0, "buffer default is 0");
t.eq( layer.ratio, 1.5, "ratio default is 1.5");
t.eq( layer.numLoadingTiles, 0, "numLoadingTiles starts at 0");
t.ok( layer.events.listeners["tileloaded"] != null, "'tileloaded' event added to layer's event types");
@@ -47,7 +47,7 @@
function test_Layer_Grid_inittiles (t) {
t.plan( 2 );
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.WMS(name, url, params);
+ layer = new OpenLayers.Layer.WMS(name, url, params, {buffer:2});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),5);
t.eq( layer.grid.length, 7, "Grid rows is correct." );
@@ -593,7 +593,7 @@
function test_Layer_Grid_destroy (t) {
- t.plan( 7 );
+ t.plan( 8 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Grid(name, url, params);
@@ -608,6 +608,7 @@
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 10);
+ map.setCenter(new OpenLayers.LonLat(1,1));
//grab a reference to one of the tiles
@@ -616,6 +617,7 @@
layer.destroy();
t.eq( tile.imgDiv, null, "Tile destroyed" );
+ t.eq( layer.timerId, null, "Tile loading timeout cleared");
t.ok( layer.grid == null, "tiles appropriately destroyed")
Modified: sandbox/tschaub/canvas/tests/Layer/Image.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/Image.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/Image.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -146,7 +146,7 @@
delay = true;
});
- t.delay_call(0.4,function() {
+ t.delay_call(5, function() {
t.eq(delay, true, "registered for loadend");
t.eq(layer.tile.isLoading, false, "loadend triggered after tile is loaded");
map.destroy(); //tear down
Modified: sandbox/tschaub/canvas/tests/Layer/KaMap.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/KaMap.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/KaMap.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -65,8 +65,8 @@
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),5);
- t.eq( layer.grid.length, 8, "KaMap rows is correct." );
- t.eq( layer.grid[0].length, 6, "KaMap cols is correct." );
+ t.eq( layer.grid.length, 4, "KaMap rows is correct." );
+ t.eq( layer.grid[0].length, 3, "KaMap cols is correct." );
map.destroy();
}
Modified: sandbox/tschaub/canvas/tests/Layer/MapGuide.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/MapGuide.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/MapGuide.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -69,7 +69,7 @@
layer = new OpenLayers.Layer.MapGuide(name, url, paramsTiled);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,400000),5);
- t.eq( layer.grid.length, 6, "Grid rows is correct." );
+ t.eq( layer.grid.length, 3, "Grid rows is correct." );
// t.eq( layer.grid[0].length, 6, "Grid cols is correct." );
map.destroy();
}
Modified: sandbox/tschaub/canvas/tests/Layer/MapServer.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/MapServer.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/MapServer.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -74,11 +74,11 @@
function test_Layer_MapServer_inittiles (t) {
t.plan( 2 );
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.MapServer(name, url, params);
+ layer = new OpenLayers.Layer.MapServer(name, url, params, {buffer: 0});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),5);
- t.eq( layer.grid.length, 7, "Grid rows is correct." );
- t.eq( layer.grid[0].length, 6, "Grid cols is correct." );
+ t.eq( layer.grid.length, 4, "Grid rows is correct." );
+ t.eq( layer.grid[0].length, 3, "Grid cols is correct." );
map.destroy();
}
@@ -234,7 +234,7 @@
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.Google("Google");
map.addLayer(layer);
- layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, reproject: true});
+ layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, reproject: true, buffer: 2});
layer.isBaseLayer=false;
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
@@ -251,7 +251,7 @@
}
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.MapServer(name, url, params);
+ layer = new OpenLayers.Layer.MapServer(name, url, params, {buffer:2});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0];
Modified: sandbox/tschaub/canvas/tests/Layer/TMS.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/TMS.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/TMS.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -134,7 +134,7 @@
t.plan(1);
m = new OpenLayers.Map("map", {'maxExtent':new OpenLayers.Bounds(-122.6579,37.4901,-122.0738,37.8795)});
layer = new OpenLayers.Layer.TMS( "TMS",
- "http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
+ "http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png', resolutions:[0.000634956337608418], buffer: 2} );
m.addLayer(layer);
m.zoomToMaxExtent();
t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/1.png", "TMS tiles around rounded properly.");
Modified: sandbox/tschaub/canvas/tests/Layer/WMS.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/WMS.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/WMS.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -146,7 +146,7 @@
function test_Layer_WMS_inittiles (t) {
t.plan( 2 );
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.WMS(name, url, params);
+ layer = new OpenLayers.Layer.WMS(name, url, params, {buffer:2});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),5);
t.eq( layer.grid.length, 7, "Grid rows is correct." );
@@ -312,7 +312,7 @@
var layer = new OpenLayers.Layer.Google("Google");
map.addLayer(layer);
var wmslayer = new OpenLayers.Layer.WMS(name, url, params,
- {isBaseLayer: false, reproject:true});
+ {isBaseLayer: false, reproject:true, buffer: 2});
wmslayer.isBaseLayer=false;
map.addLayer(wmslayer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
@@ -329,7 +329,7 @@
}
var map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.WMS(name, url, params);
+ layer = new OpenLayers.Layer.WMS(name, url, params, {buffer: 2});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0];
Modified: sandbox/tschaub/canvas/tests/Layer/WrapDateLine.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/WrapDateLine.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/WrapDateLine.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -130,7 +130,7 @@
t.plan( 3 );
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
- layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true});
+ layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2});
var m = new OpenLayers.Map('map');
m.addLayer(layer);
m.zoomToMaxExtent();
@@ -146,7 +146,7 @@
var layer = new OpenLayers.Layer.KaMap( "Blue Marble NG",
"http://www.openlayers.org/world/index.php",
{g: "satellite", map: "world"},
- {wrapDateLine: true} );
+ {wrapDateLine: true, buffer: 2} );
var m = new OpenLayers.Map('map');
m.addLayer(layer);
m.zoomToMaxExtent();
@@ -158,13 +158,13 @@
function test_Layer_WrapDateLine_WMS_Overlay (t) {
t.plan( 3 );
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
- baselayer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true});
+ baselayer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true, buffer: 2});
var layer = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png"},
- {wrapDateLine: true, reproject: false,encodeBBOX:true});
+ {wrapDateLine: true, reproject: false,encodeBBOX:true, buffer:2});
var m = new OpenLayers.Map('map');
m.addLayers([baselayer,layer]);
m.zoomToMaxExtent();
Modified: sandbox/tschaub/canvas/tests/Layer/XYZ.html
===================================================================
--- sandbox/tschaub/canvas/tests/Layer/XYZ.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Layer/XYZ.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -126,7 +126,7 @@
t.plan(1);
m = new OpenLayers.Map("map", {'maxExtent':new OpenLayers.Bounds(-122.6579,37.4901,-122.0738,37.8795)});
layer = new OpenLayers.Layer.XYZ( "XYZ",
- url, {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
+ url, {layername: 'basic', type:'png', resolutions:[0.000634956337608418], buffer: 2} );
m.addLayer(layer);
m.zoomToMaxExtent()
t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/0.png", "XYZ tiles around rounded properly.");
Modified: sandbox/tschaub/canvas/tests/Map.html
===================================================================
--- sandbox/tschaub/canvas/tests/Map.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/Map.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -352,6 +352,8 @@
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [19]);
t.eq(valid, false, "19 is not a valid zoomLevel when baseLayer has restrictedMinZoom of 1");
+
+ map.destroy();
}
function test_Map_isValidLonLat(t) {
@@ -977,6 +979,8 @@
map.addControls(controls2, pixels2);
t.eq(map.controls.length, 5, "three additional controls were added by map.addControls with a px-array");
t.eq(map.controls[3].position.toString(), pixels2[1].toString(), "control 'fourthctrl' has position set to given px");
+
+ map.destroy();
}
function test_Map_getControl(t) {
@@ -1319,7 +1323,7 @@
var m = {
'baseLayer': { 'units': {} },
'getSize': function() { return {'w': 10, 'h': 15}; },
- 'getCenter': function() { return {'lon': -5, 'lat': -25}; },
+ 'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; },
'zoomToExtent': function(extent, closest) {
t.ok(extent.equals(g_ExpectedExtent), "extent correctly calculated for zoomToExtent()");
t.ok(closest == g_Closest, "closest correctly passed on to zoomToExtent()");
@@ -1598,11 +1602,13 @@
t.eq(map.layers.length, 2, "multiple layers added from options");
t.ok(map.baseLayer, "map has a base layer");
+
+ map.destroy();
}
function test_center_option(t) {
- t.plan(6);
+ t.plan(7);
var map, msg;
@@ -1625,6 +1631,12 @@
map.destroy();
}
+ var log = [];
+ var meth = OpenLayers.Layer.prototype.moveTo;
+ OpenLayers.Layer.prototype.moveTo = function() {
+ log.push(arguments);
+ meth.apply(this, arguments);
+ };
// set center without zoom
var center = new OpenLayers.LonLat(1, 2);
@@ -1635,8 +1647,10 @@
});
t.ok(center.equals(map.getCenter()), "map center set without zoom");
+ t.eq(log.length, 1, "moveTo called once");
map.destroy();
+ OpenLayers.Layer.prototype.moveTo = meth;
// set center and zoom
var zoom = 3;
@@ -1687,6 +1701,41 @@
map.destroy();
}
+ function test_moveByPx(t) {
+ t.plan(8);
+
+ var map = new OpenLayers.Map({
+ div: 'map',
+ maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50),
+ restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
+ layers: [
+ new OpenLayers.Layer('name', {isBaseLayer: true})
+ ]
+ });
+ map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1));
+
+ // check initial state
+ t.eq(map.layerContainerDiv.style.left, '0px', 'layer container left correct');
+ t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
+
+ // move to a valid position
+ map.moveByPx(-455, 455);
+ t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
+ t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+
+ // move outside the max extent
+ map.moveByPx(-4500, 4500);
+ t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
+ t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+
+ // move outside the restricted extent
+ map.moveByPx(-500, 500);
+ t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
+ t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
+
+ map.destroy();
+ }
+
</script>
</head>
<body>
Modified: sandbox/tschaub/canvas/tests/list-tests.html
===================================================================
--- sandbox/tschaub/canvas/tests/list-tests.html 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/list-tests.html 2011-02-27 10:37:39 UTC (rev 11553)
@@ -32,6 +32,7 @@
<li>Control/PanZoom.html</li>
<li>Control/PanZoomBar.html</li>
<li>Control/Permalink.html</li>
+ <li>Control/PinchZoom.html</li>
<li>Control/Scale.html</li>
<li>Control/ScaleLine.html</li>
<li>Control/SelectFeature.html</li>
Deleted: sandbox/tschaub/canvas/tests/node.js/mockdom.js
===================================================================
--- trunk/openlayers/tests/node.js/mockdom.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/node.js/mockdom.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,106 +0,0 @@
-XMLHttpRequest = function() {
- return {
- 'open': function() { },
- 'send': function() { }
- }
-};
-
-alert = print;
-
-navigator = {
- 'appName': 'mockdom',
- 'userAgent': 'mockdom',
- 'appVersion': '0.1',
- 'language': 'en',
- 'userLanguage': 'en'
-}
-
-element = function(type) {
- type = type || "";
-
- return {
- 'childNodes': [],
- 'className': '',
- 'tagName': type.toUpperCase(),
- 'style': {},
- 'setAttribute': function(attr, value) {
- this[attr] = value;
- },
- 'appendChild': function(element) {
- if (this.childNodes.length) {
- this.childNodes[this.childNodes.length - 1].nextSibling = element;
- } else {
- this.firstChild = element;
- }
- element.parentNode = this;
- this.childNodes.push(element);
-
- },
- 'removeChild': function(element) {
- var i = this.childNodes.indexOf(element);
- this.childNodes.splice(i, 1);
- },
- 'addEventListener': function() {
- },
- 'removeEventListener': function() {
- },
- 'getElementsByTagName': function(name, externalList) {
- var uc = name.toUpperCase();
- var list = externalList || [];
- for(var i = 0; i < this.childNodes.length; i++) {
- if (this.childNodes[i].tagName == uc) {
- list.push(this.childNodes[i]);
- }
- this.childNodes[i].getElementsByTagName(name, list);
- }
- return list;
- },
- 'getElementById': function(id) {
- for(var i = 0; i < this.childNodes.length; i++) {
- if (this.childNodes[i].id == id) {
- return this.childNodes[i];
- } else {
- var elem = this.childNodes[i].getElementById(id);
- if (elem) {
- return elem
- }
- }
- }
- }
- }
-};
-
-document = element();
-document.createElement = function(type) {
- return element(type);
-};
-document.createTextNode = function(text) {
- var e = element("Text");
- e.innerHTML = text;
-}
-
-document.appendChild(element("head"));
-document.body = element("body");
-document.appendChild(document.body);
-
-window = {
- 'addEventListener': function() {
- },
- 'getSelection': function() {
- return {
- collapseToStart: function() {}
- }
- },
- document: document,
- navigator: navigator,
- location: {
- href: '#',
- port: '',
- hostname: 'openlayers.org',
- host: 'openlayers.org',
- proto: 'https'
- }
-};
-document.location = window.location;
-
-window.Function = Function;
Copied: sandbox/tschaub/canvas/tests/node.js/mockdom.js (from rev 11552, trunk/openlayers/tests/node.js/mockdom.js)
===================================================================
--- sandbox/tschaub/canvas/tests/node.js/mockdom.js (rev 0)
+++ sandbox/tschaub/canvas/tests/node.js/mockdom.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,106 @@
+XMLHttpRequest = function() {
+ return {
+ 'open': function() { },
+ 'send': function() { }
+ }
+};
+
+alert = print;
+
+navigator = {
+ 'appName': 'mockdom',
+ 'userAgent': 'mockdom',
+ 'appVersion': '0.1',
+ 'language': 'en',
+ 'userLanguage': 'en'
+}
+
+element = function(type) {
+ type = type || "";
+
+ return {
+ 'childNodes': [],
+ 'className': '',
+ 'tagName': type.toUpperCase(),
+ 'style': {},
+ 'setAttribute': function(attr, value) {
+ this[attr] = value;
+ },
+ 'appendChild': function(element) {
+ if (this.childNodes.length) {
+ this.childNodes[this.childNodes.length - 1].nextSibling = element;
+ } else {
+ this.firstChild = element;
+ }
+ element.parentNode = this;
+ this.childNodes.push(element);
+
+ },
+ 'removeChild': function(element) {
+ var i = this.childNodes.indexOf(element);
+ this.childNodes.splice(i, 1);
+ },
+ 'addEventListener': function() {
+ },
+ 'removeEventListener': function() {
+ },
+ 'getElementsByTagName': function(name, externalList) {
+ var uc = name.toUpperCase();
+ var list = externalList || [];
+ for(var i = 0; i < this.childNodes.length; i++) {
+ if (this.childNodes[i].tagName == uc) {
+ list.push(this.childNodes[i]);
+ }
+ this.childNodes[i].getElementsByTagName(name, list);
+ }
+ return list;
+ },
+ 'getElementById': function(id) {
+ for(var i = 0; i < this.childNodes.length; i++) {
+ if (this.childNodes[i].id == id) {
+ return this.childNodes[i];
+ } else {
+ var elem = this.childNodes[i].getElementById(id);
+ if (elem) {
+ return elem
+ }
+ }
+ }
+ }
+ }
+};
+
+document = element();
+document.createElement = function(type) {
+ return element(type);
+};
+document.createTextNode = function(text) {
+ var e = element("Text");
+ e.innerHTML = text;
+}
+
+document.appendChild(element("head"));
+document.body = element("body");
+document.appendChild(document.body);
+
+window = {
+ 'addEventListener': function() {
+ },
+ 'getSelection': function() {
+ return {
+ collapseToStart: function() {}
+ }
+ },
+ document: document,
+ navigator: navigator,
+ location: {
+ href: '#',
+ port: '',
+ hostname: 'openlayers.org',
+ host: 'openlayers.org',
+ proto: 'https'
+ }
+};
+document.location = window.location;
+
+window.Function = Function;
Deleted: sandbox/tschaub/canvas/tests/node.js/node-tests.cfg
===================================================================
--- trunk/openlayers/tests/node.js/node-tests.cfg 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/node.js/node-tests.cfg 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,12 +0,0 @@
-# This build config is supposed to be used for the units tests with "mode=build"
-
-[first]
-mockdom.js
-[last]
-node.js
-
-[include]
-
-[exclude]
-OpenLayers.js
-Firebug/firebug.js
Copied: sandbox/tschaub/canvas/tests/node.js/node-tests.cfg (from rev 11552, trunk/openlayers/tests/node.js/node-tests.cfg)
===================================================================
--- sandbox/tschaub/canvas/tests/node.js/node-tests.cfg (rev 0)
+++ sandbox/tschaub/canvas/tests/node.js/node-tests.cfg 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,12 @@
+# This build config is supposed to be used for the units tests with "mode=build"
+
+[first]
+mockdom.js
+[last]
+node.js
+
+[include]
+
+[exclude]
+OpenLayers.js
+Firebug/firebug.js
Deleted: sandbox/tschaub/canvas/tests/node.js/node.js
===================================================================
--- trunk/openlayers/tests/node.js/node.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/node.js/node.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1 +0,0 @@
-exports.OpenLayers = OpenLayers;
Copied: sandbox/tschaub/canvas/tests/node.js/node.js (from rev 11552, trunk/openlayers/tests/node.js/node.js)
===================================================================
--- sandbox/tschaub/canvas/tests/node.js/node.js (rev 0)
+++ sandbox/tschaub/canvas/tests/node.js/node.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1 @@
+exports.OpenLayers = OpenLayers;
Deleted: sandbox/tschaub/canvas/tests/node.js/run-test.js
===================================================================
--- trunk/openlayers/tests/node.js/run-test.js 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/node.js/run-test.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,26 +0,0 @@
-// Requires:
-/// 0. nodejs
-// 1. jsdom installed (npm install jsdom)
-// 2. A build profile with mockdom.js included in [first], and node.js
-// inclded in [last], at ../../build/OpenLayers.js , like node-tests.js.
-// 3. Run with node run-tests.js
-//
-// Missing: integration with a solid node.js testrunner.
-var jsdom = require('jsdom');
-jsdom.env('<html><body></body></html>', function(errors, window) {
- for (var i in window) {
- if (i == "console") {
- continue;
- }
- eval(i+"=window['"+i+"'];");
- }
- OpenLayers = require("../../build/OpenLayers.js")['OpenLayers'];
- var map = new OpenLayers.Map(document.createElement("map"));
- map.addLayer(new OpenLayers.Layer("", {isBaseLayer:true}));
- map.setCenter(new OpenLayers.LonLat(-71,42), 10);
- var px = map.getPixelFromLonLat(map.getLonLatFromPixel(new OpenLayers.Pixel(100,100)));
- console.log(px);
- var px = map.getLonLatFromPixel(map.getPixelFromLonLat(new OpenLayers.LonLat(10,10)));
- console.log(px);
-
-});
Copied: sandbox/tschaub/canvas/tests/node.js/run-test.js (from rev 11552, trunk/openlayers/tests/node.js/run-test.js)
===================================================================
--- sandbox/tschaub/canvas/tests/node.js/run-test.js (rev 0)
+++ sandbox/tschaub/canvas/tests/node.js/run-test.js 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,26 @@
+// Requires:
+/// 0. nodejs
+// 1. jsdom installed (npm install jsdom)
+// 2. A build profile with mockdom.js included in [first], and node.js
+// inclded in [last], at ../../build/OpenLayers.js , like node-tests.js.
+// 3. Run with node run-tests.js
+//
+// Missing: integration with a solid node.js testrunner.
+var jsdom = require('jsdom');
+jsdom.env('<html><body></body></html>', function(errors, window) {
+ for (var i in window) {
+ if (i == "console") {
+ continue;
+ }
+ eval(i+"=window['"+i+"'];");
+ }
+ OpenLayers = require("../../build/OpenLayers.js")['OpenLayers'];
+ var map = new OpenLayers.Map(document.createElement("map"));
+ map.addLayer(new OpenLayers.Layer("", {isBaseLayer:true}));
+ map.setCenter(new OpenLayers.LonLat(-71,42), 10);
+ var px = map.getPixelFromLonLat(map.getLonLatFromPixel(new OpenLayers.Pixel(100,100)));
+ console.log(px);
+ var px = map.getLonLatFromPixel(map.getPixelFromLonLat(new OpenLayers.LonLat(10,10)));
+ console.log(px);
+
+});
Deleted: sandbox/tschaub/canvas/tests/node.js/run.sh
===================================================================
--- trunk/openlayers/tests/node.js/run.sh 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tests/node.js/run.sh 2011-02-27 10:37:39 UTC (rev 11553)
@@ -1,10 +0,0 @@
-#!/bin/sh
-cp mockdom.js node.js ../../lib
-cp node-tests.cfg ../../build
-cd ../../build
-python build.py -c none node-tests
-cd ../tests/node.js/
-
-node run-test.js
-rm ../../lib/mockdom.js
-rm ../../lib/node.js
Copied: sandbox/tschaub/canvas/tests/node.js/run.sh (from rev 11552, trunk/openlayers/tests/node.js/run.sh)
===================================================================
--- sandbox/tschaub/canvas/tests/node.js/run.sh (rev 0)
+++ sandbox/tschaub/canvas/tests/node.js/run.sh 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,10 @@
+#!/bin/sh
+cp mockdom.js node.js ../../lib
+cp node-tests.cfg ../../build
+cd ../../build
+python build.py -c none node-tests
+cd ../tests/node.js/
+
+node run-test.js
+rm ../../lib/mockdom.js
+rm ../../lib/node.js
Modified: sandbox/tschaub/canvas/theme/default/img/add_point_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/drag-rectangle-off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/drag-rectangle-on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_line_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_line_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_point_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_point_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_polygon_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/draw_polygon_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/editing_tool_bar.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/move_feature_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/move_feature_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/navigation_history.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/pan-panel-NOALPHA.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/pan-panel.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/pan_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/panning-hand-off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/panning-hand-on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/remove_point_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/save_features_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/save_features_on.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/view_next_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/view_previous_off.png
===================================================================
(Binary files differ)
Modified: sandbox/tschaub/canvas/theme/default/img/zoom-panel.png
===================================================================
(Binary files differ)
Property changes on: sandbox/tschaub/canvas/tools
___________________________________________________________________
Modified: svn:ignore
- *.pyc
+ *.pyc
closure-compiler.jar
Copied: sandbox/tschaub/canvas/tools/closure.py (from rev 11552, trunk/openlayers/tools/closure.py)
===================================================================
--- sandbox/tschaub/canvas/tools/closure.py (rev 0)
+++ sandbox/tschaub/canvas/tools/closure.py 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,21 @@
+import sys
+import os
+import tempfile
+
+path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar"))
+if not os.path.exists(path):
+ raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
+
+def minimize(code):
+ ntf = tempfile.NamedTemporaryFile()
+ ntf.write(code)
+ ntf.flush()
+
+ ntf2 = tempfile.NamedTemporaryFile()
+
+ os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
+ ntf2.seek(0)
+ data = ntf2.read()
+ ntf.close()
+ ntf2.close()
+ return data
Copied: sandbox/tschaub/canvas/tools/closure_ws.py (from rev 11552, trunk/openlayers/tools/closure_ws.py)
===================================================================
--- sandbox/tschaub/canvas/tools/closure_ws.py (rev 0)
+++ sandbox/tschaub/canvas/tools/closure_ws.py 2011-02-27 10:37:39 UTC (rev 11553)
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import httplib, urllib, sys
+import time
+# Define the parameters for the POST request and encode them in
+# a URL-safe format.
+
+def minimize(code):
+
+ params = urllib.urlencode([
+ ('js_code', code),
+ ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
+ ('output_format', 'text'),
+ ('output_info', 'compiled_code'),
+ ])
+
+ t = time.time()
+ # Always use the following value for the Content-type header.
+ headers = { "Content-type": "application/x-www-form-urlencoded" }
+ conn = httplib.HTTPConnection('closure-compiler.appspot.com')
+ conn.request('POST', '/compile', params, headers)
+ response = conn.getresponse()
+ data = response.read()
+ conn.close()
+ if data.startswith("Error"):
+ raise Exception(data)
+ print "%.3f seconds to compile" % (time.time() - t)
+ return data
Modified: sandbox/tschaub/canvas/tools/release.sh
===================================================================
--- sandbox/tschaub/canvas/tools/release.sh 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tools/release.sh 2011-02-27 10:37:39 UTC (rev 11553)
@@ -2,12 +2,23 @@
VERSION=$1
+wget -c http://closure-compiler.googlecode.com/files/compiler-latest.zip
+unzip compiler-latest.zip
+
svn export http://svn.openlayers.org/tags/openlayers/release-$VERSION OpenLayers-$VERSION
cd OpenLayers-$VERSION/build
-./build.py full
+mv ../../compiler.jar ../tools/closure-compiler.jar
+./build.py -c closure full
cp OpenLayers.js ..
+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
mkdir doc/devdocs
mkdir doc/apidocs
Modified: sandbox/tschaub/canvas/tools/update_dev_dir.sh
===================================================================
--- sandbox/tschaub/canvas/tools/update_dev_dir.sh 2011-02-27 00:52:09 UTC (rev 11552)
+++ sandbox/tschaub/canvas/tools/update_dev_dir.sh 2011-02-27 10:37:39 UTC (rev 11553)
@@ -18,11 +18,19 @@
cd /osgeo/openlayers/docs/dev/tools/
python exampleparser.py
cd /osgeo/openlayers/docs/dev/build
- ./build.py tests.cfg
+ ./build.py -c closure tests.cfg
+ ./build.py -c closure mobile.cfg OpenLayers.mobile.js
cp OpenLayers.js ..
+ cp OpenLayers.mobile.js ..
+
cd ..
-
+ for i in google ie6-style style; do
+ csstidy theme/default/$i.css --template=highest theme/default/$i.tidy.css
+ cp theme/default/$i.tidy.css theme/default/$i.css
+ done
+
+ sed -i -e 's!../lib/OpenLayers.js?mobile!../OpenLayers.mobile.js!' examples/*.html
sed -i -e 's!../lib/OpenLayers.js!../OpenLayers.js!' examples/*.html
naturaldocs -i /osgeo/openlayers/docs/dev/lib -o HTML /osgeo/openlayers/dev/apidocs -p /osgeo/openlayers/docs/dev/apidoc_config -s Default OL >/dev/null
naturaldocs -i /osgeo/openlayers/docs/dev/lib -o HTML /osgeo/openlayers/dev/docs -p /osgeo/openlayers/docs/dev/doc_config -s Default OL >/dev/null
More information about the Commits
mailing list