Transformed
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
goog.provide('ol.featureloader');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.format.FormatType');
|
||||
goog.require('ol.xml');
|
||||
/**
|
||||
* @module ol/featureloader
|
||||
*/
|
||||
import _ol_ from './index.js';
|
||||
import _ol_format_FormatType_ from './format/FormatType.js';
|
||||
import _ol_xml_ from './xml.js';
|
||||
var _ol_featureloader_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,7 +18,7 @@ goog.require('ol.xml');
|
||||
* source as `this`.
|
||||
* @return {ol.FeatureLoader} The feature loader.
|
||||
*/
|
||||
ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
_ol_featureloader_.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
return (
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
@@ -29,7 +31,7 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
xhr.open('GET',
|
||||
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
||||
true);
|
||||
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
|
||||
if (format.getType() == _ol_format_FormatType_.ARRAY_BUFFER) {
|
||||
xhr.responseType = 'arraybuffer';
|
||||
}
|
||||
/**
|
||||
@@ -42,15 +44,15 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
var type = format.getType();
|
||||
/** @type {Document|Node|Object|string|undefined} */
|
||||
var source;
|
||||
if (type == ol.format.FormatType.JSON ||
|
||||
type == ol.format.FormatType.TEXT) {
|
||||
if (type == _ol_format_FormatType_.JSON ||
|
||||
type == _ol_format_FormatType_.TEXT) {
|
||||
source = xhr.responseText;
|
||||
} else if (type == ol.format.FormatType.XML) {
|
||||
} else if (type == _ol_format_FormatType_.XML) {
|
||||
source = xhr.responseXML;
|
||||
if (!source) {
|
||||
source = ol.xml.parse(xhr.responseText);
|
||||
source = _ol_xml_.parse(xhr.responseText);
|
||||
}
|
||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||
} else if (type == _ol_format_FormatType_.ARRAY_BUFFER) {
|
||||
source = /** @type {ArrayBuffer} */ (xhr.response);
|
||||
}
|
||||
if (source) {
|
||||
@@ -71,7 +73,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
failure.call(this);
|
||||
}.bind(this);
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -84,8 +87,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
||||
* @return {ol.FeatureLoader} The feature loader.
|
||||
* @api
|
||||
*/
|
||||
ol.featureloader.xhr = function(url, format) {
|
||||
return ol.featureloader.loadFeaturesXhr(url, format,
|
||||
_ol_featureloader_.xhr = function(url, format) {
|
||||
return _ol_featureloader_.loadFeaturesXhr(url, format,
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features The loaded features.
|
||||
* @param {ol.proj.Projection} dataProjection Data projection.
|
||||
@@ -93,5 +96,6 @@ ol.featureloader.xhr = function(url, format) {
|
||||
*/
|
||||
function(features, dataProjection) {
|
||||
this.addFeatures(features);
|
||||
}, /* FIXME handle error */ ol.nullFunction);
|
||||
}, /* FIXME handle error */ _ol_.nullFunction);
|
||||
};
|
||||
export default _ol_featureloader_;
|
||||
|
||||
Reference in New Issue
Block a user