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

📄 wfs.js

📁 用来在地图上做操作GIS,在地图上做标记
💻 JS
📖 第 1 页 / 共 2 页
字号:
/* 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/Vector.js * @requires OpenLayers/Layer/Markers.js * * Class: OpenLayers.Layer.WFS *  * Inherits from: *  - <OpenLayers.Layer.Vector> *  - <OpenLayers.Layer.Markers> */OpenLayers.Layer.WFS = OpenLayers.Class(  OpenLayers.Layer.Vector, OpenLayers.Layer.Markers, {    /**     * APIProperty: isBaseLayer     * {Boolean} WFS layer is not a base layer by default.      */    isBaseLayer: false,        /**     * Property: tile     * {<OpenLayers.Tile.WFS>}     */    tile: null,            /**     * APIProperty: ratio     * {Float} the ratio of image/tile size to map size (this is the untiled     *     buffer)     */    ratio: 2,    /**       * Property: DEFAULT_PARAMS     * {Object} Hashtable of default key/value parameters     */    DEFAULT_PARAMS: { service: "WFS",                      version: "1.0.0",                      request: "GetFeature"                    },        /**      * APIProperty: featureClass     * {<OpenLayers.Feature>} If featureClass is defined, an old-style markers     *     based WFS layer is created instead of a new-style vector layer. If     *     sent, this should be a subclass of OpenLayers.Feature     */    featureClass: null,    /**     * Property: vectorMode     * {Boolean} Should be calculated automatically.     */    vectorMode: true,         /**     * APIProperty: encodeBBOX     * {Boolean} Should the BBOX commas be encoded? The WMS spec says 'no',      *     but some services want it that way. Default false.     */    encodeBBOX: false,        /**     * APIProperty: extractAttributes      * {Boolean} Should the WFS layer parse attributes from the retrieved     *     GML? Defaults to false. If enabled, parsing is slower, but      *     attributes are available in the attributes property of      *     layer features.     */    extractAttributes: false,    /**     * Constructor: OpenLayers.Layer.WFS     *     * Parameters:     * name - {String}      * url - {String}      * params - {Object}      * options - {Object} Hashtable of extra options to tag onto the layer     */    initialize: function(name, url, params, options) {        if (options == undefined) { options = {}; }                 if (options.featureClass ||             !OpenLayers.Layer.Vector ||             !OpenLayers.Feature.Vector) {            this.vectorMode = false;        }                    // Turn off error reporting, browsers like Safari may work        // depending on the setup, and we don't want an unneccesary alert.        OpenLayers.Util.extend(options, {'reportError': false});        var newArguments = [];        newArguments.push(name, options);        OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);        if (!this.renderer || !this.vectorMode) {            this.vectorMode = false;             if (!options.featureClass) {                options.featureClass = OpenLayers.Feature.WFS;            }               OpenLayers.Layer.Markers.prototype.initialize.apply(this,                                                                 newArguments);        }                if (this.params && this.params.typename && !this.options.typename) {            this.options.typename = this.params.typename;        }                if (!this.options.geometry_column) {            this.options.geometry_column = "the_geom";        }                    this.params = params;        OpenLayers.Util.applyDefaults(                       this.params,                        OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)                       );        this.url = url;    },            /**     * APIMethod: destroy     */    destroy: function() {        if (this.vectorMode) {            OpenLayers.Layer.Vector.prototype.destroy.apply(this, arguments);        } else {                OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);        }        },        /**     * Method: setMap     *      * Parameters:     * map - {<OpenLayers.Map>}      */    setMap: function(map) {        if (this.vectorMode) {            OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments);        } else {                OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments);        }        },        /**      * Method: moveTo     *      * Parameters:     * bounds - {<OpenLayers.Bounds>}      * zoomChanged - {Boolean}      * dragging - {Boolean}      */    moveTo:function(bounds, zoomChanged, dragging) {        if (this.vectorMode) {            OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);        } else {            OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);        }            // don't load wfs features while dragging, wait for drag end        if (dragging) {            // TBD try to hide the vector layer while dragging            // this.setVisibility(false);            // this will probably help for panning performances            return false;        }                if ( zoomChanged ) {            if (this.vectorMode) {                this.renderer.clear();            }        }            //DEPRECATED - REMOVE IN 3.0        // don't load data if current zoom level doesn't match        if (this.options.minZoomLevel) {                        var err = "The minZoomLevel property is only intended for use " +                    "with the FixedZoomLevels-descendent layers. That this " +                    "wfs layer checks for minZoomLevel is a relic of the" +                    "past. We cannot, however, remove it without possibly " +                    "breaking OL based applications that may depend on it." +                    " Therefore we are deprecating it -- the minZoomLevel " +                    "check below will be removed at 3.0. Please instead " +                    "use min/max resolution setting as described here: " +                    "http://trac.openlayers.org/wiki/SettingZoomLevels";            OpenLayers.Console.warn(err);                        if (this.map.getZoom() < this.options.minZoomLevel) {                return null;            }        }                if (bounds == null) {            bounds = this.map.getExtent();        }        var firstRendering = (this.tile == null);        //does the new bounds to which we need to move fall outside of the         // current tile's bounds?        var outOfBounds = (!firstRendering &&                           !this.tile.bounds.containsBounds(bounds));        if ( (zoomChanged || firstRendering || (!dragging && outOfBounds))             && this.inRange) {            //determine new tile bounds            var center = bounds.getCenterLonLat();            var tileWidth = bounds.getWidth() * this.ratio;            var tileHeight = bounds.getHeight() * this.ratio;            var tileBounds =                 new OpenLayers.Bounds(center.lon - (tileWidth / 2),                                      center.lat - (tileHeight / 2),                                      center.lon + (tileWidth / 2),                                      center.lat + (tileHeight / 2));            //determine new tile size            var tileSize = this.map.getSize();            tileSize.w = tileSize.w * this.ratio;            tileSize.h = tileSize.h * this.ratio;            //determine new position (upper left corner of new bounds)            var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);            var pos = this.map.getLayerPxFromLonLat(ul);            //formulate request url string            var url = this.getFullRequestString();                    var params = {BBOX: this.encodeBBOX ? tileBounds.toBBOX()                                                 : tileBounds.toArray()};            url += "&" + OpenLayers.Util.getParameterString(params);            if (!this.tile) {                this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds,                                                      url, tileSize);

⌨️ 快捷键说明

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