[OpenLayers-Commits] r6035 - in sandbox/crschmidt/animated_panning: lib/OpenLayers tests
commits at openlayers.org
commits at openlayers.org
Thu Feb 7 16:42:11 EST 2008
Author: crschmidt
Date: 2008-02-07 16:42:11 -0500 (Thu, 07 Feb 2008)
New Revision: 6035
Modified:
sandbox/crschmidt/animated_panning/lib/OpenLayers/Map.js
sandbox/crschmidt/animated_panning/tests/test_Map.html
Log:
Minor modifications to the map.setCenter / map.moveTo rewrite. (See #962)
Modified: sandbox/crschmidt/animated_panning/lib/OpenLayers/Map.js
===================================================================
--- sandbox/crschmidt/animated_panning/lib/OpenLayers/Map.js 2008-02-07 21:07:19 UTC (rev 6034)
+++ sandbox/crschmidt/animated_panning/lib/OpenLayers/Map.js 2008-02-07 21:42:11 UTC (rev 6035)
@@ -1259,9 +1259,33 @@
*
* TBD: reconsider forceZoomChange in 3.0
*/
- setCenter: function (lonlat, zoom, dragging, forceZoomChange) {
- this.dragging = !!dragging;
-
+ setCenter: function(lonlat, zoom, dragging, forceZoomChange) {
+ this.moveTo(lonlat, zoom, {
+ 'dragging': dragging,
+ 'forceZoomChange': forceZoomChange,
+ 'source': 'setCenter'
+ });
+ },
+
+ /**
+ * Method: moveTo
+ *
+ * Parameters:
+ * lonlat - {<OpenLayers.LonLat>}
+ * zoom - {Integer}
+ * options - {Object}
+ */
+ moveTo: function(lonlat, zoom, options) {
+ if (!options) {
+ options = {};
+ }
+ // dragging is false by default
+ var dragging = options.dragging;
+ // forceZoomChange is false by default
+ var forceZoomChange = options.forceZoomChange;
+ // noEvent is false by default
+ var noEvent = options.noEvent;
+
if (!this.center && !this.isValidLonLat(lonlat)) {
lonlat = this.maxExtent.getCenterLonLat();
}
@@ -1311,7 +1335,9 @@
// if neither center nor zoom will change, no need to do anything
if (zoomChanged || centerChanged || !dragging) {
- if (!dragging) { this.events.triggerEvent("movestart"); }
+ if (!dragging && !noEvent) {
+ this.events.triggerEvent("movestart");
+ }
if (centerChanged) {
if ((!zoomChanged) && (this.center)) {
@@ -1377,7 +1403,9 @@
}
// even if nothing was done, we want to notify of this
- if (!dragging) { this.events.triggerEvent("moveend"); }
+ if (!dragging && !noEvent) {
+ this.events.triggerEvent("moveend");
+ }
},
/**
Modified: sandbox/crschmidt/animated_panning/tests/test_Map.html
===================================================================
--- sandbox/crschmidt/animated_panning/tests/test_Map.html 2008-02-07 21:07:19 UTC (rev 6034)
+++ sandbox/crschmidt/animated_panning/tests/test_Map.html 2008-02-07 21:42:11 UTC (rev 6035)
@@ -726,7 +726,7 @@
t.eq( ct, 3, "raiseLayer triggered changelayer the right # of times" );
}
- function test_15_Map_setCenter(t) {
+ function test_15_Map_moveTo(t) {
t.plan(1);
map = new OpenLayers.Map('map');
@@ -736,7 +736,7 @@
{maxResolution: 'auto', maxExtent: new OpenLayers.Bounds(-10,-10,10,10)});
map.addLayer(baseLayer);
var ll = new OpenLayers.LonLat(-100,-150);
- map.setCenter(ll, 0);
+ map.moveTo(ll, 0);
t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat");
}
More information about the Commits
mailing list