From cd9ee75a7348cb2d6a3950a7c089153ff389cc81 Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 21 Nov 2007 07:54:45 +0000 Subject: [PATCH] give the ve layer smooth (but safe) dragging. just like google layer. (Closes #1161) (See #1053) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5227 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- ...raggingGoogle.html => smoothDragging.html} | 19 ++++++++++-- lib/OpenLayers/Layer/VirtualEarth.js | 31 ++++++++++++++++++- 2 files changed, 46 insertions(+), 4 deletions(-) rename examples/{draggingGoogle.html => smoothDragging.html} (70%) diff --git a/examples/draggingGoogle.html b/examples/smoothDragging.html similarity index 70% rename from examples/draggingGoogle.html rename to examples/smoothDragging.html index c5b0c0f685..834d78a59f 100755 --- a/examples/draggingGoogle.html +++ b/examples/smoothDragging.html @@ -8,7 +8,8 @@ } - + + -

OpenLayers With Responsive Google Dragging

+

OpenLayers With Responsive Dragging

Uses Google Maps v2.82

diff --git a/lib/OpenLayers/Layer/VirtualEarth.js b/lib/OpenLayers/Layer/VirtualEarth.js index 8518d3c60a..e55bf4d5ba 100644 --- a/lib/OpenLayers/Layer/VirtualEarth.js +++ b/lib/OpenLayers/Layer/VirtualEarth.js @@ -103,10 +103,28 @@ OpenLayers.Layer.VirtualEarth = OpenLayers.Class( if (this.mapObject != null) { try { // this is to catch a Mozilla bug without falling apart - this.mapObject.LoadMap(null, null, this.type); + + // The fourth argument is whether the map is 'fixed' -- not + // draggable. See: + // http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx + // + this.mapObject.LoadMap(null, null, this.type, true); + this.mapObject.AttachEvent("onmousedown", function() {return true; }); + } catch (e) { } this.mapObject.HideDashboard(); } + + //can we do smooth panning? this is an unpublished method, so we need + // to be careful + if ( !this.mapObject || + !this.mapObject.vemapcontrol || + !this.mapObject.vemapcontrol.PanMap || + (typeof this.mapObject.vemapcontrol.PanMap != "function")) { + + this.dragPanMapObject = null; + } + }, /** @@ -169,6 +187,17 @@ OpenLayers.Layer.VirtualEarth = OpenLayers.Class( return this.mapObject.GetCenter(); }, + /** + * APIMethod: dragPanMapObject + * + * Parameters: + * dX - {Integer} + * dY - {Integer} + */ + dragPanMapObject: function(dX, dY) { + this.mapObject.vemapcontrol.PanMap(dX, -dY); + }, + /** * APIMethod: getMapObjectZoom *