Remove olx.source.VectorOptions

This commit is contained in:
Florent gravin
2018-03-29 09:46:08 +02:00
parent 910373eaa2
commit 798119c9c8
2 changed files with 87 additions and 156 deletions

View File

@@ -48,6 +48,92 @@ export const VectorSourceEvent = function(type, opt_feature) {
inherits(VectorSourceEvent, Event);
/**
* @typedef {Object} Options
* @property {ol.AttributionLike} [attributions] Attributions.
* @property {Array.<module:ol/Feature~Feature>|ol.Collection.<module:ol/Feature~Feature>} [features]
* Features. If provided as {@link ol.Collection}, the features in the source
* and the collection will stay in sync.
* @property {ol.format.Feature} [format=undefined] The feature format used by the XHR
* feature loader when `url` is set. Required if `url` is set, otherwise ignored.
* @property {module:ol/Feature~FeatureLoader} [loader]
* The loader function used to load features, from a remote source for example.
* If this is not set and `url` is set, the source will create and use an XHR
* feature loader.
*
* Example:
*
* ```js
* var vectorSource = new ol.source.Vector({
* format: new ol.format.GeoJSON(),
* loader: function(extent, resolution, projection) {
* var proj = projection.getCode();
* var url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
* 'outputFormat=application/json&srsname=' + proj + '&' +
* 'bbox=' + extent.join(',') + ',' + proj;
* var xhr = new XMLHttpRequest();
* xhr.open('GET', url);
* var onError = function() {
* vectorSource.removeLoadedExtent(extent);
* }
* xhr.onerror = onError;
* xhr.onload = function() {
* if (xhr.status == 200) {
* vectorSource.addFeatures(
* vectorSource.getFormat().readFeatures(xhr.responseText));
* } else {
* onError();
* }
* }
* xhr.send();
* },
* strategy: ol.loadingstrategy.bbox
* });
* ```
* @property {boolean} [overlaps=true] This source may have overlapping geometries.
* Setting this to `false` (e.g. for sources with polygons that represent administrative
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
* stroke operations.
* @property {ol.LoadingStrategy} [strategy] The loading strategy to use.
* By default an {@link ol.loadingstrategy.all}
* strategy is used, a one-off strategy which loads all features at once.
* @property {string|module:ol/Feature~FeatureUrlFunction} [url]
* Setting this option instructs the source to load features using an XHR loader
* (see {@link ol.featureloader.xhr}). Use a `string` and an
* {@link ol.loadingstrategy.all} for a one-off download of all features from
* the given URL. Use a {@link module:ol/Feature~FeatureUrlFunction} to generate the url with
* other loading strategies.
* Requires `format` to be set as well.
* When default XHR feature loader is provided, the features will
* be transformed from the data projection to the view projection
* during parsing. If your remote data source does not advertise its projection
* properly, this transformation will be incorrect. For some formats, the
* default projection (usually EPSG:4326) can be overridden by setting the
* defaultDataProjection constructor option on the format.
* Note that if a source contains non-feature data, such as a GeoJSON geometry
* or a KML NetworkLink, these will be ignored. Use a custom loader to load these.
* @property {boolean} [useSpatialIndex=true]
* By default, an RTree is used as spatial index. When features are removed and
* added frequently, and the total number of features is low, setting this to
* `false` may improve performance.
*
* Note that
* {@link ol.source.Vector#getFeaturesInExtent},
* {@link ol.source.Vector#getClosestFeatureToCoordinate} and
* {@link ol.source.Vector#getExtent} cannot be used when `useSpatialIndex` is
* set to `false`, and {@link ol.source.Vector#forEachFeatureInExtent} will loop
* through all features.
*
* When set to `false`, the features will be maintained in an
* {@link ol.Collection}, which can be retrieved through
* {@link ol.source.Vector#getFeaturesCollection}.
* @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the
* -180° and 180° meridians to work properly, this should be set to `false`. The
* resulting geometry coordinates will then exceed the world bounds.
*/
/**
* @classdesc
* Provides a source of features for vector layers. Vector features provided
@@ -57,7 +143,7 @@ inherits(VectorSourceEvent, Event);
* @constructor
* @extends {ol.source.Source}
* @fires ol.source.Vector.Event
* @param {olx.source.VectorOptions=} opt_options Vector source options.
* @param {module:ol/source/Vector~Options=} opt_options Vector source options.
* @api
*/
const VectorSource = function(opt_options) {