The OpenLayers server threw a disk, and clobbered another, resulting in a loss
of data up to our last backup. In the previous subversion repository, this was r1694->r1777. I'm sorry to all those of you who might have checked out that code, as this will surely cause problems for you. We're currently working to figure out what went wrong, and how to prevent it in the future. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1695 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -3,82 +3,46 @@
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer/EventPane.js
|
||||
* @requires OpenLayers/Layer/FixedZoomLevels.js
|
||||
*/
|
||||
OpenLayers.Layer.VirtualEarth = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
OpenLayers.Layer.VirtualEarth.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.EventPane,
|
||||
OpenLayers.Layer.FixedZoomLevels, {
|
||||
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 1,
|
||||
/** @final @type int */
|
||||
MIN_ZOOM_LEVEL: 1,
|
||||
|
||||
/** @final @type int */
|
||||
MAX_ZOOM_LEVEL: 17,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/**
|
||||
/** Hardcode these resolutions so that they are more closely
|
||||
* tied with the standard wms projection
|
||||
*
|
||||
* @final @type Array(float) */
|
||||
RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],
|
||||
|
||||
/** @type VEMapType */
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
initialize:function(name) {
|
||||
initialize: function(name, options) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
|
||||
arguments);
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @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} dragging
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
|
||||
|
||||
if (this.vemap != null) {
|
||||
|
||||
if (this.type != null) {
|
||||
this.vemap.SetMapStyle(this.type);
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
var olCenter = this.map.getCenter();
|
||||
var veCenter = this.getVELatLongFromOLLonLat(olCenter);
|
||||
|
||||
if (zoomChanged) {
|
||||
var olZoom = this.map.getZoom();
|
||||
var veZoom = this.getVEZoomFromOLZoom(olZoom);
|
||||
|
||||
this.vemap.SetCenterAndZoom(veCenter, veZoom);
|
||||
} else {
|
||||
this.vemap.PanToLatLong(veCenter);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
loadVEMap:function() {
|
||||
loadMapObject:function() {
|
||||
|
||||
// create div and set to same size as map
|
||||
var veDiv = OpenLayers.Util.createDiv(this.name);
|
||||
@@ -87,47 +51,30 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
veDiv.style.height = sz.h;
|
||||
this.div.appendChild(veDiv);
|
||||
|
||||
try {
|
||||
try { // crash prevention
|
||||
this.mapObject = new VEMap(this.name);
|
||||
} catch (e) { }
|
||||
|
||||
// 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.
|
||||
if (this.mapObject != null) {
|
||||
try { // this is to catch a Mozilla bug without falling apart
|
||||
this.mapObject.LoadMap(null, null, this.type);
|
||||
} catch (e) { }
|
||||
this.mapObject.HideDashboard();
|
||||
}
|
||||
|
||||
|
||||
if (this.vemap == null) {
|
||||
this.loadWarningMessage();
|
||||
} else {
|
||||
|
||||
|
||||
try {
|
||||
this.vemap.LoadMap();
|
||||
} catch (e) {
|
||||
// this is to catch a Mozilla bug without falling apart
|
||||
}
|
||||
|
||||
this.vemap.HideDashboard();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/** If we can't load the vemap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
/**
|
||||
* @return String with information on why layer is broken, how to get
|
||||
* it working.
|
||||
* @type String
|
||||
*/
|
||||
loadWarningMessage:function() {
|
||||
|
||||
this.div.style.backgroundColor = "darkblue";
|
||||
getWarningHTML:function() {
|
||||
|
||||
var html = "";
|
||||
html += "The VE Layer was unable to load correctly.<br>";
|
||||
html += "<br>";
|
||||
html += "To get rid of this message, click on the VE Layer's "
|
||||
html += "tab in the layer switcher in the upper-right corner.<br>";
|
||||
html += "To get rid of this message, select a new BaseLayer "
|
||||
html += "in the layer switcher in the upper-right corner.<br>";
|
||||
html += "<br>";
|
||||
html += "Most likely, this is because the VE library";
|
||||
html += " script was either not correctly included.<br>";
|
||||
@@ -137,229 +84,144 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
html += "target='_blank'>";
|
||||
html += "click here";
|
||||
html += "</a>";
|
||||
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
msgW = Math.min(viewSize.w, 300);
|
||||
msgH = Math.min(viewSize.h, 200);
|
||||
var size = new OpenLayers.Size(msgW, msgH);
|
||||
|
||||
var centerPx = new OpenLayers.Pixel(viewSize.w/2, viewSize.h/2);
|
||||
|
||||
var topLeft = centerPx.add(-size.w/2, -size.h/2);
|
||||
|
||||
var div = OpenLayers.Util.createDiv("veWarning",
|
||||
topLeft,
|
||||
size,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"auto");
|
||||
|
||||
div.style.padding = "7px";
|
||||
div.style.backgroundColor = "yellow";
|
||||
|
||||
div.innerHTML = html;
|
||||
this.div.appendChild(div);
|
||||
return html;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} viewPortPx
|
||||
*
|
||||
* @returns An OpenLayers.LonLat which is the passed-in view port
|
||||
* OpenLayers.Pixel, translated into lon/lat by VE
|
||||
* If vemap is not loaded, returns null.
|
||||
* @type OpenLayers.LonLat
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Interface Controls *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// Get&Set Center, Zoom
|
||||
|
||||
/** Set the mapObject to the specified center and zoom
|
||||
*
|
||||
* @param {Object} center MapObject LonLat format
|
||||
* @param {int} zoom MapObject zoom format
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var lonlat = null;
|
||||
if (this.vemap != null) {
|
||||
var pixel = this.getPixelFromOLPixel(viewPortPx);
|
||||
var zoom = this.vemap.GetZoomLevel();
|
||||
var veLatLong = this.vemap.PixelToLatLong(pixel.x, pixel.y, zoom);
|
||||
lonlat = this.getOLLonLatFromVELatLong(veLatLong);
|
||||
}
|
||||
return lonlat;
|
||||
setMapObjectCenter: function(center, zoom) {
|
||||
this.mapObject.SetCenterAndZoom(center, zoom);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
*
|
||||
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
|
||||
* translated into view port pixels BY VE
|
||||
* If vemap is not loaded, returns null.
|
||||
* @type OpenLayers.Pixel
|
||||
* @returns the mapObject's current center in Map Object format
|
||||
* @type Object
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
var viewPortPx = null;
|
||||
if (this.vemap != null) {
|
||||
var veLatLong = this.getVELatLongFromOLLonLat(lonlat);
|
||||
var pixel = this.vemap.LatLongToPixel(veLatLong);
|
||||
viewPortPx = this.getOLPixelFromPixel(pixel);
|
||||
}
|
||||
return viewPortPx;
|
||||
getMapObjectCenter: function() {
|
||||
return this.mapObject.GetCenter();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns Corresponding zoom level for a specified Bounds.
|
||||
* If vemap is not loaded, returns null.
|
||||
/**
|
||||
* @returns the mapObject's current zoom, in Map Object format
|
||||
* @type int
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var zoom = null;
|
||||
if (this.vemap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
}
|
||||
return zoom;
|
||||
getMapObjectZoom: function() {
|
||||
return this.mapObject.GetZoomLevel();
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Translation Functions */
|
||||
/* */
|
||||
/* The following functions translate GMaps and OL */
|
||||
/* formats for Pixel, LonLat, Bounds, and Zoom */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
//
|
||||
// TRANSLATION: GZoom <-> OpenLayers Zoom
|
||||
//
|
||||
|
||||
// LonLat - Pixel Translation
|
||||
|
||||
/**
|
||||
* @param {int} veZoom
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns An OpenLayers Zoom level, translated from the passed in veZoom
|
||||
* Returns null if null value is passed in
|
||||
* @type int
|
||||
* @returns MapObject LonLat translated from MapObject Pixel
|
||||
* @type Object
|
||||
*/
|
||||
getOLZoomFromVEZoom: function(veZoom) {
|
||||
var zoom = null;
|
||||
if (veZoom != null) {
|
||||
zoom = veZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
|
||||
return this.mapObject.PixelToLatLong(moPixel.x, moPixel.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns MapObject Pixel translated from MapObject LonLat
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
|
||||
return this.mapObject.LatLongToPixel(moLonLat);
|
||||
},
|
||||
|
||||
|
||||
/************************************
|
||||
* *
|
||||
* MapObject Primitives *
|
||||
* *
|
||||
************************************/
|
||||
|
||||
|
||||
// LonLat
|
||||
|
||||
/**
|
||||
* @param {int} olZoom
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns A VEZoom level, translated from the passed in olZoom
|
||||
* Returns null if null value is passed in
|
||||
* @returns Longitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLongitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Longitude;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} moLonLat MapObject LonLat format
|
||||
*
|
||||
* @returns Latitude of the given MapObject LonLat
|
||||
* @type float
|
||||
*/
|
||||
getLatitudeFromMapObjectLonLat: function(moLonLat) {
|
||||
return moLonLat.Latitude;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} lon float
|
||||
* @param {int} lat float
|
||||
*
|
||||
* @returns MapObject LonLat built from lon and lat params
|
||||
* @type Object
|
||||
*/
|
||||
getMapObjectLonLatFromLonLat: function(lon, lat) {
|
||||
return new VELatLong(lat, lon);
|
||||
},
|
||||
|
||||
// Pixel
|
||||
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns X value of the MapObject Pixel
|
||||
* @type int
|
||||
*/
|
||||
getVEZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
getXFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.x;
|
||||
},
|
||||
|
||||
//
|
||||
// TRANSLATION: VELatLong <-> LonLat
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {VELatLong} veLatLong
|
||||
/**
|
||||
* @param {Object} moPixel MapObject Pixel format
|
||||
*
|
||||
* @returns An OpenLayers.LonLat, translated from the passed in VELatLong
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.LonLat
|
||||
* @returns Y value of the MapObject Pixel
|
||||
* @type int
|
||||
*/
|
||||
getOLLonLatFromVELatLong: function(veLatLong) {
|
||||
var olLonLat = null;
|
||||
if (veLatLong != null) {
|
||||
olLonLat = new OpenLayers.LonLat(veLatLong.Longitude,
|
||||
veLatLong.Latitude);
|
||||
}
|
||||
return olLonLat;
|
||||
getYFromMapObjectPixel: function(moPixel) {
|
||||
return moPixel.y;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.LonLat} olLonLat
|
||||
/**
|
||||
* @param {int} x
|
||||
* @param {int} y
|
||||
*
|
||||
* @returns A VELatLong, translated from the passed in OpenLayers.LonLat
|
||||
* Returns null if null value is passed in
|
||||
* @type VELatLong
|
||||
* @returns MapObject Pixel from x and y parameters
|
||||
* @type Object
|
||||
*/
|
||||
getVELatLongFromOLLonLat: function(olLonLat) {
|
||||
var veLatLong = null;
|
||||
if (olLonLat != null) {
|
||||
veLatLong = new VELatLong(olLonLat.lat, olLonLat.lon);
|
||||
}
|
||||
return veLatLong;
|
||||
getMapObjectPixelFromXY: function(x, y) {
|
||||
return new Msn.VE.Pixel(x, y);
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// TRANSLATION: Pixel <-> OpenLayers.Pixel
|
||||
//
|
||||
|
||||
/**
|
||||
* @param {Pixel} pixel
|
||||
*
|
||||
* @returns An OpenLayers.Pixel, translated from the passed in Pixel
|
||||
* Returns null if null value is passed in
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
getOLPixelFromPixel: function(pixel) {
|
||||
var olPixel = null;
|
||||
if (pixel != null) {
|
||||
olPixel = new OpenLayers.Pixel(pixel.x, pixel.y);
|
||||
}
|
||||
return olPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} olPixel
|
||||
*
|
||||
* @returns A Pixel, translated from the passed in OpenLayers.Pixel
|
||||
* Returns null if null value is passed in
|
||||
*
|
||||
* As it turns out, the only specifications we can see for the
|
||||
* VE-compatible Pixel is an x & y property, which every
|
||||
* OpenLayers.Pixel has by default. So just leave it as-is.
|
||||
*
|
||||
* @type Pixel
|
||||
*/
|
||||
getPixelFromOLPixel: function(olPixel) {
|
||||
var pixel = null;
|
||||
if (olPixel != null) {
|
||||
pixel = new Msn.VE.Pixel(olPixel.x, olPixel.y);
|
||||
}
|
||||
return pixel;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user