move Layer.VirtualEarth function into deprecated.js

This commit is contained in:
fredj
2011-11-14 15:52:39 +01:00
parent 71f1f4701b
commit 3d0d2cbc4e
6 changed files with 380 additions and 595 deletions

View File

@@ -1,68 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Virtual Earth Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, velayer, layer;
function init(){
map = new OpenLayers.Map('map', {
controls: [new OpenLayers.Control.Navigation()],
panMethod: OpenLayers.Easing.Linear.easeOut,
panDuration: 10
});
velayer = new OpenLayers.Layer.VirtualEarth("VE", {
minZoomLevel: 2,
maxZoomLevel: 6,
type: VEMapStyle.Road
});
map.addLayer(velayer);
map.setCenter(new OpenLayers.LonLat(25, 25), 0);
map.addControl( new OpenLayers.Control.PanZoomBar() );
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
for(var i=0;i<100;i++){
var lat= Math.floor(Math.random()*50);
var lon= Math.floor(Math.random()*50);
var lonLat=new OpenLayers.LonLat(lon,lat);
var marker=new OpenLayers.Marker(lonLat);
markers.addMarker(marker);
}
}
</script>
</head>
<body onload="init()">
<h1 id="title">Virtual Earth Example</h1>
<div id="tags">
panning, virtual earth, panzoom, panmethod, panduration
</div>
<p id="shortdesc">
When using the PanZoom buttons with VirtualEarth, some 'drift' is
possible in markers. This page demonstrates how to use the
panMethod and panDuration properties to change the OpenLayers
settings to match VirtualEarth.
</p>
<div id="map" class="smallmap"></div>
</body>
</html>

View File

@@ -1,74 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Virtual Earth Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var lon = 12;
var lat = 41;
var zoom = 15;
var map, velayer, layer, marker;
function init(){
map = new OpenLayers.Map( 'map' ,
{controls:[new OpenLayers.Control.MouseDefaults()]});
velayer = new OpenLayers.Layer.VirtualEarth( "VE", {
// turn off animated zooming
animationEnabled: false,
minZoomLevel: 4,
maxZoomLevel: 6,
'type': VEMapStyle.Aerial
});
map.addLayer(velayer);
markers = new OpenLayers.Layer.Markers("markers");
map.addLayer(markers);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
map.addControl( new OpenLayers.Control.PanZoomBar() );
}
function add() {
if(!marker) {
marker = new OpenLayers.Marker(new OpenLayers.LonLat(15, 47));
markers.addMarker(marker);
}
}
function remove() {
if(marker) {
markers.removeMarker(marker);
marker = null;
}
}
</script>
</head>
<body onload="init()">
<h1 id="title">Virtual Earth Example</h1>
<div id="tags">
virtual earth, marker
</div>
<p id="shortdesc">
Demonstrates the use of a Virtual Earth base layer.
</p>
<div id="map" class="smallmap"></div>
<input type="button" onClick="javascript:add()"value="Add the marker to the map">
<input type="button" onClick="javascript:remove()" value="Remove the marker from the map">
<div id="docs">This example demonstrates the ability to add VirtualEarth and the and remove markers.</div>
</body>
</html>

View File

@@ -128,7 +128,6 @@
"OpenLayers/Layer/FixedZoomLevels.js",
"OpenLayers/Layer/Google.js",
"OpenLayers/Layer/Google/v3.js",
"OpenLayers/Layer/VirtualEarth.js",
"OpenLayers/Layer/Yahoo.js",
"OpenLayers/Layer/HTTPRequest.js",
"OpenLayers/Layer/Grid.js",

View File

@@ -1,391 +0,0 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Layer/SphericalMercator.js
* @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
* @requires OpenLayers/Lang.js
*/
/**
* Class: OpenLayers.Layer.VirtualEarth
* *Deprecated*. Use <OpenLayers.Layer.Bing> instead.
*
* Instances of OpenLayers.Layer.VirtualEarth are used to display the data from
* the Bing Maps AJAX Control (see e.g.
* http://msdn.microsoft.com/library/bb429619.aspx). Create a VirtualEarth
* layer with the <OpenLayers.Layer.VirtualEarth> constructor.
*
* Inherits from:
* - <OpenLayers.Layer.EventPane>
* - <OpenLayers.Layer.FixedZoomLevels>
*/
OpenLayers.Layer.VirtualEarth = OpenLayers.Class(
OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/**
* Constant: MIN_ZOOM_LEVEL
* {Integer} 1
*/
MIN_ZOOM_LEVEL: 1,
/**
* Constant: MAX_ZOOM_LEVEL
* {Integer} 19
*/
MAX_ZOOM_LEVEL: 19,
/**
* Constant: RESOLUTIONS
* {Array(Float)} Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*/
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,
0.00002145767211914062,
0.00001072883605957031,
0.00000536441802978515
],
/**
* APIProperty: type
* {VEMapType}
*/
type: null,
/**
* APIProperty: wrapDateLine
* {Boolean} Allow user to pan forever east/west. Default is true.
* Setting this to false only restricts panning if
* <sphericalMercator> is true.
*/
wrapDateLine: true,
/**
* APIProperty: sphericalMercator
* {Boolean} Should the map act as a mercator-projected map? This will
* cause all interactions with the map to be in the actual map
* projection, which allows support for vector drawing, overlaying
* other maps, etc.
*/
sphericalMercator: false,
/**
* APIProperty: animationEnabled
* {Boolean} If set to true, the transition between zoom levels will be
* animated. Set to false to match the zooming experience of other
* layer types. Default is true.
*/
animationEnabled: true,
/**
* Constructor: OpenLayers.Layer.VirtualEarth
* Creates a new instance of a OpenLayers.Layer.VirtualEarth. If you use an
* instance of OpenLayers.Layer.VirtualEarth in you map, you should set
* the <OpenLayers.Map> option restrictedExtent to a meaningful value,
* e.g.:
* (code)
* var map = new OpenLayers.Map( 'map', {
* // other map options
* restrictedExtent : OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)
* } );
*
* var veLayer = new OpenLayers.Layer.VirtualEarth (
* "Virtual Earth Layer"
* );
*
* map.addLayer( veLayer );
* (end)
*
* Parameters:
* name - {String}
* options - {Object}
*/
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if(this.sphericalMercator) {
OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
this.initMercatorParameters();
}
},
/**
* Method: loadMapObject
*/
loadMapObject: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 + "px";
veDiv.style.height = sz.h + "px";
this.div.appendChild(veDiv);
try { // crash prevention
this.mapObject = new VEMap(this.name);
} catch (e) { }
if (this.mapObject != null) {
try { // this is to catch a Mozilla bug without falling apart
// The fourth argument is whether the map is 'fixed' -- not
// draggable. See:
// http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx
//
this.mapObject.LoadMap(null, null, this.type, true);
this.mapObject.AttachEvent("onmousedown", OpenLayers.Function.True);
} catch (e) { }
this.mapObject.HideDashboard();
if(typeof this.mapObject.SetAnimationEnabled == "function") {
this.mapObject.SetAnimationEnabled(this.animationEnabled);
}
}
//can we do smooth panning? this is an unpublished method, so we need
// to be careful
if ( !this.mapObject ||
!this.mapObject.vemapcontrol ||
!this.mapObject.vemapcontrol.PanMap ||
(typeof this.mapObject.vemapcontrol.PanMap != "function")) {
this.dragPanMapObject = null;
}
},
/**
* Method: onMapResize
*/
onMapResize: function() {
this.mapObject.Resize(this.map.size.w, this.map.size.h);
},
/**
* APIMethod: getWarningHTML
*
* Returns:
* {String} String with information on why layer is broken, how to get
* it working.
*/
getWarningHTML:function() {
return OpenLayers.i18n(
"getLayerWarning", {'layerType':'VE', 'layerLib':'VirtualEarth'}
);
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/**
* APIMethod: setMapObjectCenter
* Set the mapObject to the specified center and zoom
*
* Parameters:
* center - {Object} MapObject LonLat format
* zoom - {int} MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.SetCenterAndZoom(center, zoom);
},
/**
* APIMethod: getMapObjectCenter
*
* Returns:
* {Object} The mapObject's current center in Map Object format
*/
getMapObjectCenter: function() {
return this.mapObject.GetCenter();
},
/**
* APIMethod: dragPanMapObject
*
* Parameters:
* dX - {Integer}
* dY - {Integer}
*/
dragPanMapObject: function(dX, dY) {
this.mapObject.vemapcontrol.PanMap(dX, -dY);
},
/**
* APIMethod: getMapObjectZoom
*
* Returns:
* {Integer} The mapObject's current zoom, in Map Object format
*/
getMapObjectZoom: function() {
return this.mapObject.GetZoomLevel();
},
// LonLat - Pixel Translation
/**
* APIMethod: getMapObjectLonLatFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Object} MapObject LonLat translated from MapObject Pixel
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
//the conditional here is to test if we are running the v6 of VE
return (typeof VEPixel != 'undefined')
? this.mapObject.PixelToLatLong(moPixel)
: this.mapObject.PixelToLatLong(moPixel.x, moPixel.y);
},
/**
* APIMethod: getMapObjectPixelFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Object} MapObject Pixel transtlated from MapObject LonLat
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.LatLongToPixel(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* APIMethod: getLongitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Longitude of the given MapObject LonLat
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lon :
moLonLat.Longitude;
},
/**
* APIMethod: getLatitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Latitude of the given MapObject LonLat
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lat :
moLonLat.Latitude;
},
/**
* APIMethod: getMapObjectLonLatFromLonLat
*
* Parameters:
* lon - {Float}
* lat - {Float}
*
* Returns:
* {Object} MapObject LonLat built from lon and lat params
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
var veLatLong;
if(this.sphericalMercator) {
var lonlat = this.inverseMercator(lon, lat);
veLatLong = new VELatLong(lonlat.lat, lonlat.lon);
} else {
veLatLong = new VELatLong(lat, lon);
}
return veLatLong;
},
// Pixel
/**
* APIMethod: getXFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} X value of the MapObject Pixel
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* APIMethod: getYFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} Y value of the MapObject Pixel
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* APIMethod: getMapObjectPixelFromXY
*
* Parameters:
* x - {Integer}
* y - {Integer}
*
* Returns:
* {Object} MapObject Pixel from x and y parameters
*/
getMapObjectPixelFromXY: function(x, y) {
//the conditional here is to test if we are running the v6 of VE
return (typeof VEPixel != 'undefined') ? new VEPixel(x, y)
: new Msn.VE.Pixel(x, y);
},
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
});

