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

📄 vector.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. */// TRASH THISOpenLayers.State = {    /** states */    UNKNOWN: 'Unknown',    INSERT: 'Insert',    UPDATE: 'Update',    DELETE: 'Delete'}/** * @requires OpenLayers/Feature.js * @requires OpenLayers/Util.js * * Class: OpenLayers.Feature.Vector * Vector features use the OpenLayers.Geometry classes as geometry description. * They have an 'attributes' property, which is the data object, and a 'style' * property, the default values of which are defined in the  * <OpenLayers.Feature.Vector.style> objects. *  * Inherits from: *  - <OpenLayers.Feature> */OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {    /**      * Property: fid      * {String}      */    fid: null,        /**      * APIProperty: geometry      * {<OpenLayers.Geometry>}      */    geometry: null,    /**      * APIProperty: attributes      * {Object} This object holds arbitrary properties that describe the     *     feature.     */    attributes: null,    /**      * Property: state      * {String}      */    state: null,        /**      * APIProperty: style      * {Object}      */    style: null,        /**      * Constructor: OpenLayers.Feature.Vector     * Create a vector feature.      *      * Parameters:     * geometry - {<OpenLayers.Geometry>} The geometry that this feature     *     represents.     * attributes - {Object} An optional object that will be mapped to the     *     <attributes> property.      * style - {Object} An optional style object.     */    initialize: function(geometry, attributes, style) {        OpenLayers.Feature.prototype.initialize.apply(this,                                                      [null, null, attributes]);        this.lonlat = null;        this.geometry = geometry;        this.state = null;        this.attributes = {};        if (attributes) {            this.attributes = OpenLayers.Util.extend(this.attributes,                                                     attributes);        }        this.style = style ? style : null;     },        /**      * Method: destroy     * nullify references to prevent circular references and memory leaks     */    destroy: function() {        if (this.layer) {            this.layer.removeFeatures(this);            this.layer = null;        }                    this.geometry = null;        OpenLayers.Feature.prototype.destroy.apply(this, arguments);    },        /**     * Method: clone     * Create a clone of this vector feature.  Does not set any non-standard     *     properties.     *     * Returns:     * {<OpenLayers.Feature.Vector>} An exact clone of this vector feature.     */    clone: function () {        return new OpenLayers.Feature.Vector(this.geometry.clone(),                                             this.attributes,                                             this.style);    },    /**     * Method: onScreen     * HACK - we need to rewrite this for non-point geometry     *      * Returns:     * {Boolean} For now just returns null     */    onScreen:function() {        return null;    },        /**     * Method: createMarker     * HACK - we need to decide if all vector features should be able to     *     create markers     *      * Returns:     * {<OpenLayers.Marker>} For now just returns null     */    createMarker: function() {        return null;    },    /**     * Method: destroyMarker     * HACK - we need to decide if all vector features should be able to     *     delete markers     *      * If user overrides the createMarker() function, s/he should be able     *   to also specify an alternative function for destroying it     */    destroyMarker: function() {        // pass    },    /**     * Method: createPopup     * HACK - we need to decide if all vector features should be able to     *     create popups     *      * Returns:     * {<OpenLayers.Popup>} For now just returns null     */    createPopup: function() {        return null;    },    /**     * Method: atPoint     * Determins whether the feature intersects with the specified location.     *      * Parameters:      * lonlat - {<OpenLayers.LonLat>}      * toleranceLon - {float} Optional tolerance in Geometric Coords     * toleranceLat - {float} Optional tolerance in Geographic Coords     *      * Returns:     * {Boolean} Whether or not the feature is at the specified location     */    atPoint: function(lonlat, toleranceLon, toleranceLat) {        var atPoint = false;        if(this.geometry) {            atPoint = this.geometry.atPoint(lonlat, toleranceLon,                                                     toleranceLat);        }        return atPoint;    },    /**     * Method: destroyPopup     * HACK - we need to decide if all vector features should be able to     * delete popups     */    destroyPopup: function() {        // pass    },        /**     * Method: toState     * Sets the new state     *     * Parameters:     * state - {String}      */    toState: function(state) {        if (state == OpenLayers.State.UPDATE) {            switch (this.state) {                case OpenLayers.State.UNKNOWN:                case OpenLayers.State.DELETE:                    this.state = state;                    break;                case OpenLayers.State.UPDATE:                case OpenLayers.State.INSERT:                    break;            }        } else if (state == OpenLayers.State.INSERT) {            switch (this.state) {                case OpenLayers.State.UNKNOWN:                    break;                default:                    this.state = state;                    break;            }        } else if (state == OpenLayers.State.DELETE) {            switch (this.state) {                case OpenLayers.State.INSERT:                    // the feature should be destroyed                    break;                case OpenLayers.State.DELETE:                    break;                case OpenLayers.State.UNKNOWN:                case OpenLayers.State.UPDATE:                    this.state = state;                    break;            }        } else if (state == OpenLayers.State.UNKNOWN) {            this.state = state;        }    },        CLASS_NAME: "OpenLayers.Feature.Vector"});/** * Constant: OpenLayers.Feature.Vector.style * OpenLayers features can have a number of style attributes. The 'default'  *     style will typically be used if no other style is specified. * * Default style properties: * *  - fillColor: "#ee9900", *  - fillOpacity: 0.4,  *  - hoverFillColor: "white", *  - hoverFillOpacity: 0.8, *  - strokeColor: "#ee9900", *  - strokeOpacity: 1, *  - strokeWidth: 1, *  - strokeLinecap: "round", *  - hoverStrokeColor: "red", *  - hoverStrokeOpacity: 1, *  - hoverStrokeWidth: 0.2, *  - pointRadius: 6, *  - hoverPointRadius: 1, *  - hoverPointUnit: "%", *  - pointerEvents: "visiblePainted" * * Other style properties that have no default values: * *  - externalGraphic, *  - graphicWidth, *  - graphicHeight, *  - graphicOpacity *  - graphicXOffset *  - graphicYOffset */ OpenLayers.Feature.Vector.style = {    'default': {        fillColor: "#ee9900",        fillOpacity: 0.4,         hoverFillColor: "white",        hoverFillOpacity: 0.8,        strokeColor: "#ee9900",        strokeOpacity: 1,        strokeWidth: 1,        strokeLinecap: "round",        hoverStrokeColor: "red",        hoverStrokeOpacity: 1,        hoverStrokeWidth: 0.2,        pointRadius: 6,        hoverPointRadius: 1,        hoverPointUnit: "%",        pointerEvents: "visiblePainted"    },    'select': {        fillColor: "blue",        fillOpacity: 0.4,         hoverFillColor: "white",        hoverFillOpacity: 0.8,        strokeColor: "blue",        strokeOpacity: 1,        strokeWidth: 2,        strokeLinecap: "round",        hoverStrokeColor: "red",        hoverStrokeOpacity: 1,        hoverStrokeWidth: 0.2,        pointRadius: 6,        hoverPointRadius: 1,        hoverPointUnit: "%",        pointerEvents: "visiblePainted",        cursor: "pointer"    },    'temporary': {        fillColor: "yellow",        fillOpacity: 0.2,         hoverFillColor: "white",        hoverFillOpacity: 0.8,        strokeColor: "yellow",        strokeOpacity: 1,        strokeLinecap: "round",        strokeWidth: 4,        hoverStrokeColor: "red",        hoverStrokeOpacity: 1,        hoverStrokeWidth: 0.2,        pointRadius: 6,        hoverPointRadius: 1,        hoverPointUnit: "%",        pointerEvents: "visiblePainted"    }};    

⌨️ 快捷键说明

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