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

📄 pixel.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. *//** * Class: OpenLayers.Pixel * This class represents a screen coordinate, in x and y coordinates */OpenLayers.Pixel = OpenLayers.Class({        /**     * APIProperty: x     * {Number} The x coordinate     */    x: 0.0,    /**     * APIProperty: y     * {Number} The y coordinate     */    y: 0.0,        /**     * Constructor: OpenLayers.Pixel     * Create a new OpenLayers.Pixel instance     *     * Parameters:     * x - {Number} The x coordinate     * y - {Number} The y coordinate     *     * Returns:     * An instance of OpenLayers.Pixel     */    initialize: function(x, y) {        this.x = parseFloat(x);        this.y = parseFloat(y);    },        /**     * Method: toString     * Cast this object into a string     *     * Returns:     * {String} The string representation of Pixel. ex: "x=200.4,y=242.2"     */    toString:function() {        return ("x=" + this.x + ",y=" + this.y);    },    /**     * APIMethod: clone     * Return a clone of this pixel object     *     * Returns:     * {<OpenLayers.Pixel>} A clone pixel     */    clone:function() {        return new OpenLayers.Pixel(this.x, this.y);     },        /**     * APIMethod: equals     * Determine whether one pixel is equivalent to another     *     * Parameters:     * px - {<OpenLayers.Pixel>}     *     * Returns:     * {Boolean} The point passed in as parameter is equal to this. Note that     * if px passed in is null, returns false.     */    equals:function(px) {        var equals = false;        if (px != null) {            equals = ((this.x == px.x && this.y == px.y) ||                      (isNaN(this.x) && isNaN(this.y) && isNaN(px.x) && isNaN(px.y)));        }        return equals;    },    /**     * APIMethod: add     *     * Parameters:     * x - {Integer}     * y - {Integer}     *     * Returns:     * {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the      * values passed in.     */    add:function(x, y) {        if ( (x == null) || (y == null) ) {            var msg = "You must pass both x and y values to the add function.";            OpenLayers.Console.error(msg);            return null;        }        return new OpenLayers.Pixel(this.x + x, this.y + y);    },    /**    * APIMethod: offset    *     * Parameters    * px - {<OpenLayers.Pixel>}    *     * Returns:    * {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the     *                      x&y values of the pixel passed in.    */    offset:function(px) {        var newPx = this.clone();        if (px) {            newPx = this.add(px.x, px.y);        }        return newPx;    },    CLASS_NAME: "OpenLayers.Pixel"});

⌨️ 快捷键说明

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