View File

@@ -15,6 +15,7 @@
* @requires OpenLayers/Feature.js
* @requires OpenLayers/Layer/EventPane.js
* @requires OpenLayers/Layer/FixedZoomLevels.js
* @requires OpenLayers/Layer/SphericalMercator.js
*/
/**
@@ -3176,3 +3177,382 @@ OpenLayers.Layer.MultiMap = OpenLayers.Class(
CLASS_NAME: "OpenLayers.Layer.MultiMap"
});
/**
* Class: OpenLayers.Layer.VirtualEarth
* *Deprecated*. Use <OpenLayers.Layer.Bing> instead.
*
* Instances of OpenLayers.Layer.VirtualEarth are used to display the data from
* the Bing Maps AJAX Control (see e.g.
* http://msdn.microsoft.com/library/bb429619.aspx). Create a VirtualEarth
* layer with the <OpenLayers.Layer.VirtualEarth> constructor.
*
* Inherits from:
* - <OpenLayers.Layer.EventPane>
* - <OpenLayers.Layer.FixedZoomLevels>
*/
OpenLayers.Layer.VirtualEarth = OpenLayers.Class(
OpenLayers.Layer.EventPane,
OpenLayers.Layer.FixedZoomLevels, {
/**
* Constant: MIN_ZOOM_LEVEL
* {Integer} 1
*/
MIN_ZOOM_LEVEL: 1,
/**
* Constant: MAX_ZOOM_LEVEL
* {Integer} 19
*/
MAX_ZOOM_LEVEL: 19,
/**
* Constant: RESOLUTIONS
* {Array(Float)} Hardcode these resolutions so that they are more closely
* tied with the standard wms projection
*/
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,
0.00002145767211914062,
0.00001072883605957031,
0.00000536441802978515
],
/**
* APIProperty: type
* {VEMapType}
*/
type: null,
/**
* APIProperty: wrapDateLine
* {Boolean} Allow user to pan forever east/west. Default is true.
* Setting this to false only restricts panning if
* <sphericalMercator> is true.
*/
wrapDateLine: true,
/**
* APIProperty: sphericalMercator
* {Boolean} Should the map act as a mercator-projected map? This will
* cause all interactions with the map to be in the actual map
* projection, which allows support for vector drawing, overlaying
* other maps, etc.
*/
sphericalMercator: false,
/**
* APIProperty: animationEnabled
* {Boolean} If set to true, the transition between zoom levels will be
* animated. Set to false to match the zooming experience of other
* layer types. Default is true.
*/
animationEnabled: true,
/**
* Constructor: OpenLayers.Layer.VirtualEarth
* Creates a new instance of a OpenLayers.Layer.VirtualEarth. If you use an
* instance of OpenLayers.Layer.VirtualEarth in you map, you should set
* the <OpenLayers.Map> option restrictedExtent to a meaningful value,
* e.g.:
* (code)
* var map = new OpenLayers.Map( 'map', {
* // other map options
* restrictedExtent : OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)
* } );
*
* var veLayer = new OpenLayers.Layer.VirtualEarth (
* "Virtual Earth Layer"
* );
*
* map.addLayer( veLayer );
* (end)
*
* Parameters:
* name - {String}
* options - {Object}
*/
initialize: function(name, options) {
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
arguments);
if(this.sphericalMercator) {
OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
this.initMercatorParameters();
}
},
/**
* Method: loadMapObject
*/
loadMapObject: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 + "px";
veDiv.style.height = sz.h + "px";
this.div.appendChild(veDiv);
try { // crash prevention
this.mapObject = new VEMap(this.name);
} catch (e) { }
if (this.mapObject != null) {
try { // this is to catch a Mozilla bug without falling apart
// The fourth argument is whether the map is 'fixed' -- not
// draggable. See:
// http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx
//
this.mapObject.LoadMap(null, null, this.type, true);
this.mapObject.AttachEvent("onmousedown", OpenLayers.Function.True);
} catch (e) { }
this.mapObject.HideDashboard();
if(typeof this.mapObject.SetAnimationEnabled == "function") {
this.mapObject.SetAnimationEnabled(this.animationEnabled);
}
}
//can we do smooth panning? this is an unpublished method, so we need
// to be careful
if ( !this.mapObject ||
!this.mapObject.vemapcontrol ||
!this.mapObject.vemapcontrol.PanMap ||
(typeof this.mapObject.vemapcontrol.PanMap != "function")) {
this.dragPanMapObject = null;
}
},
/**
* Method: onMapResize
*/
onMapResize: function() {
this.mapObject.Resize(this.map.size.w, this.map.size.h);
},
/**
* APIMethod: getWarningHTML
*
* Returns:
* {String} String with information on why layer is broken, how to get
* it working.
*/
getWarningHTML:function() {
return OpenLayers.i18n(
"getLayerWarning", {'layerType':'VE', 'layerLib':'VirtualEarth'}
);
},
/************************************
* *
* MapObject Interface Controls *
* *
************************************/
// Get&Set Center, Zoom
/**
* APIMethod: setMapObjectCenter
* Set the mapObject to the specified center and zoom
*
* Parameters:
* center - {Object} MapObject LonLat format
* zoom - {int} MapObject zoom format
*/
setMapObjectCenter: function(center, zoom) {
this.mapObject.SetCenterAndZoom(center, zoom);
},
/**
* APIMethod: getMapObjectCenter
*
* Returns:
* {Object} The mapObject's current center in Map Object format
*/
getMapObjectCenter: function() {
return this.mapObject.GetCenter();
},
/**
* APIMethod: dragPanMapObject
*
* Parameters:
* dX - {Integer}
* dY - {Integer}
*/
dragPanMapObject: function(dX, dY) {
this.mapObject.vemapcontrol.PanMap(dX, -dY);
},
/**
* APIMethod: getMapObjectZoom
*
* Returns:
* {Integer} The mapObject's current zoom, in Map Object format
*/
getMapObjectZoom: function() {
return this.mapObject.GetZoomLevel();
},
// LonLat - Pixel Translation
/**
* APIMethod: getMapObjectLonLatFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Object} MapObject LonLat translated from MapObject Pixel
*/
getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
//the conditional here is to test if we are running the v6 of VE
return (typeof VEPixel != 'undefined')
? this.mapObject.PixelToLatLong(moPixel)
: this.mapObject.PixelToLatLong(moPixel.x, moPixel.y);
},
/**
* APIMethod: getMapObjectPixelFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Object} MapObject Pixel transtlated from MapObject LonLat
*/
getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
return this.mapObject.LatLongToPixel(moLonLat);
},
/************************************
* *
* MapObject Primitives *
* *
************************************/
// LonLat
/**
* APIMethod: getLongitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Longitude of the given MapObject LonLat
*/
getLongitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lon :
moLonLat.Longitude;
},
/**
* APIMethod: getLatitudeFromMapObjectLonLat
*
* Parameters:
* moLonLat - {Object} MapObject LonLat format
*
* Returns:
* {Float} Latitude of the given MapObject LonLat
*/
getLatitudeFromMapObjectLonLat: function(moLonLat) {
return this.sphericalMercator ?
this.forwardMercator(moLonLat.Longitude, moLonLat.Latitude).lat :
moLonLat.Latitude;
},
/**
* APIMethod: getMapObjectLonLatFromLonLat
*
* Parameters:
* lon - {Float}
* lat - {Float}
*
* Returns:
* {Object} MapObject LonLat built from lon and lat params
*/
getMapObjectLonLatFromLonLat: function(lon, lat) {
var veLatLong;
if(this.sphericalMercator) {
var lonlat = this.inverseMercator(lon, lat);
veLatLong = new VELatLong(lonlat.lat, lonlat.lon);
} else {
veLatLong = new VELatLong(lat, lon);
}
return veLatLong;
},
// Pixel
/**
* APIMethod: getXFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} X value of the MapObject Pixel
*/
getXFromMapObjectPixel: function(moPixel) {
return moPixel.x;
},
/**
* APIMethod: getYFromMapObjectPixel
*
* Parameters:
* moPixel - {Object} MapObject Pixel format
*
* Returns:
* {Integer} Y value of the MapObject Pixel
*/
getYFromMapObjectPixel: function(moPixel) {
return moPixel.y;
},
/**
* APIMethod: getMapObjectPixelFromXY
*
* Parameters:
* x - {Integer}
* y - {Integer}
*
* Returns:
* {Object} MapObject Pixel from x and y parameters
*/
getMapObjectPixelFromXY: function(x, y) {
//the conditional here is to test if we are running the v6 of VE
return (typeof VEPixel != 'undefined') ? new VEPixel(x, y)
: new Msn.VE.Pixel(x, y);
},
CLASS_NAME: "OpenLayers.Layer.VirtualEarth"
});

View File

@@ -1,61 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 512px;
height: 512px;
border: 1px solid gray;
}
</style>
<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
// make map available for easy debugging
var map;
// increase reload attempts
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
function init(){
var options = {
projection: "EPSG:900913",
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34)
};
map = new OpenLayers.Map('map', options);
// create Virtual Earth layers
var veroad = new OpenLayers.Layer.VirtualEarth(
"Virtual Earth Raods",
{'type': VEMapStyle.Road, 'sphericalMercator': true}
);
// create WMS layer
var wms = new OpenLayers.Layer.WMS(
"World Map",
"http://world.freemap.in/tiles/",
{'layers': 'factbook-overlay', 'format':'png'},
{
'opacity': 0.4,
'isBaseLayer': false,'wrapDateLine': true
}
);
map.addLayers([veroad, wms]);
map.zoomToMaxExtent()
}
</script>
</head>
<body onload="init()">
<h3>VE Opacity</h3>
<p>The overlay should have an opacity of 40%.</p>
<div id="map"></div>
</body>
</html>