remove old dragging code from gmaps -- eventpane does all this for us

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1262 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-16 22:13:12 +00:00
parent e76f87e0df
commit 2f2dcf2f09

View File

@@ -46,12 +46,6 @@ OpenLayers.Layer.Google.prototype =
/** @type GMapType */ /** @type GMapType */
type: null, type: null,
/** @type Boolean */
dragging:false,
/** @type Boolean */
dontListen:false,
// OPTIONS // OPTIONS
/** @type int */ /** @type int */
@@ -103,29 +97,29 @@ OpenLayers.Layer.Google.prototype =
if ((this.gmap != null) && (!this.dragging)) { if ((this.gmap != null) && (!this.dragging)) {
var newCenter = this.map.getCenter(); var newOLCenter = this.map.getCenter();
var newZoom = this.map.getZoom(); var newOLZoom = this.map.getZoom();
if (newCenter != null) { if (newOLCenter != null) {
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
var currentCenter = this.getOLLonLatFromGLatLng(gCenter); var oldGCenter = this.gmap.getCenter();
var currentZoom = this.getOLZoomFromGZoom(gZoom); var oldOLCenter = this.getOLLonLatFromGLatLng(oldGCenter);
var oldGZoom = this.gmap.getZoom();
var oldOLZoom = this.getOLZoomFromGZoom(oldGZoom);
if ( (!newCenter.equals(currentCenter)) || if ( !(newOLCenter.equals(oldOLCenter)) ||
(newZoom != currentZoom) ) { !(newOLZoom == oldOLZoom) ) {
this.dontListen = true; var newGCenter = this.getGLatLngFromOLLonLat(newOLCenter);
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter), var newGZoom = this.getGZoomFromOLZoom(newOLZoom);
this.getGZoomFromOLZoom(newZoom));
this.gmap.setCenter(newGCenter, newGZoom);
if (this.type != null) { if (this.type != null) {
this.gmap.setMapType(this.type); this.gmap.setMapType(this.type);
this.type = null; this.type = null;
} }
this.dontListen = false;
} }
} }
} }
@@ -142,33 +136,12 @@ OpenLayers.Layer.Google.prototype =
//has gmaps library has been loaded? //has gmaps library has been loaded?
try { try {
// create GMap, hide nav controls // create GMap, hide nav controls
this.gmap = new GMap2(this.div ); this.gmap = new GMap2( this.div );
this.gmap.disableDragging();
// this causes the GMap to set itself to Map's center/zoom // this causes the GMap to set itself to Map's center/zoom
this.moveTo(); this.moveTo();
// catch pans and zooms from GMap
GEvent.addListener(this.gmap,
"moveend",
this.catchPanZoom.bindAsEventListener(this));
// attach to the drag start and end and we<77>ll set a flag so that
// we dont get recursivity. this is because when we call setCenter(),
// it calls moveTo() on all layers
GEvent.addListener(this.gmap,
"dragstart",
this.dragStart.bindAsEventListener(this));
GEvent.addListener(this.gmap,
"dragend",
this.dragEnd.bindAsEventListener(this));
// catch pans and zooms from GMap
GEvent.addListener(this.gmap,
"drag",
this.catchPanZoom.bindAsEventListener(this));
} catch (e) { } catch (e) {
this.loadWarningMessage(); this.loadWarningMessage();
} }
@@ -225,41 +198,7 @@ OpenLayers.Layer.Google.prototype =
this.div.appendChild(div); this.div.appendChild(div);
}, },
/**
* @private
*/
dragStart: function() {
this.dragging = true;
},
/**
* @private
*/
dragEnd: function() {
this.dragging = false;
},
/** When GMap recenters itself (when user doubleclicks or draggs it) we
* need to update our Map -- and all the other layers
*
* @private
*
* @param {Event} e
*/
catchPanZoom: function(e) {
if (!this.dontListen) {
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
var olZoom = this.getOLZoomFromGZoom(gZoom);
this.map.setCenter(olCenter, olZoom, this.dragging);
}
},
/********************************************************/ /********************************************************/
/* */ /* */