move Layer.GML into deprecated.js
This commit is contained in:
@@ -249,7 +249,6 @@
|
||||
"OpenLayers/Protocol/SOS.js",
|
||||
"OpenLayers/Protocol/SOS/v1_0_0.js",
|
||||
"OpenLayers/Layer/PointTrack.js",
|
||||
"OpenLayers/Layer/GML.js",
|
||||
"OpenLayers/Style.js",
|
||||
"OpenLayers/Style2.js",
|
||||
"OpenLayers/StyleMap.js",
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Layer/Vector.js
|
||||
* @requires OpenLayers/Request/XMLHttpRequest.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.GML
|
||||
* Create a vector layer by parsing a GML file. The GML file is
|
||||
* passed in as a parameter.
|
||||
* *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.Vector
|
||||
* with Protocol.HTTP and Strategy.Fixed. Provide the protocol with a
|
||||
* format parameter to get the parser you want for your data.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.Vector>
|
||||
*/
|
||||
OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
||||
|
||||
/**
|
||||
* Property: loaded
|
||||
* {Boolean} Flag for whether the GML data has been loaded yet.
|
||||
*/
|
||||
loaded: false,
|
||||
|
||||
/**
|
||||
* APIProperty: format
|
||||
* {<OpenLayers.Format>} The format you want the data to be parsed with.
|
||||
*/
|
||||
format: null,
|
||||
|
||||
/**
|
||||
* APIProperty: formatOptions
|
||||
* {Object} Hash of options which should be passed to the format when it is
|
||||
* created. Must be passed in the constructor.
|
||||
*/
|
||||
formatOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.GML
|
||||
* Load and parse a single file on the web, according to the format
|
||||
* provided via the 'format' option, defaulting to GML.
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String}
|
||||
* url - {String} URL of a GML file.
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer.
|
||||
*/
|
||||
initialize: function(name, url, options) {
|
||||
var newArguments = [];
|
||||
newArguments.push(name, options);
|
||||
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: setVisibility
|
||||
* Set the visibility flag for the layer and hide/show&redraw accordingly.
|
||||
* Fire event unless otherwise specified
|
||||
* GML will be loaded if the layer is being made visible for the first
|
||||
* time.
|
||||
*
|
||||
* Parameters:
|
||||
* visible - {Boolean} Whether or not to display the layer
|
||||
* (if in range)
|
||||
* noEvent - {Boolean}
|
||||
*/
|
||||
setVisibility: function(visibility, noEvent) {
|
||||
OpenLayers.Layer.Vector.prototype.setVisibility.apply(this, arguments);
|
||||
if(this.visibility && !this.loaded){
|
||||
// Load the GML
|
||||
this.loadGML();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveTo
|
||||
* If layer is visible and GML has not been loaded, load GML, then load GML
|
||||
* and call OpenLayers.Layer.Vector.moveTo() to redraw at the new location.
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {Object}
|
||||
* zoomChanged - {Object}
|
||||
* minor - {Object}
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);
|
||||
// Wait until initialisation is complete before loading GML
|
||||
// otherwise we can get a race condition where the root HTML DOM is
|
||||
// loaded after the GML is paited.
|
||||
// See http://trac.openlayers.org/ticket/404
|
||||
if(this.visibility && !this.loaded){
|
||||
this.loadGML();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: loadGML
|
||||
*/
|
||||
loadGML: function() {
|
||||
if (!this.loaded) {
|
||||
this.events.triggerEvent("loadstart");
|
||||
OpenLayers.Request.GET({
|
||||
url: this.url,
|
||||
success: this.requestSuccess,
|
||||
failure: this.requestFailure,
|
||||
scope: this
|
||||
});
|
||||
this.loaded = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setUrl
|
||||
* Change the URL and reload the GML
|
||||
*
|
||||
* Parameters:
|
||||
* url - {String} URL of a GML file.
|
||||
*/
|
||||
setUrl:function(url) {
|
||||
this.url = url;
|
||||
this.destroyFeatures();
|
||||
this.loaded = false;
|
||||
this.loadGML();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: requestSuccess
|
||||
* Process GML after it has been loaded.
|
||||
* Called by initialize() and loadUrl() after the GML has been loaded.
|
||||
*
|
||||
* Parameters:
|
||||
* request - {String}
|
||||
*/
|
||||
requestSuccess:function(request) {
|
||||
var doc = request.responseXML;
|
||||
|
||||
if (!doc || !doc.documentElement) {
|
||||
doc = request.responseText;
|
||||
}
|
||||
|
||||
var options = {};
|
||||
|
||||
OpenLayers.Util.extend(options, this.formatOptions);
|
||||
if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
|
||||
options.externalProjection = this.projection;
|
||||
options.internalProjection = this.map.getProjectionObject();
|
||||
}
|
||||
|
||||
var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
|
||||
this.addFeatures(gml.read(doc));
|
||||
this.events.triggerEvent("loadend");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: requestFailure
|
||||
* Process a failed loading of GML.
|
||||
* Called by initialize() and loadUrl() if there was a problem loading GML.
|
||||
*
|
||||
* Parameters:
|
||||
* request - {String}
|
||||
*/
|
||||
requestFailure: function(request) {
|
||||
OpenLayers.Console.userError('Error in loading GML file ' + this.url);
|
||||
this.events.triggerEvent("loadend");
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.GML"
|
||||
});
|
||||
@@ -4008,3 +4008,167 @@ OpenLayers.Layer.Yahoo = OpenLayers.Class(
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.Yahoo"
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Layer.GML
|
||||
* Create a vector layer by parsing a GML file. The GML file is
|
||||
* passed in as a parameter.
|
||||
* *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.Vector
|
||||
* with Protocol.HTTP and Strategy.Fixed. Provide the protocol with a
|
||||
* format parameter to get the parser you want for your data.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Layer.Vector>
|
||||
*/
|
||||
OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
||||
|
||||
/**
|
||||
* Property: loaded
|
||||
* {Boolean} Flag for whether the GML data has been loaded yet.
|
||||
*/
|
||||
loaded: false,
|
||||
|
||||
/**
|
||||
* APIProperty: format
|
||||
* {<OpenLayers.Format>} The format you want the data to be parsed with.
|
||||
*/
|
||||
format: null,
|
||||
|
||||
/**
|
||||
* APIProperty: formatOptions
|
||||
* {Object} Hash of options which should be passed to the format when it is
|
||||
* created. Must be passed in the constructor.
|
||||
*/
|
||||
formatOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Layer.GML
|
||||
* Load and parse a single file on the web, according to the format
|
||||
* provided via the 'format' option, defaulting to GML.
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String}
|
||||
* url - {String} URL of a GML file.
|
||||
* options - {Object} Hashtable of extra options to tag onto the layer.
|
||||
*/
|
||||
initialize: function(name, url, options) {
|
||||
var newArguments = [];
|
||||
newArguments.push(name, options);
|
||||
OpenLayers.Layer.Vector.prototype.initialize.apply(this, newArguments);
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: setVisibility
|
||||
* Set the visibility flag for the layer and hide/show&redraw accordingly.
|
||||
* Fire event unless otherwise specified
|
||||
* GML will be loaded if the layer is being made visible for the first
|
||||
* time.
|
||||
*
|
||||
* Parameters:
|
||||
* visible - {Boolean} Whether or not to display the layer
|
||||
* (if in range)
|
||||
* noEvent - {Boolean}
|
||||
*/
|
||||
setVisibility: function(visibility, noEvent) {
|
||||
OpenLayers.Layer.Vector.prototype.setVisibility.apply(this, arguments);
|
||||
if(this.visibility && !this.loaded){
|
||||
// Load the GML
|
||||
this.loadGML();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveTo
|
||||
* If layer is visible and GML has not been loaded, load GML, then load GML
|
||||
* and call OpenLayers.Layer.Vector.moveTo() to redraw at the new location.
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {Object}
|
||||
* zoomChanged - {Object}
|
||||
* minor - {Object}
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
OpenLayers.Layer.Vector.prototype.moveTo.apply(this, arguments);
|
||||
// Wait until initialisation is complete before loading GML
|
||||
// otherwise we can get a race condition where the root HTML DOM is
|
||||
// loaded after the GML is paited.
|
||||
// See http://trac.openlayers.org/ticket/404
|
||||
if(this.visibility && !this.loaded){
|
||||
this.loadGML();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: loadGML
|
||||
*/
|
||||
loadGML: function() {
|
||||
if (!this.loaded) {
|
||||
this.events.triggerEvent("loadstart");
|
||||
OpenLayers.Request.GET({
|
||||
url: this.url,
|
||||
success: this.requestSuccess,
|
||||
failure: this.requestFailure,
|
||||
scope: this
|
||||
});
|
||||
this.loaded = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setUrl
|
||||
* Change the URL and reload the GML
|
||||
*
|
||||
* Parameters:
|
||||
* url - {String} URL of a GML file.
|
||||
*/
|
||||
setUrl:function(url) {
|
||||
this.url = url;
|
||||
this.destroyFeatures();
|
||||
this.loaded = false;
|
||||
this.loadGML();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: requestSuccess
|
||||
* Process GML after it has been loaded.
|
||||
* Called by initialize() and loadUrl() after the GML has been loaded.
|
||||
*
|
||||
* Parameters:
|
||||
* request - {String}
|
||||
*/
|
||||
requestSuccess:function(request) {
|
||||
var doc = request.responseXML;
|
||||
|
||||
if (!doc || !doc.documentElement) {
|
||||
doc = request.responseText;
|
||||
}
|
||||
|
||||
var options = {};
|
||||
|
||||
OpenLayers.Util.extend(options, this.formatOptions);
|
||||
if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
|
||||
options.externalProjection = this.projection;
|
||||
options.internalProjection = this.map.getProjectionObject();
|
||||
}
|
||||
|
||||
var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
|
||||
this.addFeatures(gml.read(doc));
|
||||
this.events.triggerEvent("loadend");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: requestFailure
|
||||
* Process a failed loading of GML.
|
||||
* Called by initialize() and loadUrl() if there was a problem loading GML.
|
||||
*
|
||||
* Parameters:
|
||||
* request - {String}
|
||||
*/
|
||||
requestFailure: function(request) {
|
||||
OpenLayers.Console.userError('Error in loading GML file ' + this.url);
|
||||
this.events.triggerEvent("loadend");
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.GML"
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var name = "GML Layer";
|
||||
@@ -148,7 +148,6 @@
|
||||
<li>Layer/EventPane.html</li>
|
||||
<li>Layer/FixedZoomLevels.html</li>
|
||||
<li>Layer/GeoRSS.html</li>
|
||||
<li>Layer/GML.html</li>
|
||||
<li>Layer/Google.html</li>
|
||||
<li>Layer/Google/v3.html</li>
|
||||
<li>Layer/Grid.html</li>
|
||||
@@ -226,6 +225,7 @@
|
||||
<li>deprecated/BaseTypes/Class.html</li>
|
||||
<li>deprecated/BaseTypes/Element.html</li>
|
||||
<li>deprecated/Control/MouseToolbar.html</li>
|
||||
<li>deprecated/Layer/GML.html</li>
|
||||
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
||||
<li>deprecated/Layer/MultiMap.html</li>
|
||||
<li>deprecated/Layer/WFS.html</li>
|
||||
|
||||
Reference in New Issue
Block a user