[OpenLayers-Commits] r11375 - in sandbox/ahocevar/layercontainer: .
examples lib/OpenLayers lib/OpenLayers/Control
lib/OpenLayers/Handler tests tests/BaseTypes tests/Control
tests/Handler tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Feb 23 17:52:52 EST 2011
Author: ahocevar
Date: 2011-02-23 14:52:52 -0800 (Wed, 23 Feb 2011)
New Revision: 11375
Modified:
sandbox/ahocevar/layercontainer/
sandbox/ahocevar/layercontainer/examples/controls.html
sandbox/ahocevar/layercontainer/examples/geolocation.html
sandbox/ahocevar/layercontainer/examples/geolocation.js
sandbox/ahocevar/layercontainer/examples/mobile-navigation.html
sandbox/ahocevar/layercontainer/examples/style.css
sandbox/ahocevar/layercontainer/lib/OpenLayers/BaseTypes.js
sandbox/ahocevar/layercontainer/lib/OpenLayers/Control/Geolocate.js
sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Drag.js
sandbox/ahocevar/layercontainer/lib/OpenLayers/Kinetic.js
sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js
sandbox/ahocevar/layercontainer/tests/BaseTypes/Bounds.html
sandbox/ahocevar/layercontainer/tests/BaseTypes/LonLat.html
sandbox/ahocevar/layercontainer/tests/BaseTypes/Pixel.html
sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html
sandbox/ahocevar/layercontainer/tests/Control/PanZoom.html
sandbox/ahocevar/layercontainer/tests/Control/Scale.html
sandbox/ahocevar/layercontainer/tests/Handler/Drag.html
sandbox/ahocevar/layercontainer/tests/Layer/EventPane.html
sandbox/ahocevar/layercontainer/tests/Map.html
sandbox/ahocevar/layercontainer/tests/run-tests.html
Log:
merging from trunk
Property changes on: sandbox/ahocevar/layercontainer
___________________________________________________________________
Modified: svn:mergeinfo
- /sandbox/roberthl/openlayers:9745-9748
+ /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11266-11374
Modified: sandbox/ahocevar/layercontainer/examples/controls.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/controls.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/examples/controls.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -64,8 +64,8 @@
Attach zooming, panning, layer switcher, overview map, and permalink map controls to an OpenLayers window.
</p>
- <a style="float:right" href="" id="permalink">Permalink</a>
<div id="map" class="smallmap"></div>
+ <a href="#" id="permalink">Permalink</a>
<div id="docs"></div>
</body>
Modified: sandbox/ahocevar/layercontainer/examples/geolocation.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/geolocation.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/examples/geolocation.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -13,7 +13,7 @@
}
</style>
</head>
- <body onload="init()">
+ <body>
<h1 id="title">Geolocation Example</h1>
<div id="tags">
Modified: sandbox/ahocevar/layercontainer/examples/geolocation.js
===================================================================
--- sandbox/ahocevar/layercontainer/examples/geolocation.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/examples/geolocation.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -1,8 +1,7 @@
var style = {
+ fillColor: '#000',
fillOpacity: 0.1,
- fillColor: '#000',
- strokeColor: '#f00',
- strokeOpacity: 0.6
+ strokeWidth: 0
}
var map = new OpenLayers.Map('map');
@@ -17,6 +16,34 @@
), 12
);
+var pulsate = function(feature) {
+ var point = feature.geometry.getCentroid(),
+ bounds = feature.geometry.getBounds(),
+ radius = Math.abs((bounds.right - bounds.left)/2),
+ count = 0,
+ grow = 'up';
+
+ var resize = function(){
+ if (count>16) clearInterval(window.resizeInterval);
+ var interval = radius * 0.03;
+ var ratio = interval/radius;
+ switch(count) {
+ case 4:
+ case 12:
+ grow = 'down'; break;
+ case 8:
+ grow = 'up'; break;
+ }
+ if (grow!=='up') {
+ ratio = - Math.abs(ratio);
+ }
+ feature.geometry.resize(1+ratio, point);
+ vector.drawFeature(feature);
+ count++;
+ }
+ window.resizeInterval = window.setInterval(resize, 50, point, radius);
+};
+
var geolocate = new OpenLayers.Control.Geolocate({
geolocationOptions: {
enableHighAccuracy: false,
@@ -27,6 +54,16 @@
map.addControl(geolocate);
geolocate.events.register("locationupdated",this,function(e) {
vector.removeAllFeatures();
+ var circle = new OpenLayers.Feature.Vector(
+ OpenLayers.Geometry.Polygon.createRegularPolygon(
+ new OpenLayers.Geometry.Point(e.point.x, e.point.y),
+ e.position.coords.accuracy/2,
+ 40,
+ 0
+ ),
+ {},
+ style
+ );
vector.addFeatures([
new OpenLayers.Feature.Vector(
e.point,
@@ -39,34 +76,28 @@
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
- )
+ circle
]);
map.zoomToExtent(vector.getDataExtent());
+ pulsate(circle);
});
geolocate.events.register("locationfailed",this,function() {
OpenLayers.Console.log('Location detection failed');
});
$('locate').onclick = function() {
+ vector.removeAllFeatures();
geolocate.deactivate();
$('track').checked = false;
geolocate.watch = false;
geolocate.activate();
};
$('track').onclick = function() {
+ vector.removeAllFeatures();
geolocate.deactivate();
if (this.checked) {
geolocate.watch = true;
geolocate.activate();
}
};
-$('track').checked = false;
\ No newline at end of file
+$('track').checked = false;
Modified: sandbox/ahocevar/layercontainer/examples/mobile-navigation.html
===================================================================
--- sandbox/ahocevar/layercontainer/examples/mobile-navigation.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/examples/mobile-navigation.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
- <title>OpenLayers TouchNavigation Control</title>
+ <title>Mobile Navigation Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="style.mobile.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
Modified: sandbox/ahocevar/layercontainer/examples/style.css
===================================================================
--- sandbox/ahocevar/layercontainer/examples/style.css 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/examples/style.css 2011-02-23 22:52:52 UTC (rev 11375)
@@ -121,3 +121,19 @@
display : none;
}
}
+ at media only screen and (orientation: landscape) and (max-width: 600px) {
+ #shortdesc {
+ float: right;
+ width: 25%;
+ }
+ #map {
+ width: 70%;
+ }
+ #docs {
+ font-size: 12px;
+ }
+}
+body {
+ -webkit-text-size-adjust: none;
+}
+
Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/BaseTypes.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/BaseTypes.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -632,9 +632,11 @@
* APIMethod: parse
* Generate a date object from a string. The format for the string follows
* the profile of ISO 8601 for date and time on the Internet (see
- * http://tools.ietf.org/html/rfc3339). If the parse method on
- * the Date constructor returns a valid date for the given string,
- * that method is used.
+ * http://tools.ietf.org/html/rfc3339). We don't call the native
+ * Date.parse because of inconsistency between implmentations. In
+ * Chrome, calling Date.parse with a string that doesn't contain any
+ * indication of the timezone (e.g. "2011"), the date is interpreted
+ * in local time. On Firefox, the assumption is UTC.
*
* Parameters:
* str - {String} A string representing the date (e.g.
@@ -647,37 +649,31 @@
*/
parse: function(str) {
var date;
- // first check if the native parse method can parse it
- var elapsed = Date.parse(str);
- if (!isNaN(elapsed)) {
- date = new Date(elapsed);
- } else {
- var match = str.match(/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))?$/);
- if (match && (match[1] || match[7])) { // must have at least year or time
- var year = parseInt(match[1], 10) || 0;
- var month = (parseInt(match[2], 10) - 1) || 0;
- var day = parseInt(match[3], 10) || 1;
- date = new Date(Date.UTC(year, month, day));
- // optional time
- var type = match[7];
- if (type) {
- var hours = parseInt(match[4], 10);
- var minutes = parseInt(match[5], 10);
- var secFrac = parseFloat(match[6]);
- var seconds = secFrac | 0;
- var milliseconds = Math.round(1000 * (secFrac - seconds));
- date.setUTCHours(hours, minutes, seconds, milliseconds);
- // check offset
- if (type !== "Z") {
- var hoursOffset = parseInt(type, 10);
- var minutesOffset = parseInt(match[8], 10) || 0;
- var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);
- date = new Date(date.getTime() + offset);
- }
+ var match = str.match(/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))?$/);
+ if (match && (match[1] || match[7])) { // must have at least year or time
+ var year = parseInt(match[1], 10) || 0;
+ var month = (parseInt(match[2], 10) - 1) || 0;
+ var day = parseInt(match[3], 10) || 1;
+ date = new Date(Date.UTC(year, month, day));
+ // optional time
+ var type = match[7];
+ if (type) {
+ var hours = parseInt(match[4], 10);
+ var minutes = parseInt(match[5], 10);
+ var secFrac = parseFloat(match[6]);
+ var seconds = secFrac | 0;
+ var milliseconds = Math.round(1000 * (secFrac - seconds));
+ date.setUTCHours(hours, minutes, seconds, milliseconds);
+ // check offset
+ if (type !== "Z") {
+ var hoursOffset = parseInt(type, 10);
+ var minutesOffset = parseInt(match[8], 10) || 0;
+ var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);
+ date = new Date(date.getTime() + offset);
}
- } else {
- date = new Date("invalid");
}
+ } else {
+ date = new Date("invalid");
}
return date;
}
Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Control/Geolocate.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Control/Geolocate.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Control/Geolocate.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -85,7 +85,7 @@
this.events.triggerEvent("locationuncapable");
return false;
}
- if (!this.active) {
+ if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
if (this.watch) {
this.watchId = this.geolocation.watchPosition(
OpenLayers.Function.bind(this.geolocate, this),
@@ -93,16 +93,11 @@
this.geolocationOptions
);
} else {
- this.geolocation.getCurrentPosition(
- OpenLayers.Function.bind(this.geolocate, this),
- OpenLayers.Function.bind(this.failure, this),
- this.geolocationOptions
- );
+ this.getCurrentLocation();
}
+ return true;
}
- return OpenLayers.Control.prototype.activate.apply(
- this, arguments
- );
+ return false;
},
/**
@@ -146,6 +141,25 @@
},
/**
+ * APIMethod: getCurrentLocation
+ *
+ * Returns:
+ * {Boolean} Returns true if a event will be fired (successfull
+ * registration)
+ */
+ getCurrentLocation: function() {
+ if (!this.active || this.watch) {
+ return false;
+ }
+ this.geolocation.getCurrentPosition(
+ OpenLayers.Function.bind(this.geolocate, this),
+ OpenLayers.Function.bind(this.failure, this),
+ this.geolocationOptions
+ );
+ return true;
+ },
+
+ /**
* Method: failure
* method called on browser's geolocation failure
*
Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Drag.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Drag.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Handler/Drag.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -156,9 +156,7 @@
this.down(evt);
this.callback("down", [evt.xy]);
- if (evt.type === "mousedown") {
- OpenLayers.Event.stop(evt);
- }
+ OpenLayers.Event.stop(evt);
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart ?
@@ -204,9 +202,7 @@
this.interval);
}
this.dragging = true;
- if (evt.type === "touchmove") {
- OpenLayers.Event.stop(evt);
- }
+
this.move(evt);
this.callback("move", [evt.xy]);
if(!this.oldOnselectstart) {
Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Kinetic.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Kinetic.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Kinetic.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -63,7 +63,6 @@
/**
* Method: begin
- *
* Begins the dragging.
*/
begin: function() {
@@ -74,8 +73,10 @@
/**
* Method: update
+ * Updates during the dragging.
*
- * Updates during the dragging.
+ * Parameters:
+ * xy - {<OpenLayers.Pixel>} The new position.
*/
update: function(xy) {
this.points.unshift({xy: xy, tick: new Date().getTime()});
@@ -86,8 +87,15 @@
/**
* Method: end
+ * Ends the dragging, start the kinetic.
*
- * Ends the dragging, start the kinetic.
+ * Parameters:
+ * xy - {<OpenLayers.Pixel>} The last position.
+ *
+ * Returns:
+ * {Object} An object with two properties: "speed", and "theta". The
+ * "speed" and "theta" values are to be passed to the move
+ * function when starting the animation.
*/
end: function(xy) {
var last, now = new Date().getTime();
@@ -117,12 +125,13 @@
/**
* Method: move
- *
* Launch the kinetic move pan.
*
* Parameters:
- * info - {Object}
- * callback - arguments x, y (values to pan), end (is the last point)
+ * info - {Object} An object with two properties, "speed", and "theta".
+ * These values are those returned from the "end" call.
+ * callback - {Function} Function called on every step of the animation,
+ * receives x, y (values to pan), end (is the last point).
*/
move: function(info, callback) {
var v0 = info.speed;
Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js 2011-02-23 22:52:52 UTC (rev 11375)
@@ -506,18 +506,27 @@
this.viewPortDiv.className = "olMapViewport";
this.div.appendChild(this.viewPortDiv);
+ // the eventsDiv is where we listen for all map events
+ var eventsDiv = document.createElement("div");
+ eventsDiv.id = this.id + "_events";
+ eventsDiv.style.position = "absolute";
+ eventsDiv.style.width = "100%";
+ eventsDiv.style.height = "100%";
+ eventsDiv.style.zIndex = this.Z_INDEX_BASE.Control - 1;
+ this.viewPortDiv.appendChild(eventsDiv);
+ this.eventsDiv = eventsDiv;
+ this.events = new OpenLayers.Events(
+ this, this.eventsDiv, this.EVENT_TYPES, this.fallThrough,
+ {includeXY: true}
+ );
+
// the layerContainerDiv is the one that holds all the layers
id = this.id + "_OpenLayers_Container";
this.layerContainerDiv = OpenLayers.Util.createDiv(id);
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
- this.viewPortDiv.appendChild(this.layerContainerDiv);
+ this.eventsDiv.appendChild(this.layerContainerDiv);
- this.events = new OpenLayers.Events(this,
- this.viewPortDiv,
- this.EVENT_TYPES,
- this.fallThrough,
- {includeXY: true});
this.updateSize();
if(this.eventListeners instanceof Object) {
this.events.on(this.eventListeners);
Modified: sandbox/ahocevar/layercontainer/tests/BaseTypes/Bounds.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/BaseTypes/Bounds.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/BaseTypes/Bounds.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -606,6 +606,7 @@
t.ok( bounds.equals(b), "bounds is set correctly");
//null values
+ OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both x and y values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
Modified: sandbox/ahocevar/layercontainer/tests/BaseTypes/LonLat.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/BaseTypes/LonLat.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/BaseTypes/LonLat.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -64,6 +64,7 @@
t.ok( addpx.equals(ll), "addpx is set correctly");
//null values
+ OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both lon and lat values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
Modified: sandbox/ahocevar/layercontainer/tests/BaseTypes/Pixel.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/BaseTypes/Pixel.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/BaseTypes/Pixel.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -74,6 +74,7 @@
t.ok( pixel.equals(px), "returned pixel is correct");
//null values
+ OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both x and y values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
Modified: sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Control/Geolocate.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -62,6 +62,31 @@
map.removeControl(control);
map.setCenter(centerLL);
}
+ function test_getCurrentLocation(t) {
+ t.plan(5);
+ var control = new OpenLayers.Control.Geolocate({
+ geolocation: geolocation
+ });
+ map.addControl(control);
+ t.eq(control.getCurrentLocation(), false, 'getCurrentLocation return false if control hasnt been activated');
+ control.activate();
+ map.setCenter(centerLL);
+ t.eq(control.getCurrentLocation(), true, 'getCurrentLocation return true if control has been activated');
+ var center = map.getCenter();
+ t.eq(center.lon, 10, 'bound control sets the map lon when calling getCurrentLocation');
+ t.eq(center.lat, 10, 'bound control sets the map lat when calling getCurrentLocation');
+ control.deactivate();
+ map.removeControl(control);
+ map.setCenter(centerLL);
+ var control2 = new OpenLayers.Control.Geolocate({
+ geolocation: geolocation
+ });
+ map.addControl(control2);
+ t.eq(control2.getCurrentLocation(), false, 'getCurrentLocation return false if control is in watch mode');
+ control2.deactivate();
+ map.removeControl(control2);
+ map.setCenter(centerLL);
+ }
function test_watch(t) {
t.plan(2);
var control = new OpenLayers.Control.Geolocate({
Modified: sandbox/ahocevar/layercontainer/tests/Control/PanZoom.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Control/PanZoom.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Control/PanZoom.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -72,65 +72,65 @@
simulateClick(wnd, wnd.control.buttons[0]);
t.delay_call(2, function() {
- t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "1) Pan up works correctly" );
+ t.ok(!flag.mousedown, "1) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "1) mouseup does not get to the map");
+ t.ok(!flag.click, "1) click does not get to the map");
+ t.ok(!flag.dblclick, "1) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[1]);
}, 2, function() {
- t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "2) Pan left works correctly" );
+ t.ok(!flag.mousedown, "2) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "2) mouseup does not get to the map");
+ t.ok(!flag.click, "2) click does not get to the map");
+ t.ok(!flag.dblclick, "2) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[2]);
}, 2, function() {
- t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "3) Pan right works correctly" );
+ t.ok(!flag.mousedown, "3) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "3) mouseup does not get to the map");
+ t.ok(!flag.click, "3) click does not get to the map");
+ t.ok(!flag.dblclick, "3) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[3]);
}, 2, function() {
- t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "4) Pan down works correctly" );
+ t.ok(!flag.mousedown, "4) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "4) mouseup does not get to the map");
+ t.ok(!flag.click, "4) click does not get to the map");
+ t.ok(!flag.dblclick, "4) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[4]);
}, 2, function() {
- t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.eq( wnd.mapper.getZoom(), 6, "5) zoomin works correctly" );
+ t.ok(!flag.mousedown, "5) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "5) mouseup does not get to the map");
+ t.ok(!flag.click, "5) click does not get to the map");
+ t.ok(!flag.dblclick, "5) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[6]);
}, 2, function() {
- t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.eq( wnd.mapper.getZoom(), 5, "6) zoomout works correctly" );
+ t.ok(!flag.mousedown, "6) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "6) mouseup does not get to the map");
+ t.ok(!flag.click, "6) click does not get to the map");
+ t.ok(!flag.dblclick, "6) dblclick does not get to the map");
resetFlags();
simulateClick(wnd, wnd.control.buttons[5]);
}, 2, function() {
- t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" );
- t.ok(!flag.mousedown, "mousedown does not get to the map");
- t.ok(flag.mouseup, "mouseup does get to the map");
- t.ok(!flag.click, "click does not get to the map");
- t.ok(!flag.dblclick, "dblclick does not get to the map");
+ t.eq( wnd.mapper.getZoom(), 2, "7) zoomworld works correctly" );
+ t.ok(!flag.mousedown, "7) mousedown does not get to the map");
+ t.ok(!flag.mouseup, "7) mouseup does not get to the map");
+ t.ok(!flag.click, "7) click does not get to the map");
+ t.ok(!flag.dblclick, "7) dblclick does not get to the map");
resetFlags();
});
});
Modified: sandbox/ahocevar/layercontainer/tests/Control/Scale.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Control/Scale.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Control/Scale.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -2,6 +2,7 @@
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
+ OpenLayers.Lang.setCode('en');
var map;
function test_Control_Scale_constructor (t) {
t.plan( 2 );
Modified: sandbox/ahocevar/layercontainer/tests/Handler/Drag.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Handler/Drag.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Handler/Drag.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -294,7 +294,7 @@
// "touchend" events set expected states in the drag handler.
// We also verify that we stop event bubbling as appropriate.
- t.plan(12);
+ t.plan(14);
// set up
@@ -302,37 +302,44 @@
var c = new OpenLayers.Control();
m.addControl(c);
var h = new OpenLayers.Handler.Drag(c, {
- done: function(px) { log = px; }});
+ done: function(px) {
+ log.push(px);
+ }
+ });
h.activate();
var _stop = OpenLayers.Event.stop;
- OpenLayers.Event.stop = function(e) { log = e; };
+ OpenLayers.Event.stop = function(e) {
+ log.push(e);
+ };
- var Px = OpenLayers.Pixel, e, log;
+ var Px = OpenLayers.Pixel, e;
+ var log = [];
// test
-
e = {touches: [{}], xy: new Px(0, 0)};
m.events.triggerEvent('touchstart', e);
t.eq(h.started, true, '[touchstart] started is set');
t.eq(h.start.x, 0, '[touchstart] start.x is correct');
t.eq(h.start.y, 0, '[touchstart] start.y is correct');
- t.eq(log, undefined, '[touchstart] event is not stopped');
+ t.eq(log.length, 1, '[touchstart] one item in log');
+ t.ok(log[0] === e, "touchstart", '[touchstart] event is stopped');
e = {xy: new Px(1, 1)};
m.events.triggerEvent('touchmove', e);
t.eq(h.dragging, true, '[touchmove] dragging is set');
- t.eq(h.last.x, 1, '[touchstart] last.x is correct');
- t.eq(h.last.y, 1, '[touchstart] last.y is correct');
- t.ok(log == e, '[touchmove] event is stopped');
+ t.eq(h.last.x, 1, '[touchmove] last.x is correct');
+ t.eq(h.last.y, 1, '[touchmove] last.y is correct');
+ t.eq(log.length, 1, '[touchmove] one item in log (event is not stopped)');
e = {xy: new Px(2, 2)};
m.events.triggerEvent('touchend', e);
t.eq(h.started, false, '[touchend] started is reset');
t.eq(h.started, false, '[touchend] started is reset');
// the "done" callback gets the position of the last touchmove
- t.eq(log.x, 1, '[touchend] done callback got correct x position');
- t.eq(log.y, 1, '[touchend] done callback got correct y position');
+ t.eq(log.length, 2, '[touchend] two items in log');
+ t.ok(log[1] instanceof Px, '[touchend] got');
+ t.ok(log[1].equals(e.xy), '[touchend] done callback got correct position');
// tear down
Modified: sandbox/ahocevar/layercontainer/tests/Layer/EventPane.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Layer/EventPane.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Layer/EventPane.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -58,11 +58,11 @@
// t.plan( 2 );
if (OpenLayers.BROWSER_NAME != "firefox" && OpenLayers.BROWSER_NAME != "mozilla") {
- t.plan(4);
+ t.plan(4);
} else {
- t.plan(0);
- t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.")
- return;
+ t.plan(0);
+ t.debug_print("Firefox gives different results for different browsers on setMap on EventPane, so just don't run it for now.")
+ return;
}
var map = new OpenLayers.Map('map');
@@ -84,19 +84,23 @@
layer2.getWarningHTML = function() { this.warning = true; return ""; }
map.addLayer(layer2);
- t.ok( !layer2.warning, "warning not registered on mapObject load" );
+ t.ok(!layer2.warning, "warning not registered on mapObject load");
- map.events.register("mousemove", map, function () {
- t.ok(true, "got mouse move");
+ var log = [];
+ map.events.register("mousemove", map, function(event) {
+ log.push(event);
});
- if( document.createEvent ) { // Mozilla
- var evObj = document.createEvent('MouseEvents');
- evObj.initEvent( 'mousemove', true, false );
- layer.pane.dispatchEvent(evObj);
- } else if( document.createEventObject ) { // IE
- layer.pane.fireEvent('onmousemove');
+ if (document.createEvent) { // Mozilla
+ var evObj = document.createEvent('MouseEvents');
+ evObj.initEvent('mousemove', true, false);
+ map.eventsDiv.dispatchEvent(evObj);
+ } else if(document.createEventObject) { // IE
+ map.eventsDiv.fireEvent('onmousemove');
}
+
+ t.eq(log.length, 1, "got one event");
+
}
function test_Layer_EventPane_setVisibility (t) {
Modified: sandbox/ahocevar/layercontainer/tests/Map.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/Map.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/Map.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -1664,7 +1664,26 @@
map.destroy();
}
+ function test_pixel_lonlat(t) {
+
+ t.plan(4);
+ var map = new OpenLayers.Map({
+ div: "map",
+ layers: [
+ new OpenLayers.Layer("name", {isBaseLayer:true})
+ ]
+ });
+ map.zoomToMaxExtent();
+ var px = map.getPixelFromLonLat(map.getLonLatFromPixel(new OpenLayers.Pixel(100, 100)));
+ t.eq(px.x, 100, "x is the same in and ot");
+ t.eq(px.y, 100, "y is the same in and out");
+ var ll = map.getLonLatFromPixel(map.getPixelFromLonLat(new OpenLayers.LonLat(100, 100)));
+ t.ok((ll.lon > (100 -map.getResolution()) && (ll.lon < (100 + map.getResolution()))), "lon is the same in and ot");
+ t.ok((ll.lat > (100 -map.getResolution()) && (ll.lat < (100 + map.getResolution()))), "lat is the same in and ot");
+ map.destroy();
+ }
+
</script>
</head>
<body>
Modified: sandbox/ahocevar/layercontainer/tests/run-tests.html
===================================================================
--- sandbox/ahocevar/layercontainer/tests/run-tests.html 2011-02-23 22:24:35 UTC (rev 11374)
+++ sandbox/ahocevar/layercontainer/tests/run-tests.html 2011-02-23 22:52:52 UTC (rev 11375)
@@ -686,7 +686,7 @@
timeout_seconds=4;
}
var no_close=document.getElementById( "dont_close_test_windows" );
- var action={ action_kind: "window", wnd_url: url.toString(), wnd_wnd: null, wnd_fn: fn, wnd_timeout_milliseconds: timeout_seconds*1000, wnd_no_close: no_close.checked };
+ var action={ action_kind: "window", wnd_url: url.toString() + (window.location.search || ""), wnd_wnd: null, wnd_fn: fn, wnd_timeout_milliseconds: timeout_seconds*1000, wnd_no_close: no_close.checked };
this.delay_total_milliseconds_left+=Test.AnotherWay._action_estimate_milliseconds( action );
this.delay_actions.push( action );
}
@@ -2410,4 +2410,10 @@
</div>
</span>
+<script>
+ if (/noscroll/.test(location.href)) {
+ document.getElementById('scroller').style.height='auto';
+ document.getElementById('right_frame').style.height='auto';
+ }
+</script>
</body></html>
More information about the Commits
mailing list