From 9ca4ca2ceef92c0df1940ba53cd49cdd9ca10ff9 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 15 Jun 2006 12:09:21 +0000 Subject: [PATCH] Adding implementation of Microsoft Virtual Earth layer. git-svn-id: http://svn.openlayers.org/trunk/openlayers@587 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/VirtualEarth.js | 93 ++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 lib/OpenLayers/Layer/VirtualEarth.js diff --git a/lib/OpenLayers/Layer/VirtualEarth.js b/lib/OpenLayers/Layer/VirtualEarth.js new file mode 100644 index 0000000000..147b4569cc --- /dev/null +++ b/lib/OpenLayers/Layer/VirtualEarth.js @@ -0,0 +1,93 @@ +// load VE map control script +document.write(""); + + +/** + * @class + */ +OpenLayers.Layer.VirtualEarth = Class.create(); +OpenLayers.Layer.VirtualEarth.prototype = + Object.extend( new OpenLayers.Layer(), { + + /** @type Boolean */ + viewPortLayer: true, + + /** @type VEMap */ + vemap: null, + + /** + * @constructor + * + * @param {str} 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 create the vemap + this.map.events.register("addlayer", this, this.loadVEMap); + }, + + /** + * @param {OpenLayers.Bounds} bounds + * @param {int} zoomChanged + */ + moveTo:function(bounds,zoomChanged) { + + var olCenter = this.map.getCenter(); + var olZoom = this.map.getZoom(); + + this.vemap.SetCenterAndZoom(new VELatLong(olCenter.lat, olCenter.lon), + olZoom + 1); + }, + + + /** + * + */ + 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); + + // create VEMap, hide nav controls + this.vemap = new VEMap(this.name); + this.vemap.LoadMap(); + 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)); + + + }, + + /** + * @param {event} e + */ + catchPanZoom: function(e) { + var veCenter = this.vemap.GetCenter(); + var veZoom = this.vemap.GetZoomLevel(); + + var olCenter = new OpenLayers.LonLat(veCenter.Longitude, + veCenter.Latitude); + + this.map.setCenter(olCenter, veZoom - 1); + + }, + + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Layer.VirtualEarth" +}); \ No newline at end of file