⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virtualearth.js

📁 用来在地图上做操作GIS,在地图上做标记
💻 JS
字号:
/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license. * See http://svn.openlayers.org/trunk/openlayers/release-license.txt  * for the full text of the license. *//** * @requires OpenLayers/Layer/EventPane.js * @requires OpenLayers/Layer/FixedZoomLevels.js *  * Class: OpenLayers.Layer.VirtualEarth *  * 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} 17     */    MAX_ZOOM_LEVEL: 17,    /**      * 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    ],    /**     * APIProperty: type     * {VEMapType}     */    type: null,    /**     * 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,     /**      * Constructor: OpenLayers.Layer.VirtualEarth     *      * 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;        veDiv.style.height = sz.h;        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                this.mapObject.LoadMap(null, null, this.type);            } catch (e) { }            this.mapObject.HideDashboard();        }    },    /**      * APIMethod: getWarningHTML     *      * Returns:      * {String} String with information on why layer is broken, how to get     *          it working.     */    getWarningHTML:function() {        var html = "";        html += "The VE Layer was unable to load correctly.<br>";        html += "<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>";        html += "<br>";        html += "Developers: For help getting this working correctly, ";        html += "<a href='http://trac.openlayers.org/wiki/VirtualEarth' "        html +=  "target='_blank'>";        html +=     "click here";        html += "</a>";        return html;    },    /************************************     *                                  *     *   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: 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) {        return 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) {        return new Msn.VE.Pixel(x, y);    },    CLASS_NAME: "OpenLayers.Layer.VirtualEarth"});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -