1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3 * text of the license. */
4 // @require: OpenLayers/Layer.js
\r
6 // load VE map control script
\r
7 document.write("<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>");
\r
13 OpenLayers.Layer.VirtualEarth = Class.create();
\r
14 OpenLayers.Layer.VirtualEarth.prototype =
\r
15 Object.extend( new OpenLayers.Layer(), {
\r
17 /** @type Boolean */
\r
18 viewPortLayer: true,
\r
28 initialize:function(name) {
\r
29 OpenLayers.Layer.prototype.initialize.apply(this, arguments);
\r
33 * @param {OpenLayers.Map} map
\r
35 setMap:function(map) {
\r
36 OpenLayers.Layer.prototype.setMap.apply(this, arguments);
\r
38 // once our layer has been added to the map, we can create the vemap
\r
39 this.map.events.register("addlayer", this, this.loadVEMap);
\r
42 /** Virtual Earth layer is always a base class.
\r
45 isBaseLayer: function() {
\r
50 * @param {OpenLayers.Bounds} bounds
\r
51 * @param {int} zoomChanged
\r
53 moveTo:function(bounds,zoomChanged) {
\r
55 if (this.vemap != null) {
\r
56 var olCenter = this.map.getCenter();
\r
57 var olZoom = this.map.getZoom();
\r
59 this.vemap.SetCenterAndZoom(new VELatLong(olCenter.lat, olCenter.lon),
\r
68 loadVEMap:function() {
\r
69 // create div and set to same size as map
\r
70 var veDiv = OpenLayers.Util.createDiv(this.name);
\r
71 var sz = this.map.getSize();
\r
72 veDiv.style.width = sz.w;
\r
73 veDiv.style.height = sz.h;
\r
74 this.div.appendChild(veDiv);
\r
76 // create VEMap, hide nav controls
\r
77 this.vemap = new VEMap(this.name);
\r
78 this.vemap.LoadMap();
\r
79 this.vemap.HideDashboard();
\r
81 // catch pans and zooms from VE Map
\r
82 this.vemap.AttachEvent("onendcontinuouspan",
\r
83 this.catchPanZoom.bindAsEventListener(this));
\r
84 this.vemap.AttachEvent("onendzoom",
\r
85 this.catchPanZoom.bindAsEventListener(this));
\r
93 catchPanZoom: function(e) {
\r
94 var veCenter = this.vemap.GetCenter();
\r
95 var veZoom = this.vemap.GetZoomLevel();
\r
97 var olCenter = new OpenLayers.LonLat(veCenter.Longitude,
\r
100 this.map.setCenter(olCenter, veZoom - 1);
\r
105 /** @final @type String */
\r
106 CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
\r