altered VirtualEarth to subclass EventPane.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1207 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,81 +1,70 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
// @require: OpenLayers/Layer/EventPane.js
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
*/
|
||||
OpenLayers.Layer.VirtualEarth = Class.create();
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
Object.extend( new OpenLayers.Layer(), {
|
||||
|
||||
/** Virtual Earth layer is always a base layer.
|
||||
*/
|
||||
OpenLayers.Layer.VirtualEarth = Class.create();
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
Object.extend( new OpenLayers.Layer.EventPane(), {
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @type Boolean
|
||||
* @param {String} name
|
||||
*/
|
||||
isBaseLayer: true,
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** @type Boolean */
|
||||
isFixed: true,
|
||||
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load the vemap
|
||||
this.loadVEMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap:function(map) {
|
||||
OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments);
|
||||
|
||||
// once our layer has been added to the map, we can load the vemap
|
||||
this.loadVEMap();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
* @param {Boolean} zoomChanged
|
||||
* @param {Boolean} minor
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
|
||||
if (this.vemap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
var olZoom = this.map.getZoom();
|
||||
|
||||
if (this.vemap != null) {
|
||||
var olCenter = this.map.getCenter();
|
||||
var olZoom = this.map.getZoom();
|
||||
|
||||
var veCenter = this.getVELatLongFromOLLonLat(olCenter);
|
||||
var veZoom = this.getVEZoomFromOLZoom(olZoom);
|
||||
|
||||
this.vemap.SetCenterAndZoom(veCenter, veZoom);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadVEMap:function() {
|
||||
// create div and set to same size as map
|
||||
var veDiv = OpenLayers.Util.createDiv(this.name);
|
||||
var sz = this.map.getSize();
|
||||
veDiv.style.width = sz.w;
|
||||
veDiv.style.height = sz.h;
|
||||
this.div.appendChild(veDiv);
|
||||
|
||||
|
||||
this.vemap.SetCenterAndZoom(veCenter, veZoom);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadVEMap:function() {
|
||||
// create div and set to same size as map
|
||||
var veDiv = OpenLayers.Util.createDiv(this.name);
|
||||
var sz = this.map.getSize();
|
||||
veDiv.style.width = sz.w;
|
||||
veDiv.style.height = sz.h;
|
||||
this.div.appendChild(veDiv);
|
||||
|
||||
try {
|
||||
|
||||
// create VEMap, hide nav controls
|
||||
this.vemap = new VEMap(this.name);
|
||||
// create VEMap, hide nav controls
|
||||
this.vemap = new VEMap(this.name);
|
||||
} catch (e) {
|
||||
// do nothing this is to keep from crashing
|
||||
// if the VE library was not loaded.
|
||||
@@ -96,14 +85,14 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
this.vemap.HideDashboard();
|
||||
|
||||
// catch pans and zooms from VE Map
|
||||
this.vemap.AttachEvent("onendcontinuouspan",
|
||||
this.catchPanZoom.bindAsEventListener(this));
|
||||
this.vemap.AttachEvent("onendzoom",
|
||||
this.catchPanZoom.bindAsEventListener(this));
|
||||
//this.vemap.AttachEvent("onendcontinuouspan",
|
||||
// this.catchPanZoom.bindAsEventListener(this));
|
||||
//this.vemap.AttachEvent("onendzoom",
|
||||
// this.catchPanZoom.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
/** If we can't load the vemap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
@@ -154,19 +143,19 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
this.div.appendChild(div);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} e
|
||||
*/
|
||||
/**
|
||||
* @param {Event} e
|
||||
*/
|
||||
catchPanZoom: function(e) {
|
||||
|
||||
var veCenter = this.vemap.GetCenter();
|
||||
var veZoom = this.vemap.GetZoomLevel();
|
||||
|
||||
|
||||
var veCenter = this.vemap.GetCenter();
|
||||
var veZoom = this.vemap.GetZoomLevel();
|
||||
|
||||
var olCenter = this.getOLLonLatFromVELatLong(veCenter);
|
||||
var olZoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
|
||||
this.map.setCenter(olCenter, olZoom);
|
||||
},
|
||||
this.map.setCenter(olCenter, olZoom);
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -392,8 +381,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
return veLatLongBounds;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
|
||||
});
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user