?? wfs.js
字號:
this.addTileMonitoringHooks(this.tile); this.tile.draw(); } else { if (this.vectorMode) { this.destroyFeatures(); this.renderer.clear(); } else { this.clearMarkers(); } this.removeTileMonitoringHooks(this.tile); this.tile.destroy(); this.tile = null; this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds, url, tileSize); this.addTileMonitoringHooks(this.tile); this.tile.draw(); } } }, /** * Method: addTileMonitoringHooks * This function takes a tile as input and adds the appropriate hooks to * the tile so that the layer can keep track of the loading tile * (making sure to check that the tile is always the layer's current * tile before taking any action). * * Parameters: * tile - {<OpenLayers.Tile>} */ addTileMonitoringHooks: function(tile) { tile.onLoadStart = function() { //if this is the the layer's current tile, then trigger // a 'loadstart' if (this == this.layer.tile) { this.layer.events.triggerEvent("loadstart"); } }; tile.events.register("loadstart", tile, tile.onLoadStart); tile.onLoadEnd = function() { //if this is the the layer's current tile, then trigger // a 'tileloaded' and 'loadend' if (this == this.layer.tile) { this.layer.events.triggerEvent("tileloaded"); this.layer.events.triggerEvent("loadend"); } }; tile.events.register("loadend", tile, tile.onLoadEnd); }, /** * Method: removeTileMonitoringHooks * This function takes a tile as input and removes the tile hooks * that were added in addTileMonitoringHooks() * * Parameters: * tile - {<OpenLayers.Tile>} */ removeTileMonitoringHooks: function(tile) { tile.events.unregister("loadstart", tile, tile.onLoadStart); tile.events.unregister("loadend", tile, tile.onLoadEnd); }, /** * Method: onMapResize * Call the onMapResize method of the appropriate parent class. */ onMapResize: function() { if(this.vectorMode) { OpenLayers.Layer.Vector.prototype.onMapResize.apply(this, arguments); } else { OpenLayers.Layer.Markers.prototype.onMapResize.apply(this, arguments); } }, /** * APIMethod: mergeNewParams * Modify parameters for the layer and redraw. * * Parameters: * newParams - {Object} */ mergeNewParams:function(newParams) { var upperParams = OpenLayers.Util.upperCaseObject(newParams); var newArguments = [upperParams]; OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, newArguments); }, /** * APIMethod: clone * * Parameters: * obj - {Object} * * Returns: * {<OpenLayers.Layer.WFS>} An exact clone of this OpenLayers.Layer.WFS */ clone: function (obj) { if (obj == null) { obj = new OpenLayers.Layer.WFS(this.name, this.url, this.params, this.options); } //get all additions from superclasses if (this.vectorMode) { obj = OpenLayers.Layer.Vector.prototype.clone.apply(this, [obj]); } else { obj = OpenLayers.Layer.Markers.prototype.clone.apply(this, [obj]); } // copy/set any non-init, non-simple values here return obj; }, /** * APIMethod: getFullRequestString * combine the layer's url with its params and these newParams. * * Add the SRS parameter from 'projection' -- this is probably * more eloquently done via a setProjection() method, but this * works for now and always. * * Parameters: * newParams - {Object} */ getFullRequestString:function(newParams) { var projection = this.map.getProjection(); this.params.SRS = (projection == "none") ? null : projection; return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( this, arguments); }, /** * APIMethod: commit * Write out the data to a WFS server. */ commit: function() { if (!this.writer) { this.writer = new OpenLayers.Format.WFS({},this); } var data = this.writer.write(this.features); var url = this.url; if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(this.url, "http")) { url = OpenLayers.ProxyHost + escape(this.url); } var success = OpenLayers.Function.bind(this.commitSuccess, this); var failure = OpenLayers.Function.bind(this.commitFailure, this); data = OpenLayers.Ajax.serializeXMLToString(data); // from prototype.js new OpenLayers.Ajax.Request(url, { method: 'post', postBody: data, onComplete: success, onFailure: failure } ); }, /** * Method: commitSuccess * Called when the Ajax request returns a response * * Parameters: * response - {XmlNode} from server */ commitSuccess: function(request) { var response = request.responseText; if (response.indexOf('SUCCESS') != -1) { this.commitReport('WFS Transaction: SUCCESS', response); for(var i = 0; i < this.features.length; i++) { this.features[i].state = null; } // TBD redraw the layer or reset the state of features // foreach features: set state to null } else if (response.indexOf('FAILED') != -1 || response.indexOf('Exception') != -1) { this.commitReport('WFS Transaction: FAILED', response); } }, /** * Method: commitFailure * Called when the Ajax request fails * * Parameters: * response - {XmlNode} from server */ commitFailure: function(request) {}, /** * APIMethod: commitReport * Called with a 'success' message if the commit succeeded, otherwise * a failure message, and the full request text as a second parameter. * Override this function to provide custom transaction reporting. * * string - {String} reporting string * response - {String} full XML response */ commitReport: function(string, response) { alert(string); }, /** * APIMethod: refresh * Refreshes all the features of the layer */ refresh: function() { if (this.tile) { if (this.vectorMode) { this.renderer.clear(); this.features.length = 0; } else { this.clearMarkers(); this.markers.length = 0; } this.tile.draw(); } }, CLASS_NAME: "OpenLayers.Layer.WFS"});
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -