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