Remove goog.net.* and goog.async.AnimationDelay
This commit is contained in:
@@ -3,10 +3,6 @@ goog.provide('ol.FeatureUrlFunction');
|
||||
goog.provide('ol.featureloader');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.events');
|
||||
goog.require('goog.net.EventType');
|
||||
goog.require('goog.net.XhrIo');
|
||||
goog.require('goog.net.XhrIo.ResponseType');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.VectorTile');
|
||||
goog.require('ol.format.FormatType');
|
||||
@@ -67,59 +63,46 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
* @this {ol.source.Vector|ol.VectorTile}
|
||||
*/
|
||||
function(extent, resolution, projection) {
|
||||
var xhrIo = new goog.net.XhrIo();
|
||||
xhrIo.setResponseType(
|
||||
format.getType() == ol.format.FormatType.ARRAY_BUFFER ?
|
||||
goog.net.XhrIo.ResponseType.ARRAY_BUFFER :
|
||||
goog.net.XhrIo.ResponseType.TEXT);
|
||||
ol.events.listen(xhrIo, goog.net.EventType.COMPLETE,
|
||||
/**
|
||||
* @param {Event} event Event.
|
||||
* @private
|
||||
* @this {ol.source.Vector}
|
||||
*/
|
||||
function(event) {
|
||||
var xhrIo = event.target;
|
||||
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo,
|
||||
'event.target/xhrIo is an instance of goog.net.XhrIo');
|
||||
if (xhrIo.isSuccess()) {
|
||||
var type = format.getType();
|
||||
/** @type {Document|Node|Object|string|undefined} */
|
||||
var source;
|
||||
if (type == ol.format.FormatType.JSON) {
|
||||
source = xhrIo.getResponseText();
|
||||
} else if (type == ol.format.FormatType.TEXT) {
|
||||
source = xhrIo.getResponseText();
|
||||
} else if (type == ol.format.FormatType.XML) {
|
||||
if (!goog.userAgent.IE) {
|
||||
source = xhrIo.getResponseXml();
|
||||
}
|
||||
if (!source) {
|
||||
source = ol.xml.parse(xhrIo.getResponseText());
|
||||
}
|
||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||
source = xhrIo.getResponse();
|
||||
} else {
|
||||
goog.asserts.fail('unexpected format type');
|
||||
}
|
||||
if (source) {
|
||||
success.call(this, format.readFeatures(source,
|
||||
{featureProjection: projection}),
|
||||
format.readProjection(source));
|
||||
} else {
|
||||
goog.asserts.fail('undefined or null source');
|
||||
}
|
||||
} else {
|
||||
failure.call(this);
|
||||
}
|
||||
goog.dispose(xhrIo);
|
||||
}, false, this);
|
||||
if (goog.isFunction(url)) {
|
||||
xhrIo.send(url(extent, resolution, projection));
|
||||
} else {
|
||||
xhrIo.send(url);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET',
|
||||
goog.isFunction(url) ? url(extent, resolution, projection) : url);
|
||||
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
|
||||
xhr.responseType = 'arraybuffer';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} event Event.
|
||||
* @private
|
||||
*/
|
||||
xhr.onload = function(event) {
|
||||
if (xhr.status < 400) {
|
||||
var type = format.getType();
|
||||
/** @type {Document|Node|Object|string|undefined} */
|
||||
var source;
|
||||
if (type == ol.format.FormatType.JSON ||
|
||||
type == ol.format.FormatType.TEXT) {
|
||||
source = /** @type {string} */ (xhr.responseText);
|
||||
} else if (type == ol.format.FormatType.XML) {
|
||||
source = xhr.responseXML;
|
||||
if (!source) {
|
||||
source = ol.xml.parse(xhr.responseText);
|
||||
}
|
||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||
source = /** @type {ArrayBuffer} */ (xhr.response);
|
||||
} else {
|
||||
goog.asserts.fail('unexpected format type');
|
||||
}
|
||||
if (source) {
|
||||
success.call(this, format.readFeatures(source,
|
||||
{featureProjection: projection}),
|
||||
format.readProjection(source));
|
||||
} else {
|
||||
goog.asserts.fail('undefined or null source');
|
||||
}
|
||||
} else {
|
||||
failure.call(this);
|
||||
}
|
||||
}.bind(this);
|
||||
xhr.send();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user