ol-wfst 4.0.6 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +790 -782
- package/dist/Geoserver.d.ts +15 -15
- package/dist/Geoserver.d.ts.map +1 -1
- package/dist/WfsLayer.d.ts +10 -10
- package/dist/WfsLayer.d.ts.map +1 -1
- package/dist/WmsLayer.d.ts +11 -11
- package/dist/WmsLayer.d.ts.map +1 -1
- package/dist/modules/EditControlChanges.d.ts +9 -9
- package/dist/modules/EditControlChanges.d.ts.map +1 -1
- package/dist/modules/EditFieldsModal.d.ts +3 -2
- package/dist/modules/EditFieldsModal.d.ts.map +1 -1
- package/dist/modules/EditOverlay.d.ts +4 -3
- package/dist/modules/EditOverlay.d.ts.map +1 -1
- package/dist/modules/LayersControl.d.ts +2 -3
- package/dist/modules/LayersControl.d.ts.map +1 -1
- package/dist/modules/Uploads.d.ts +6 -3
- package/dist/modules/Uploads.d.ts.map +1 -1
- package/dist/modules/base/BaseLayer.d.ts +4 -4
- package/dist/modules/base/BaseLayer.d.ts.map +1 -1
- package/dist/modules/base/WfsSource.d.ts +1 -1
- package/dist/modules/base/WfsSource.d.ts.map +1 -1
- package/dist/modules/base/WmsSource.d.ts +1 -1
- package/dist/modules/base/WmsSource.d.ts.map +1 -1
- package/dist/modules/editLayer.d.ts +2 -2
- package/dist/modules/editLayer.d.ts.map +1 -1
- package/dist/modules/state.d.ts +2 -2
- package/dist/modules/state.d.ts.map +1 -1
- package/dist/modules/styleFunction.d.ts +3 -3
- package/dist/modules/styleFunction.d.ts.map +1 -1
- package/dist/ol-wfst.d.ts +20 -20
- package/dist/ol-wfst.d.ts.map +1 -1
- package/dist/ol-wfst.js +321 -2105
- package/dist/ol-wfst.js.map +1 -1
- package/dist/ol-wfst.min.js +1 -1
- package/dist/ol-wfst.min.js.map +1 -1
- package/lib/Geoserver.d.ts +15 -15
- package/lib/Geoserver.d.ts.map +1 -1
- package/lib/WfsLayer.d.ts +10 -10
- package/lib/WfsLayer.d.ts.map +1 -1
- package/lib/WmsLayer.d.ts +11 -11
- package/lib/WmsLayer.d.ts.map +1 -1
- package/lib/modules/EditControlChanges.d.ts +9 -9
- package/lib/modules/EditControlChanges.d.ts.map +1 -1
- package/lib/modules/EditFieldsModal.d.ts +3 -2
- package/lib/modules/EditFieldsModal.d.ts.map +1 -1
- package/lib/modules/EditOverlay.d.ts +4 -3
- package/lib/modules/EditOverlay.d.ts.map +1 -1
- package/lib/modules/LayersControl.d.ts +2 -3
- package/lib/modules/LayersControl.d.ts.map +1 -1
- package/lib/modules/Uploads.d.ts +6 -3
- package/lib/modules/Uploads.d.ts.map +1 -1
- package/lib/modules/base/BaseLayer.d.ts +4 -4
- package/lib/modules/base/BaseLayer.d.ts.map +1 -1
- package/lib/modules/base/WfsSource.d.ts +1 -1
- package/lib/modules/base/WfsSource.d.ts.map +1 -1
- package/lib/modules/base/WmsSource.d.ts +1 -1
- package/lib/modules/base/WmsSource.d.ts.map +1 -1
- package/lib/modules/editLayer.d.ts +2 -2
- package/lib/modules/editLayer.d.ts.map +1 -1
- package/lib/modules/state.d.ts +2 -2
- package/lib/modules/state.d.ts.map +1 -1
- package/lib/modules/styleFunction.d.ts +3 -3
- package/lib/modules/styleFunction.d.ts.map +1 -1
- package/lib/ol-wfst.d.ts +20 -20
- package/lib/ol-wfst.d.ts.map +1 -1
- package/lib/ol-wfst.js +81 -196
- package/lib/ol-wfst.js.map +1 -1
- package/package.json +5 -5
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/dist/ol-wfst.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/style/Circle'), require('ol/style/Fill'), require('ol/style/Stroke'), require('ol/style/Style'), require('ol/control/Control'), require('ol/interaction/Draw'), require('ol/interaction/Modify'), require('ol/interaction/Select'), require('ol/interaction/Snap'), require('ol/Collection'), require('ol/events/Event'), require('ol/events/condition'), require('ol/Observable'), require('ol/layer/Vector'), require('ol/layer/Base'), require('ol/format/GeoJSON'), require('ol/source/Vector'), require('ol/proj'), require('ol/loadingstrategy'), require('ol/layer/Tile'), require('ol/source/TileWMS'), require('ol/geom'), require('ol/format'), require('ol/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['ol/style/Circle', 'ol/style/Fill', 'ol/style/Stroke', 'ol/style/Style', 'ol/control/Control', 'ol/interaction/Draw', 'ol/interaction/Modify', 'ol/interaction/Select', 'ol/interaction/Snap', 'ol/Collection', 'ol/events/Event', 'ol/events/condition', 'ol/Observable', 'ol/layer/Vector', 'ol/layer/Base', 'ol/format/GeoJSON', 'ol/source/Vector', 'ol/proj', 'ol/loadingstrategy', 'ol/layer/Tile', 'ol/source/TileWMS', 'ol/geom', 'ol/format', 'ol/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Wfst = factory(global.ol.style.Circle, global.ol.style.Fill, global.ol.style.Stroke, global.ol.style.Style, global.ol.control.Control, global.ol.interaction.Draw, global.ol.interaction.Modify, global.ol.interaction.Select, global.ol.interaction.Snap, global.ol.Collection, global.ol.events.Event, global.ol.events.condition, global.ol.Observable, global.ol.layer.Vector, global.ol.layer.Base, global.ol.format.GeoJSON, global.ol.source.Vector, global.ol.proj, global.ol.loadingstrategy, global.ol.layer.Tile, global.ol.source.TileWMS, global.ol.geom, global.ol.format, global.ol.
|
|
5
|
-
})(this, (function (CircleStyle, Fill, Stroke, Style, Control, Draw, Modify, Select, Snap, Collection, BaseEvent
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/style/Circle.js'), require('ol/style/Fill.js'), require('ol/style/Stroke.js'), require('ol/style/Style.js'), require('ol/control/Control.js'), require('ol/interaction/Draw.js'), require('ol/interaction/Modify.js'), require('ol/interaction/Select.js'), require('ol/interaction/Snap.js'), require('ol/Collection.js'), require('ol/events/Event.js'), require('ol/events/condition.js'), require('ol/Observable.js'), require('ol/layer/Vector.js'), require('ol/layer/Base.js'), require('ol/format/GeoJSON.js'), require('ol/source/Vector.js'), require('ol/proj.js'), require('ol/loadingstrategy.js'), require('ol/layer/Tile.js'), require('ol/source/TileWMS.js'), require('ol/geom.js'), require('ol/format/KML.js'), require('ol/format/WFS.js'), require('ol/style.js'), require('ol/Object.js'), require('ol/geom/Circle.js'), require('ol/geom/GeometryCollection.js'), require('ol/Feature.js'), require('ol/geom/Polygon.js'), require('ol/extent.js'), require('ol/Overlay.js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['ol/style/Circle.js', 'ol/style/Fill.js', 'ol/style/Stroke.js', 'ol/style/Style.js', 'ol/control/Control.js', 'ol/interaction/Draw.js', 'ol/interaction/Modify.js', 'ol/interaction/Select.js', 'ol/interaction/Snap.js', 'ol/Collection.js', 'ol/events/Event.js', 'ol/events/condition.js', 'ol/Observable.js', 'ol/layer/Vector.js', 'ol/layer/Base.js', 'ol/format/GeoJSON.js', 'ol/source/Vector.js', 'ol/proj.js', 'ol/loadingstrategy.js', 'ol/layer/Tile.js', 'ol/source/TileWMS.js', 'ol/geom.js', 'ol/format/KML.js', 'ol/format/WFS.js', 'ol/style.js', 'ol/Object.js', 'ol/geom/Circle.js', 'ol/geom/GeometryCollection.js', 'ol/Feature.js', 'ol/geom/Polygon.js', 'ol/extent.js', 'ol/Overlay.js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Wfst = factory(global.ol.style.Circle, global.ol.style.Fill, global.ol.style.Stroke, global.ol.style.Style, global.ol.control.Control, global.ol.interaction.Draw, global.ol.interaction.Modify, global.ol.interaction.Select, global.ol.interaction.Snap, global.ol.Collection, global.ol.events.Event, global.ol.events.condition, global.ol.Observable, global.ol.layer.Vector, global.ol.layer.Base, global.ol.format.GeoJSON, global.ol.source.Vector, global.ol.proj, global.ol.loadingstrategy, global.ol.layer.Tile, global.ol.source.TileWMS, global.ol.geom, global.ol.format.KML, global.ol.format.WFS, global.ol.style, global.ol.Object, global.ol.geom.Circle, global.ol.geom.GeometryCollection, global.ol.Feature, global.ol.geom.Polygon, global.ol.extent, global.ol.Overlay));
|
|
5
|
+
})(this, (function (CircleStyle, Fill, Stroke, Style, Control, Draw, Modify, Select, Snap, Collection, BaseEvent, condition_js, Observable, VectorLayer, Layer, GeoJSON, VectorSource, proj_js, loadingstrategy_js, TileLayer, TileWMS, geom_js, KML, WFS, style_js, BaseObject, Circle, GeometryCollection, Feature, Polygon_js, extent_js, Overlay) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var domain;
|
|
8
8
|
|
|
@@ -1266,7 +1266,7 @@
|
|
|
1266
1266
|
}
|
|
1267
1267
|
// Check if customs translations are provided
|
|
1268
1268
|
if (customI18n) {
|
|
1269
|
-
I18N = {
|
|
1269
|
+
I18N = Object.assign(Object.assign({}, I18N), customI18n);
|
|
1270
1270
|
}
|
|
1271
1271
|
};
|
|
1272
1272
|
|
|
@@ -1657,21 +1657,12 @@
|
|
|
1657
1657
|
* @param options
|
|
1658
1658
|
*/
|
|
1659
1659
|
class WfsSource extends VectorSource {
|
|
1660
|
-
urlParams = new URLSearchParams({
|
|
1661
|
-
SERVICE: 'wfs',
|
|
1662
|
-
REQUEST: 'GetFeature',
|
|
1663
|
-
OUTPUTFORMAT: 'application/json',
|
|
1664
|
-
EXCEPTIONS: 'application/json'
|
|
1665
|
-
});
|
|
1666
1660
|
constructor(options) {
|
|
1667
|
-
super({
|
|
1668
|
-
...options,
|
|
1669
|
-
format: new GeoJSON(),
|
|
1670
|
-
loader: async (extent, resolution, projection, success, failure) => {
|
|
1661
|
+
super(Object.assign(Object.assign({}, options), { format: new GeoJSON(), loader: async (extent, resolution, projection, success, failure) => {
|
|
1671
1662
|
try {
|
|
1672
1663
|
// If bbox, add extent to the request
|
|
1673
|
-
if (options.strategy ==
|
|
1674
|
-
const extentGeoServer =
|
|
1664
|
+
if (options.strategy == loadingstrategy_js.bbox) {
|
|
1665
|
+
const extentGeoServer = proj_js.transformExtent(extent, projection.getCode(), options.geoServerAdvanced.projection);
|
|
1675
1666
|
// https://docs.geoserver.org/stable/en/user/services/wfs/reference.html
|
|
1676
1667
|
// request features using a bounding box with CRS maybe different from featureTypes native CRS
|
|
1677
1668
|
this.urlParams.set('bbox', extentGeoServer.toString() +
|
|
@@ -1705,7 +1696,12 @@
|
|
|
1705
1696
|
showError(I18N.errors.geoserver, err, options.name);
|
|
1706
1697
|
failure();
|
|
1707
1698
|
}
|
|
1708
|
-
}
|
|
1699
|
+
} }));
|
|
1700
|
+
this.urlParams = new URLSearchParams({
|
|
1701
|
+
SERVICE: 'wfs',
|
|
1702
|
+
REQUEST: 'GetFeature',
|
|
1703
|
+
OUTPUTFORMAT: 'application/json',
|
|
1704
|
+
EXCEPTIONS: 'application/json'
|
|
1709
1705
|
});
|
|
1710
1706
|
this.urlParams.set('version', options.geoServerAdvanced.getFeatureVersion);
|
|
1711
1707
|
this.urlParams.set('typename', options.name);
|
|
@@ -1722,201 +1718,24 @@
|
|
|
1722
1718
|
* @param options
|
|
1723
1719
|
*/
|
|
1724
1720
|
class WfsLayer extends Mixin(BaseLayer, (VectorLayer)) {
|
|
1725
|
-
_loadingCount = 0;
|
|
1726
|
-
_loadedCount = 0;
|
|
1727
|
-
beforeTransactFeature;
|
|
1728
1721
|
constructor(options) {
|
|
1729
|
-
super({
|
|
1730
|
-
name: options.name,
|
|
1731
|
-
label: options.label || options.name,
|
|
1732
|
-
minZoom: options.minZoom,
|
|
1733
|
-
...options
|
|
1734
|
-
});
|
|
1735
|
-
if (options.beforeTransactFeature) {
|
|
1736
|
-
this.beforeTransactFeature = options.beforeTransactFeature;
|
|
1737
|
-
}
|
|
1738
|
-
const geoserver = options.geoserver;
|
|
1739
|
-
const source = new WfsSource({
|
|
1740
|
-
name: options.name,
|
|
1741
|
-
geoserverUrl: geoserver.getUrl(),
|
|
1742
|
-
geoServerAdvanced: geoserver.getAdvanced(),
|
|
1743
|
-
...(options.strategy && { strategy: options.strategy }),
|
|
1744
|
-
geoserverVendor: options.geoserverVendor
|
|
1745
|
-
});
|
|
1722
|
+
super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
|
|
1746
1723
|
this._loadingCount = 0;
|
|
1747
1724
|
this._loadedCount = 0;
|
|
1748
|
-
source.on('featuresloadstart', () => {
|
|
1749
|
-
this._loadingCount++;
|
|
1750
|
-
if (this._loadingCount === 1 && this.isVisibleByZoom()) {
|
|
1751
|
-
showLoading();
|
|
1752
|
-
}
|
|
1753
|
-
});
|
|
1754
|
-
source.on(['featuresloadend', 'featuresloaderror'], () => {
|
|
1755
|
-
this._loadedCount++;
|
|
1756
|
-
if (this._loadingCount === this._loadedCount) {
|
|
1757
|
-
this._loadingCount = 0;
|
|
1758
|
-
this._loadedCount = 0;
|
|
1759
|
-
setTimeout(() => {
|
|
1760
|
-
this.dispatchEvent('layerRendered');
|
|
1761
|
-
}, 300);
|
|
1762
|
-
}
|
|
1763
|
-
});
|
|
1764
|
-
this.setSource(source);
|
|
1765
|
-
const geoserverOptions = options.geoserverVendor;
|
|
1766
|
-
Object.keys(geoserverOptions).forEach((param) => {
|
|
1767
|
-
source.urlParams.set(param, geoserverOptions[param]);
|
|
1768
|
-
});
|
|
1769
|
-
}
|
|
1770
|
-
/**
|
|
1771
|
-
* @public
|
|
1772
|
-
*/
|
|
1773
|
-
refresh() {
|
|
1774
|
-
const source = this.getSource();
|
|
1775
|
-
// Refrescamos el wms
|
|
1776
|
-
source.refresh();
|
|
1777
|
-
}
|
|
1778
|
-
/**
|
|
1779
|
-
* Use this to update Geoserver Wms Vendors (https://docs.geoserver.org/latest/en/user/services/wms/vendor.html)
|
|
1780
|
-
* and other arguements (https://docs.geoserver.org/stable/en/user/services/wms/reference.html#getmap)
|
|
1781
|
-
* in all the getMap requests.
|
|
1782
|
-
*
|
|
1783
|
-
* Example: you can use this to change the style of the WMS, add a custom sld, set a cql_filter, etc.
|
|
1784
|
-
*
|
|
1785
|
-
* @public
|
|
1786
|
-
* @param paramName
|
|
1787
|
-
* @param value Use `undefined` or `null` to remove the param
|
|
1788
|
-
* @param refresh
|
|
1789
|
-
*/
|
|
1790
|
-
setCustomParam(paramName, value = null, refresh = true) {
|
|
1791
|
-
const source = this.getSource();
|
|
1792
|
-
if (value === undefined || value === null) {
|
|
1793
|
-
source.urlParams.delete(paramName);
|
|
1794
|
-
}
|
|
1795
|
-
else {
|
|
1796
|
-
source.urlParams.set(paramName, value);
|
|
1797
|
-
}
|
|
1798
|
-
if (refresh) {
|
|
1799
|
-
this.refresh();
|
|
1800
|
-
}
|
|
1801
|
-
return source.urlParams;
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
/**
|
|
1806
|
-
* @module ol/TileState
|
|
1807
|
-
*/
|
|
1808
|
-
|
|
1809
|
-
/**
|
|
1810
|
-
* @enum {number}
|
|
1811
|
-
*/
|
|
1812
|
-
var TileState = {
|
|
1813
|
-
IDLE: 0,
|
|
1814
|
-
LOADING: 1,
|
|
1815
|
-
LOADED: 2,
|
|
1816
|
-
/**
|
|
1817
|
-
* Indicates that tile loading failed
|
|
1818
|
-
* @type {number}
|
|
1819
|
-
*/
|
|
1820
|
-
ERROR: 3,
|
|
1821
|
-
EMPTY: 4,
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
/**
|
|
1825
|
-
* Layer source to retrieve WMS information from geoservers
|
|
1826
|
-
* https://docs.geoserver.org/stable/en/user/services/wms/reference.html
|
|
1827
|
-
*
|
|
1828
|
-
* @extends {ol/source/TieWMS~TileWMS}
|
|
1829
|
-
* @param options
|
|
1830
|
-
*/
|
|
1831
|
-
class WmsSource extends TileWMS {
|
|
1832
|
-
constructor(options) {
|
|
1833
|
-
super({
|
|
1834
|
-
url: options.geoserverUrl,
|
|
1835
|
-
serverType: 'geoserver',
|
|
1836
|
-
params: {
|
|
1837
|
-
SERVICE: 'wms',
|
|
1838
|
-
TILED: true,
|
|
1839
|
-
LAYERS: options.name,
|
|
1840
|
-
EXCEPTIONS: 'application/json',
|
|
1841
|
-
...(options.geoserverVendor && options.geoserverVendor)
|
|
1842
|
-
},
|
|
1843
|
-
tileLoadFunction: async (tile, src) => {
|
|
1844
|
-
const blobToJson = (blob) => {
|
|
1845
|
-
return new Promise((resolve) => {
|
|
1846
|
-
const reader = new FileReader();
|
|
1847
|
-
reader.onloadend = () => resolve(JSON.parse(reader.result));
|
|
1848
|
-
reader.readAsText(blob);
|
|
1849
|
-
});
|
|
1850
|
-
};
|
|
1851
|
-
try {
|
|
1852
|
-
const response = await fetch(src, {
|
|
1853
|
-
headers: options.headers,
|
|
1854
|
-
credentials: options.credentials
|
|
1855
|
-
});
|
|
1856
|
-
if (!response.ok) {
|
|
1857
|
-
throw new Error('');
|
|
1858
|
-
}
|
|
1859
|
-
let data = await response.blob();
|
|
1860
|
-
// Check if the response has an error
|
|
1861
|
-
if (data.type == 'application/json') {
|
|
1862
|
-
const parsedError = await blobToJson(data);
|
|
1863
|
-
throw new Error(parseError(parsedError));
|
|
1864
|
-
}
|
|
1865
|
-
tile.getImage().src =
|
|
1866
|
-
URL.createObjectURL(data);
|
|
1867
|
-
tile.setState(TileState.LOADED);
|
|
1868
|
-
}
|
|
1869
|
-
catch (err) {
|
|
1870
|
-
showError(I18N.errors.geoserver, err, options.name);
|
|
1871
|
-
tile.setState(TileState.ERROR);
|
|
1872
|
-
}
|
|
1873
|
-
},
|
|
1874
|
-
...options
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
/**
|
|
1880
|
-
* Layer to retrieve WMS information from geoservers
|
|
1881
|
-
* https://docs.geoserver.org/stable/en/user/services/wms/reference.html
|
|
1882
|
-
*
|
|
1883
|
-
* @fires layerRendered
|
|
1884
|
-
* @extends {ol/layer/Tile~TileLayer}
|
|
1885
|
-
* @param options
|
|
1886
|
-
*/
|
|
1887
|
-
class WmsLayer extends Mixin(BaseLayer, (TileLayer)) {
|
|
1888
|
-
_loadingCount = 0;
|
|
1889
|
-
_loadedCount = 0;
|
|
1890
|
-
beforeTransactFeature;
|
|
1891
|
-
// Formats
|
|
1892
|
-
_formatGeoJSON;
|
|
1893
|
-
constructor(options) {
|
|
1894
|
-
super({
|
|
1895
|
-
name: options.name,
|
|
1896
|
-
label: options.label || options.name,
|
|
1897
|
-
minZoom: options.minZoom,
|
|
1898
|
-
...options
|
|
1899
|
-
});
|
|
1900
1725
|
if (options.beforeTransactFeature) {
|
|
1901
1726
|
this.beforeTransactFeature = options.beforeTransactFeature;
|
|
1902
1727
|
}
|
|
1903
|
-
this._formatGeoJSON = new GeoJSON();
|
|
1904
1728
|
const geoserver = options.geoserver;
|
|
1905
|
-
const source = new
|
|
1906
|
-
name: options.name,
|
|
1907
|
-
geoserverUrl: geoserver.getUrl(),
|
|
1908
|
-
geoServerAdvanced: geoserver.getAdvanced(),
|
|
1909
|
-
geoserverVendor: options.geoserverVendor
|
|
1910
|
-
});
|
|
1729
|
+
const source = new WfsSource(Object.assign(Object.assign({ name: options.name, geoserverUrl: geoserver.getUrl(), geoServerAdvanced: geoserver.getAdvanced() }, (options.strategy && { strategy: options.strategy })), { geoserverVendor: options.geoserverVendor }));
|
|
1911
1730
|
this._loadingCount = 0;
|
|
1912
1731
|
this._loadedCount = 0;
|
|
1913
|
-
source.on('
|
|
1732
|
+
source.on('featuresloadstart', () => {
|
|
1914
1733
|
this._loadingCount++;
|
|
1915
1734
|
if (this._loadingCount === 1 && this.isVisibleByZoom()) {
|
|
1916
1735
|
showLoading();
|
|
1917
1736
|
}
|
|
1918
1737
|
});
|
|
1919
|
-
source.on(['
|
|
1738
|
+
source.on(['featuresloadend', 'featuresloaderror'], () => {
|
|
1920
1739
|
this._loadedCount++;
|
|
1921
1740
|
if (this._loadingCount === this._loadedCount) {
|
|
1922
1741
|
this._loadingCount = 0;
|
|
@@ -1927,1756 +1746,237 @@
|
|
|
1927
1746
|
}
|
|
1928
1747
|
});
|
|
1929
1748
|
this.setSource(source);
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
const
|
|
1940
|
-
//
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
const
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
catch (err) {
|
|
1970
|
-
showError(err.message, err);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
/**
|
|
1974
|
-
* @public
|
|
1975
|
-
*/
|
|
1976
|
-
refresh() {
|
|
1977
|
-
const source = this.getSource();
|
|
1978
|
-
// Refrescamos el wms
|
|
1979
|
-
source.refresh();
|
|
1980
|
-
// Force refresh the tiles
|
|
1981
|
-
const params = source.getParams();
|
|
1982
|
-
params.t = new Date().getMilliseconds();
|
|
1983
|
-
source.updateParams(params);
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Use this to update Geoserver Wfs Vendors (https://docs.geoserver.org/latest/en/user/services/wfs/vendor.html)
|
|
1987
|
-
* and other arguements (https://docs.geoserver.org/stable/en/user/services/wfs/reference.html)
|
|
1988
|
-
* in all the getFeature requests.
|
|
1989
|
-
*
|
|
1990
|
-
* Example: you can use this to set a cql_filter, limit the numbers of features, etc.
|
|
1991
|
-
*
|
|
1992
|
-
* @public
|
|
1993
|
-
* @param paramName
|
|
1994
|
-
* @param value
|
|
1995
|
-
* @param refresh
|
|
1996
|
-
*/
|
|
1997
|
-
setCustomParam(paramName, value = null, refresh = true) {
|
|
1998
|
-
const source = this.getSource();
|
|
1999
|
-
source.updateParams({
|
|
2000
|
-
[paramName]: value
|
|
2001
|
-
});
|
|
2002
|
-
if (refresh) {
|
|
2003
|
-
this.refresh();
|
|
2004
|
-
}
|
|
2005
|
-
return source.getParams();
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
/**
|
|
2010
|
-
* @module ol/events/Event
|
|
2011
|
-
*/
|
|
2012
|
-
|
|
2013
|
-
/**
|
|
2014
|
-
* @classdesc
|
|
2015
|
-
* Stripped down implementation of the W3C DOM Level 2 Event interface.
|
|
2016
|
-
* See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.
|
|
2017
|
-
*
|
|
2018
|
-
* This implementation only provides `type` and `target` properties, and
|
|
2019
|
-
* `stopPropagation` and `preventDefault` methods. It is meant as base class
|
|
2020
|
-
* for higher level events defined in the library, and works with
|
|
2021
|
-
* {@link module:ol/events/Target~Target}.
|
|
2022
|
-
*/
|
|
2023
|
-
class BaseEvent {
|
|
2024
|
-
/**
|
|
2025
|
-
* @param {string} type Type.
|
|
2026
|
-
*/
|
|
2027
|
-
constructor(type) {
|
|
2028
|
-
/**
|
|
2029
|
-
* @type {boolean}
|
|
2030
|
-
*/
|
|
2031
|
-
this.propagationStopped;
|
|
2032
|
-
|
|
2033
|
-
/**
|
|
2034
|
-
* @type {boolean}
|
|
2035
|
-
*/
|
|
2036
|
-
this.defaultPrevented;
|
|
2037
|
-
|
|
2038
|
-
/**
|
|
2039
|
-
* The event type.
|
|
2040
|
-
* @type {string}
|
|
2041
|
-
* @api
|
|
2042
|
-
*/
|
|
2043
|
-
this.type = type;
|
|
2044
|
-
|
|
2045
|
-
/**
|
|
2046
|
-
* The event target.
|
|
2047
|
-
* @type {Object}
|
|
2048
|
-
* @api
|
|
2049
|
-
*/
|
|
2050
|
-
this.target = null;
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
/**
|
|
2054
|
-
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
|
|
2055
|
-
* will be fired.
|
|
2056
|
-
* @api
|
|
2057
|
-
*/
|
|
2058
|
-
preventDefault() {
|
|
2059
|
-
this.defaultPrevented = true;
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
/**
|
|
2063
|
-
* Stop event propagation.
|
|
2064
|
-
* @api
|
|
2065
|
-
*/
|
|
2066
|
-
stopPropagation() {
|
|
2067
|
-
this.propagationStopped = true;
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
var Event$1 = BaseEvent;
|
|
2072
|
-
|
|
2073
|
-
/**
|
|
2074
|
-
* @module ol/ObjectEventType
|
|
2075
|
-
*/
|
|
2076
|
-
|
|
2077
|
-
/**
|
|
2078
|
-
* @enum {string}
|
|
2079
|
-
*/
|
|
2080
|
-
var ObjectEventType = {
|
|
2081
|
-
/**
|
|
2082
|
-
* Triggered when a property is changed.
|
|
2083
|
-
* @event module:ol/Object.ObjectEvent#propertychange
|
|
2084
|
-
* @api
|
|
2085
|
-
*/
|
|
2086
|
-
PROPERTYCHANGE: 'propertychange',
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
/**
|
|
2090
|
-
* @typedef {'propertychange'} Types
|
|
2091
|
-
*/
|
|
2092
|
-
|
|
2093
|
-
/**
|
|
2094
|
-
* @module ol/Disposable
|
|
2095
|
-
*/
|
|
2096
|
-
|
|
2097
|
-
/**
|
|
2098
|
-
* @classdesc
|
|
2099
|
-
* Objects that need to clean up after themselves.
|
|
2100
|
-
*/
|
|
2101
|
-
class Disposable {
|
|
2102
|
-
constructor() {
|
|
2103
|
-
/**
|
|
2104
|
-
* The object has already been disposed.
|
|
2105
|
-
* @type {boolean}
|
|
2106
|
-
* @protected
|
|
2107
|
-
*/
|
|
2108
|
-
this.disposed = false;
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
/**
|
|
2112
|
-
* Clean up.
|
|
2113
|
-
*/
|
|
2114
|
-
dispose() {
|
|
2115
|
-
if (!this.disposed) {
|
|
2116
|
-
this.disposed = true;
|
|
2117
|
-
this.disposeInternal();
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
/**
|
|
2122
|
-
* Extension point for disposable objects.
|
|
2123
|
-
* @protected
|
|
2124
|
-
*/
|
|
2125
|
-
disposeInternal() {}
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
var Disposable$1 = Disposable;
|
|
2129
|
-
|
|
2130
|
-
/**
|
|
2131
|
-
* @module ol/functions
|
|
2132
|
-
*/
|
|
2133
|
-
|
|
2134
|
-
/**
|
|
2135
|
-
* A reusable function, used e.g. as a default for callbacks.
|
|
2136
|
-
*
|
|
2137
|
-
* @return {void} Nothing.
|
|
2138
|
-
*/
|
|
2139
|
-
function VOID() {}
|
|
2140
|
-
|
|
2141
|
-
/**
|
|
2142
|
-
* @module ol/obj
|
|
2143
|
-
*/
|
|
2144
|
-
|
|
2145
|
-
/**
|
|
2146
|
-
* Removes all properties from an object.
|
|
2147
|
-
* @param {Object} object The object to clear.
|
|
2148
|
-
*/
|
|
2149
|
-
function clear(object) {
|
|
2150
|
-
for (const property in object) {
|
|
2151
|
-
delete object[property];
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
/**
|
|
2156
|
-
* Determine if an object has any properties.
|
|
2157
|
-
* @param {Object} object The object to check.
|
|
2158
|
-
* @return {boolean} The object is empty.
|
|
2159
|
-
*/
|
|
2160
|
-
function isEmpty(object) {
|
|
2161
|
-
let property;
|
|
2162
|
-
for (property in object) {
|
|
2163
|
-
return false;
|
|
2164
|
-
}
|
|
2165
|
-
return !property;
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
/**
|
|
2169
|
-
* @module ol/events/Target
|
|
2170
|
-
*/
|
|
2171
|
-
|
|
2172
|
-
/**
|
|
2173
|
-
* @typedef {EventTarget|Target} EventTargetLike
|
|
2174
|
-
*/
|
|
2175
|
-
|
|
2176
|
-
/**
|
|
2177
|
-
* @classdesc
|
|
2178
|
-
* A simplified implementation of the W3C DOM Level 2 EventTarget interface.
|
|
2179
|
-
* See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.
|
|
2180
|
-
*
|
|
2181
|
-
* There are two important simplifications compared to the specification:
|
|
2182
|
-
*
|
|
2183
|
-
* 1. The handling of `useCapture` in `addEventListener` and
|
|
2184
|
-
* `removeEventListener`. There is no real capture model.
|
|
2185
|
-
* 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.
|
|
2186
|
-
* There is no event target hierarchy. When a listener calls
|
|
2187
|
-
* `stopPropagation` or `preventDefault` on an event object, it means that no
|
|
2188
|
-
* more listeners after this one will be called. Same as when the listener
|
|
2189
|
-
* returns false.
|
|
2190
|
-
*/
|
|
2191
|
-
class Target extends Disposable$1 {
|
|
2192
|
-
/**
|
|
2193
|
-
* @param {*} [target] Default event target for dispatched events.
|
|
2194
|
-
*/
|
|
2195
|
-
constructor(target) {
|
|
2196
|
-
super();
|
|
2197
|
-
|
|
2198
|
-
/**
|
|
2199
|
-
* @private
|
|
2200
|
-
* @type {*}
|
|
2201
|
-
*/
|
|
2202
|
-
this.eventTarget_ = target;
|
|
2203
|
-
|
|
2204
|
-
/**
|
|
2205
|
-
* @private
|
|
2206
|
-
* @type {Object<string, number>}
|
|
2207
|
-
*/
|
|
2208
|
-
this.pendingRemovals_ = null;
|
|
2209
|
-
|
|
2210
|
-
/**
|
|
2211
|
-
* @private
|
|
2212
|
-
* @type {Object<string, number>}
|
|
2213
|
-
*/
|
|
2214
|
-
this.dispatching_ = null;
|
|
2215
|
-
|
|
2216
|
-
/**
|
|
2217
|
-
* @private
|
|
2218
|
-
* @type {Object<string, Array<import("../events.js").Listener>>}
|
|
2219
|
-
*/
|
|
2220
|
-
this.listeners_ = null;
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
|
-
/**
|
|
2224
|
-
* @param {string} type Type.
|
|
2225
|
-
* @param {import("../events.js").Listener} listener Listener.
|
|
2226
|
-
*/
|
|
2227
|
-
addEventListener(type, listener) {
|
|
2228
|
-
if (!type || !listener) {
|
|
2229
|
-
return;
|
|
2230
|
-
}
|
|
2231
|
-
const listeners = this.listeners_ || (this.listeners_ = {});
|
|
2232
|
-
const listenersForType = listeners[type] || (listeners[type] = []);
|
|
2233
|
-
if (!listenersForType.includes(listener)) {
|
|
2234
|
-
listenersForType.push(listener);
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
|
|
2238
|
-
/**
|
|
2239
|
-
* Dispatches an event and calls all listeners listening for events
|
|
2240
|
-
* of this type. The event parameter can either be a string or an
|
|
2241
|
-
* Object with a `type` property.
|
|
2242
|
-
*
|
|
2243
|
-
* @param {import("./Event.js").default|string} event Event object.
|
|
2244
|
-
* @return {boolean|undefined} `false` if anyone called preventDefault on the
|
|
2245
|
-
* event object or if any of the listeners returned false.
|
|
2246
|
-
* @api
|
|
2247
|
-
*/
|
|
2248
|
-
dispatchEvent(event) {
|
|
2249
|
-
const isString = typeof event === 'string';
|
|
2250
|
-
const type = isString ? event : event.type;
|
|
2251
|
-
const listeners = this.listeners_ && this.listeners_[type];
|
|
2252
|
-
if (!listeners) {
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
const evt = isString ? new Event$1(event) : /** @type {Event} */ (event);
|
|
2257
|
-
if (!evt.target) {
|
|
2258
|
-
evt.target = this.eventTarget_ || this;
|
|
2259
|
-
}
|
|
2260
|
-
const dispatching = this.dispatching_ || (this.dispatching_ = {});
|
|
2261
|
-
const pendingRemovals =
|
|
2262
|
-
this.pendingRemovals_ || (this.pendingRemovals_ = {});
|
|
2263
|
-
if (!(type in dispatching)) {
|
|
2264
|
-
dispatching[type] = 0;
|
|
2265
|
-
pendingRemovals[type] = 0;
|
|
2266
|
-
}
|
|
2267
|
-
++dispatching[type];
|
|
2268
|
-
let propagate;
|
|
2269
|
-
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
|
2270
|
-
if ('handleEvent' in listeners[i]) {
|
|
2271
|
-
propagate = /** @type {import("../events.js").ListenerObject} */ (
|
|
2272
|
-
listeners[i]
|
|
2273
|
-
).handleEvent(evt);
|
|
2274
|
-
} else {
|
|
2275
|
-
propagate = /** @type {import("../events.js").ListenerFunction} */ (
|
|
2276
|
-
listeners[i]
|
|
2277
|
-
).call(this, evt);
|
|
2278
|
-
}
|
|
2279
|
-
if (propagate === false || evt.propagationStopped) {
|
|
2280
|
-
propagate = false;
|
|
2281
|
-
break;
|
|
2282
|
-
}
|
|
2283
|
-
}
|
|
2284
|
-
if (--dispatching[type] === 0) {
|
|
2285
|
-
let pr = pendingRemovals[type];
|
|
2286
|
-
delete pendingRemovals[type];
|
|
2287
|
-
while (pr--) {
|
|
2288
|
-
this.removeEventListener(type, VOID);
|
|
2289
|
-
}
|
|
2290
|
-
delete dispatching[type];
|
|
2291
|
-
}
|
|
2292
|
-
return propagate;
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
|
-
/**
|
|
2296
|
-
* Clean up.
|
|
2297
|
-
*/
|
|
2298
|
-
disposeInternal() {
|
|
2299
|
-
this.listeners_ && clear(this.listeners_);
|
|
2300
|
-
}
|
|
2301
|
-
|
|
2302
|
-
/**
|
|
2303
|
-
* Get the listeners for a specified event type. Listeners are returned in the
|
|
2304
|
-
* order that they will be called in.
|
|
2305
|
-
*
|
|
2306
|
-
* @param {string} type Type.
|
|
2307
|
-
* @return {Array<import("../events.js").Listener>|undefined} Listeners.
|
|
2308
|
-
*/
|
|
2309
|
-
getListeners(type) {
|
|
2310
|
-
return (this.listeners_ && this.listeners_[type]) || undefined;
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2313
|
-
/**
|
|
2314
|
-
* @param {string} [type] Type. If not provided,
|
|
2315
|
-
* `true` will be returned if this event target has any listeners.
|
|
2316
|
-
* @return {boolean} Has listeners.
|
|
2317
|
-
*/
|
|
2318
|
-
hasListener(type) {
|
|
2319
|
-
if (!this.listeners_) {
|
|
2320
|
-
return false;
|
|
2321
|
-
}
|
|
2322
|
-
return type
|
|
2323
|
-
? type in this.listeners_
|
|
2324
|
-
: Object.keys(this.listeners_).length > 0;
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
/**
|
|
2328
|
-
* @param {string} type Type.
|
|
2329
|
-
* @param {import("../events.js").Listener} listener Listener.
|
|
2330
|
-
*/
|
|
2331
|
-
removeEventListener(type, listener) {
|
|
2332
|
-
const listeners = this.listeners_ && this.listeners_[type];
|
|
2333
|
-
if (listeners) {
|
|
2334
|
-
const index = listeners.indexOf(listener);
|
|
2335
|
-
if (index !== -1) {
|
|
2336
|
-
if (this.pendingRemovals_ && type in this.pendingRemovals_) {
|
|
2337
|
-
// make listener a no-op, and remove later in #dispatchEvent()
|
|
2338
|
-
listeners[index] = VOID;
|
|
2339
|
-
++this.pendingRemovals_[type];
|
|
2340
|
-
} else {
|
|
2341
|
-
listeners.splice(index, 1);
|
|
2342
|
-
if (listeners.length === 0) {
|
|
2343
|
-
delete this.listeners_[type];
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
|
|
2351
|
-
var Target$1 = Target;
|
|
2352
|
-
|
|
2353
|
-
/**
|
|
2354
|
-
* @module ol/events/EventType
|
|
2355
|
-
*/
|
|
2356
|
-
|
|
2357
|
-
/**
|
|
2358
|
-
* @enum {string}
|
|
2359
|
-
* @const
|
|
2360
|
-
*/
|
|
2361
|
-
var EventType = {
|
|
2362
|
-
/**
|
|
2363
|
-
* Generic change event. Triggered when the revision counter is increased.
|
|
2364
|
-
* @event module:ol/events/Event~BaseEvent#change
|
|
2365
|
-
* @api
|
|
2366
|
-
*/
|
|
2367
|
-
CHANGE: 'change',
|
|
2368
|
-
|
|
2369
|
-
/**
|
|
2370
|
-
* Generic error event. Triggered when an error occurs.
|
|
2371
|
-
* @event module:ol/events/Event~BaseEvent#error
|
|
2372
|
-
* @api
|
|
2373
|
-
*/
|
|
2374
|
-
ERROR: 'error',
|
|
2375
|
-
|
|
2376
|
-
BLUR: 'blur',
|
|
2377
|
-
CLEAR: 'clear',
|
|
2378
|
-
CONTEXTMENU: 'contextmenu',
|
|
2379
|
-
CLICK: 'click',
|
|
2380
|
-
DBLCLICK: 'dblclick',
|
|
2381
|
-
DRAGENTER: 'dragenter',
|
|
2382
|
-
DRAGOVER: 'dragover',
|
|
2383
|
-
DROP: 'drop',
|
|
2384
|
-
FOCUS: 'focus',
|
|
2385
|
-
KEYDOWN: 'keydown',
|
|
2386
|
-
KEYPRESS: 'keypress',
|
|
2387
|
-
LOAD: 'load',
|
|
2388
|
-
RESIZE: 'resize',
|
|
2389
|
-
TOUCHMOVE: 'touchmove',
|
|
2390
|
-
WHEEL: 'wheel',
|
|
2391
|
-
};
|
|
2392
|
-
|
|
2393
|
-
/**
|
|
2394
|
-
* @module ol/events
|
|
2395
|
-
*/
|
|
2396
|
-
|
|
2397
|
-
/**
|
|
2398
|
-
* Key to use with {@link module:ol/Observable.unByKey}.
|
|
2399
|
-
* @typedef {Object} EventsKey
|
|
2400
|
-
* @property {ListenerFunction} listener Listener.
|
|
2401
|
-
* @property {import("./events/Target.js").EventTargetLike} target Target.
|
|
2402
|
-
* @property {string} type Type.
|
|
2403
|
-
* @api
|
|
2404
|
-
*/
|
|
2405
|
-
|
|
2406
|
-
/**
|
|
2407
|
-
* Listener function. This function is called with an event object as argument.
|
|
2408
|
-
* When the function returns `false`, event propagation will stop.
|
|
2409
|
-
*
|
|
2410
|
-
* @typedef {function((Event|import("./events/Event.js").default)): (void|boolean)} ListenerFunction
|
|
2411
|
-
* @api
|
|
2412
|
-
*/
|
|
2413
|
-
|
|
2414
|
-
/**
|
|
2415
|
-
* @typedef {Object} ListenerObject
|
|
2416
|
-
* @property {ListenerFunction} handleEvent HandleEvent listener function.
|
|
2417
|
-
*/
|
|
2418
|
-
|
|
2419
|
-
/**
|
|
2420
|
-
* @typedef {ListenerFunction|ListenerObject} Listener
|
|
2421
|
-
*/
|
|
2422
|
-
|
|
2423
|
-
/**
|
|
2424
|
-
* Registers an event listener on an event target. Inspired by
|
|
2425
|
-
* https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
|
|
2426
|
-
*
|
|
2427
|
-
* This function efficiently binds a `listener` to a `this` object, and returns
|
|
2428
|
-
* a key for use with {@link module:ol/events.unlistenByKey}.
|
|
2429
|
-
*
|
|
2430
|
-
* @param {import("./events/Target.js").EventTargetLike} target Event target.
|
|
2431
|
-
* @param {string} type Event type.
|
|
2432
|
-
* @param {ListenerFunction} listener Listener.
|
|
2433
|
-
* @param {Object} [thisArg] Object referenced by the `this` keyword in the
|
|
2434
|
-
* listener. Default is the `target`.
|
|
2435
|
-
* @param {boolean} [once] If true, add the listener as one-off listener.
|
|
2436
|
-
* @return {EventsKey} Unique key for the listener.
|
|
2437
|
-
*/
|
|
2438
|
-
function listen(target, type, listener, thisArg, once) {
|
|
2439
|
-
if (thisArg && thisArg !== target) {
|
|
2440
|
-
listener = listener.bind(thisArg);
|
|
2441
|
-
}
|
|
2442
|
-
if (once) {
|
|
2443
|
-
const originalListener = listener;
|
|
2444
|
-
listener = function () {
|
|
2445
|
-
target.removeEventListener(type, listener);
|
|
2446
|
-
originalListener.apply(this, arguments);
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
const eventsKey = {
|
|
2450
|
-
target: target,
|
|
2451
|
-
type: type,
|
|
2452
|
-
listener: listener,
|
|
2453
|
-
};
|
|
2454
|
-
target.addEventListener(type, listener);
|
|
2455
|
-
return eventsKey;
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
/**
|
|
2459
|
-
* Registers a one-off event listener on an event target. Inspired by
|
|
2460
|
-
* https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
|
|
2461
|
-
*
|
|
2462
|
-
* This function efficiently binds a `listener` as self-unregistering listener
|
|
2463
|
-
* to a `this` object, and returns a key for use with
|
|
2464
|
-
* {@link module:ol/events.unlistenByKey} in case the listener needs to be
|
|
2465
|
-
* unregistered before it is called.
|
|
2466
|
-
*
|
|
2467
|
-
* When {@link module:ol/events.listen} is called with the same arguments after this
|
|
2468
|
-
* function, the self-unregistering listener will be turned into a permanent
|
|
2469
|
-
* listener.
|
|
2470
|
-
*
|
|
2471
|
-
* @param {import("./events/Target.js").EventTargetLike} target Event target.
|
|
2472
|
-
* @param {string} type Event type.
|
|
2473
|
-
* @param {ListenerFunction} listener Listener.
|
|
2474
|
-
* @param {Object} [thisArg] Object referenced by the `this` keyword in the
|
|
2475
|
-
* listener. Default is the `target`.
|
|
2476
|
-
* @return {EventsKey} Key for unlistenByKey.
|
|
2477
|
-
*/
|
|
2478
|
-
function listenOnce(target, type, listener, thisArg) {
|
|
2479
|
-
return listen(target, type, listener, thisArg, true);
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
/**
|
|
2483
|
-
* Unregisters event listeners on an event target. Inspired by
|
|
2484
|
-
* https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
|
|
2485
|
-
*
|
|
2486
|
-
* The argument passed to this function is the key returned from
|
|
2487
|
-
* {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.
|
|
2488
|
-
*
|
|
2489
|
-
* @param {EventsKey} key The key.
|
|
2490
|
-
*/
|
|
2491
|
-
function unlistenByKey(key) {
|
|
2492
|
-
if (key && key.target) {
|
|
2493
|
-
key.target.removeEventListener(key.type, key.listener);
|
|
2494
|
-
clear(key);
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
/**
|
|
2499
|
-
* @module ol/Observable
|
|
2500
|
-
*/
|
|
2501
|
-
|
|
2502
|
-
/***
|
|
2503
|
-
* @template {string} Type
|
|
2504
|
-
* @template {Event|import("./events/Event.js").default} EventClass
|
|
2505
|
-
* @template Return
|
|
2506
|
-
* @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature
|
|
2507
|
-
*/
|
|
2508
|
-
|
|
2509
|
-
/***
|
|
2510
|
-
* @template {string} Type
|
|
2511
|
-
* @template Return
|
|
2512
|
-
* @typedef {(type: Type[], listener: (event: Event|import("./events/Event").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature
|
|
2513
|
-
*/
|
|
2514
|
-
|
|
2515
|
-
/**
|
|
2516
|
-
* @typedef {'change'|'error'} EventTypes
|
|
2517
|
-
*/
|
|
2518
|
-
|
|
2519
|
-
/***
|
|
2520
|
-
* @template Return
|
|
2521
|
-
* @typedef {OnSignature<EventTypes, import("./events/Event.js").default, Return> & CombinedOnSignature<EventTypes, Return>} ObservableOnSignature
|
|
2522
|
-
*/
|
|
2523
|
-
|
|
2524
|
-
/**
|
|
2525
|
-
* @classdesc
|
|
2526
|
-
* Abstract base class; normally only used for creating subclasses and not
|
|
2527
|
-
* instantiated in apps.
|
|
2528
|
-
* An event target providing convenient methods for listener registration
|
|
2529
|
-
* and unregistration. A generic `change` event is always available through
|
|
2530
|
-
* {@link module:ol/Observable~Observable#changed}.
|
|
2531
|
-
*
|
|
2532
|
-
* @fires import("./events/Event.js").default
|
|
2533
|
-
* @api
|
|
2534
|
-
*/
|
|
2535
|
-
class Observable extends Target$1 {
|
|
2536
|
-
constructor() {
|
|
2537
|
-
super();
|
|
2538
|
-
|
|
2539
|
-
this.on =
|
|
2540
|
-
/** @type {ObservableOnSignature<import("./events").EventsKey>} */ (
|
|
2541
|
-
this.onInternal
|
|
2542
|
-
);
|
|
2543
|
-
|
|
2544
|
-
this.once =
|
|
2545
|
-
/** @type {ObservableOnSignature<import("./events").EventsKey>} */ (
|
|
2546
|
-
this.onceInternal
|
|
2547
|
-
);
|
|
2548
|
-
|
|
2549
|
-
this.un = /** @type {ObservableOnSignature<void>} */ (this.unInternal);
|
|
2550
|
-
|
|
2551
|
-
/**
|
|
2552
|
-
* @private
|
|
2553
|
-
* @type {number}
|
|
2554
|
-
*/
|
|
2555
|
-
this.revision_ = 0;
|
|
2556
|
-
}
|
|
2557
|
-
|
|
2558
|
-
/**
|
|
2559
|
-
* Increases the revision counter and dispatches a 'change' event.
|
|
2560
|
-
* @api
|
|
2561
|
-
*/
|
|
2562
|
-
changed() {
|
|
2563
|
-
++this.revision_;
|
|
2564
|
-
this.dispatchEvent(EventType.CHANGE);
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
/**
|
|
2568
|
-
* Get the version number for this object. Each time the object is modified,
|
|
2569
|
-
* its version number will be incremented.
|
|
2570
|
-
* @return {number} Revision.
|
|
2571
|
-
* @api
|
|
2572
|
-
*/
|
|
2573
|
-
getRevision() {
|
|
2574
|
-
return this.revision_;
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
/**
|
|
2578
|
-
* @param {string|Array<string>} type Type.
|
|
2579
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
2580
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
|
|
2581
|
-
* @protected
|
|
2582
|
-
*/
|
|
2583
|
-
onInternal(type, listener) {
|
|
2584
|
-
if (Array.isArray(type)) {
|
|
2585
|
-
const len = type.length;
|
|
2586
|
-
const keys = new Array(len);
|
|
2587
|
-
for (let i = 0; i < len; ++i) {
|
|
2588
|
-
keys[i] = listen(this, type[i], listener);
|
|
2589
|
-
}
|
|
2590
|
-
return keys;
|
|
2591
|
-
}
|
|
2592
|
-
return listen(this, /** @type {string} */ (type), listener);
|
|
2593
|
-
}
|
|
2594
|
-
|
|
2595
|
-
/**
|
|
2596
|
-
* @param {string|Array<string>} type Type.
|
|
2597
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
2598
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
|
|
2599
|
-
* @protected
|
|
2600
|
-
*/
|
|
2601
|
-
onceInternal(type, listener) {
|
|
2602
|
-
let key;
|
|
2603
|
-
if (Array.isArray(type)) {
|
|
2604
|
-
const len = type.length;
|
|
2605
|
-
key = new Array(len);
|
|
2606
|
-
for (let i = 0; i < len; ++i) {
|
|
2607
|
-
key[i] = listenOnce(this, type[i], listener);
|
|
2608
|
-
}
|
|
2609
|
-
} else {
|
|
2610
|
-
key = listenOnce(this, /** @type {string} */ (type), listener);
|
|
2611
|
-
}
|
|
2612
|
-
/** @type {Object} */ (listener).ol_key = key;
|
|
2613
|
-
return key;
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
/**
|
|
2617
|
-
* Unlisten for a certain type of event.
|
|
2618
|
-
* @param {string|Array<string>} type Type.
|
|
2619
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
2620
|
-
* @protected
|
|
2621
|
-
*/
|
|
2622
|
-
unInternal(type, listener) {
|
|
2623
|
-
const key = /** @type {Object} */ (listener).ol_key;
|
|
2624
|
-
if (key) {
|
|
2625
|
-
unByKey(key);
|
|
2626
|
-
} else if (Array.isArray(type)) {
|
|
2627
|
-
for (let i = 0, ii = type.length; i < ii; ++i) {
|
|
2628
|
-
this.removeEventListener(type[i], listener);
|
|
2629
|
-
}
|
|
2630
|
-
} else {
|
|
2631
|
-
this.removeEventListener(type, listener);
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
/**
|
|
2637
|
-
* Listen for a certain type of event.
|
|
2638
|
-
* @function
|
|
2639
|
-
* @param {string|Array<string>} type The event type or array of event types.
|
|
2640
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
|
|
2641
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
|
|
2642
|
-
* called with an array of event types as the first argument, the return
|
|
2643
|
-
* will be an array of keys.
|
|
2644
|
-
* @api
|
|
2645
|
-
*/
|
|
2646
|
-
Observable.prototype.on;
|
|
2647
|
-
|
|
2648
|
-
/**
|
|
2649
|
-
* Listen once for a certain type of event.
|
|
2650
|
-
* @function
|
|
2651
|
-
* @param {string|Array<string>} type The event type or array of event types.
|
|
2652
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
|
|
2653
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
|
|
2654
|
-
* called with an array of event types as the first argument, the return
|
|
2655
|
-
* will be an array of keys.
|
|
2656
|
-
* @api
|
|
2657
|
-
*/
|
|
2658
|
-
Observable.prototype.once;
|
|
2659
|
-
|
|
2660
|
-
/**
|
|
2661
|
-
* Unlisten for a certain type of event.
|
|
2662
|
-
* @function
|
|
2663
|
-
* @param {string|Array<string>} type The event type or array of event types.
|
|
2664
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
|
|
2665
|
-
* @api
|
|
2666
|
-
*/
|
|
2667
|
-
Observable.prototype.un;
|
|
2668
|
-
|
|
2669
|
-
/**
|
|
2670
|
-
* Removes an event listener using the key returned by `on()` or `once()`.
|
|
2671
|
-
* @param {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} key The key returned by `on()`
|
|
2672
|
-
* or `once()` (or an array of keys).
|
|
2673
|
-
* @api
|
|
2674
|
-
*/
|
|
2675
|
-
function unByKey(key) {
|
|
2676
|
-
if (Array.isArray(key)) {
|
|
2677
|
-
for (let i = 0, ii = key.length; i < ii; ++i) {
|
|
2678
|
-
unlistenByKey(key[i]);
|
|
2679
|
-
}
|
|
2680
|
-
} else {
|
|
2681
|
-
unlistenByKey(/** @type {import("./events.js").EventsKey} */ (key));
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
|
|
2685
|
-
var Observable$1 = Observable;
|
|
2686
|
-
|
|
2687
|
-
/**
|
|
2688
|
-
* @module ol/util
|
|
2689
|
-
*/
|
|
2690
|
-
|
|
2691
|
-
/**
|
|
2692
|
-
* Counter for getUid.
|
|
2693
|
-
* @type {number}
|
|
2694
|
-
* @private
|
|
2695
|
-
*/
|
|
2696
|
-
let uidCounter_ = 0;
|
|
2697
|
-
|
|
2698
|
-
/**
|
|
2699
|
-
* Gets a unique ID for an object. This mutates the object so that further calls
|
|
2700
|
-
* with the same object as a parameter returns the same value. Unique IDs are generated
|
|
2701
|
-
* as a strictly increasing sequence. Adapted from goog.getUid.
|
|
2702
|
-
*
|
|
2703
|
-
* @param {Object} obj The object to get the unique ID for.
|
|
2704
|
-
* @return {string} The unique ID for the object.
|
|
2705
|
-
* @api
|
|
2706
|
-
*/
|
|
2707
|
-
function getUid(obj) {
|
|
2708
|
-
return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
/**
|
|
2712
|
-
* @module ol/Object
|
|
2713
|
-
*/
|
|
2714
|
-
|
|
2715
|
-
/**
|
|
2716
|
-
* @classdesc
|
|
2717
|
-
* Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.
|
|
2718
|
-
*/
|
|
2719
|
-
class ObjectEvent extends Event$1 {
|
|
2720
|
-
/**
|
|
2721
|
-
* @param {string} type The event type.
|
|
2722
|
-
* @param {string} key The property name.
|
|
2723
|
-
* @param {*} oldValue The old value for `key`.
|
|
2724
|
-
*/
|
|
2725
|
-
constructor(type, key, oldValue) {
|
|
2726
|
-
super(type);
|
|
2727
|
-
|
|
2728
|
-
/**
|
|
2729
|
-
* The name of the property whose value is changing.
|
|
2730
|
-
* @type {string}
|
|
2731
|
-
* @api
|
|
2732
|
-
*/
|
|
2733
|
-
this.key = key;
|
|
2734
|
-
|
|
2735
|
-
/**
|
|
2736
|
-
* The old value. To get the new value use `e.target.get(e.key)` where
|
|
2737
|
-
* `e` is the event object.
|
|
2738
|
-
* @type {*}
|
|
2739
|
-
* @api
|
|
2740
|
-
*/
|
|
2741
|
-
this.oldValue = oldValue;
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
/***
|
|
2746
|
-
* @template Return
|
|
2747
|
-
* @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
|
|
2748
|
-
* import("./Observable").OnSignature<import("./ObjectEventType").Types, ObjectEvent, Return> &
|
|
2749
|
-
* import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|import("./ObjectEventType").Types, Return>} ObjectOnSignature
|
|
2750
|
-
*/
|
|
2751
|
-
|
|
2752
|
-
/**
|
|
2753
|
-
* @classdesc
|
|
2754
|
-
* Abstract base class; normally only used for creating subclasses and not
|
|
2755
|
-
* instantiated in apps.
|
|
2756
|
-
* Most non-trivial classes inherit from this.
|
|
2757
|
-
*
|
|
2758
|
-
* This extends {@link module:ol/Observable~Observable} with observable
|
|
2759
|
-
* properties, where each property is observable as well as the object as a
|
|
2760
|
-
* whole.
|
|
2761
|
-
*
|
|
2762
|
-
* Classes that inherit from this have pre-defined properties, to which you can
|
|
2763
|
-
* add your owns. The pre-defined properties are listed in this documentation as
|
|
2764
|
-
* 'Observable Properties', and have their own accessors; for example,
|
|
2765
|
-
* {@link module:ol/Map~Map} has a `target` property, accessed with
|
|
2766
|
-
* `getTarget()` and changed with `setTarget()`. Not all properties are however
|
|
2767
|
-
* settable. There are also general-purpose accessors `get()` and `set()`. For
|
|
2768
|
-
* example, `get('target')` is equivalent to `getTarget()`.
|
|
2769
|
-
*
|
|
2770
|
-
* The `set` accessors trigger a change event, and you can monitor this by
|
|
2771
|
-
* registering a listener. For example, {@link module:ol/View~View} has a
|
|
2772
|
-
* `center` property, so `view.on('change:center', function(evt) {...});` would
|
|
2773
|
-
* call the function whenever the value of the center property changes. Within
|
|
2774
|
-
* the function, `evt.target` would be the view, so `evt.target.getCenter()`
|
|
2775
|
-
* would return the new center.
|
|
2776
|
-
*
|
|
2777
|
-
* You can add your own observable properties with
|
|
2778
|
-
* `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.
|
|
2779
|
-
* You can listen for changes on that property value with
|
|
2780
|
-
* `object.on('change:prop', listener)`. You can get a list of all
|
|
2781
|
-
* properties with {@link module:ol/Object~BaseObject#getProperties}.
|
|
2782
|
-
*
|
|
2783
|
-
* Note that the observable properties are separate from standard JS properties.
|
|
2784
|
-
* You can, for example, give your map object a title with
|
|
2785
|
-
* `map.title='New title'` and with `map.set('title', 'Another title')`. The
|
|
2786
|
-
* first will be a `hasOwnProperty`; the second will appear in
|
|
2787
|
-
* `getProperties()`. Only the second is observable.
|
|
2788
|
-
*
|
|
2789
|
-
* Properties can be deleted by using the unset method. E.g.
|
|
2790
|
-
* object.unset('foo').
|
|
2791
|
-
*
|
|
2792
|
-
* @fires ObjectEvent
|
|
2793
|
-
* @api
|
|
2794
|
-
*/
|
|
2795
|
-
class BaseObject extends Observable$1 {
|
|
2796
|
-
/**
|
|
2797
|
-
* @param {Object<string, *>} [values] An object with key-value pairs.
|
|
2798
|
-
*/
|
|
2799
|
-
constructor(values) {
|
|
2800
|
-
super();
|
|
2801
|
-
|
|
2802
|
-
/***
|
|
2803
|
-
* @type {ObjectOnSignature<import("./events").EventsKey>}
|
|
2804
|
-
*/
|
|
2805
|
-
this.on;
|
|
2806
|
-
|
|
2807
|
-
/***
|
|
2808
|
-
* @type {ObjectOnSignature<import("./events").EventsKey>}
|
|
2809
|
-
*/
|
|
2810
|
-
this.once;
|
|
2811
|
-
|
|
2812
|
-
/***
|
|
2813
|
-
* @type {ObjectOnSignature<void>}
|
|
2814
|
-
*/
|
|
2815
|
-
this.un;
|
|
2816
|
-
|
|
2817
|
-
// Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is
|
|
2818
|
-
// the same as the order in which they were created. This also helps to
|
|
2819
|
-
// ensure that object properties are always added in the same order, which
|
|
2820
|
-
// helps many JavaScript engines generate faster code.
|
|
2821
|
-
getUid(this);
|
|
2822
|
-
|
|
2823
|
-
/**
|
|
2824
|
-
* @private
|
|
2825
|
-
* @type {Object<string, *>}
|
|
2826
|
-
*/
|
|
2827
|
-
this.values_ = null;
|
|
2828
|
-
|
|
2829
|
-
if (values !== undefined) {
|
|
2830
|
-
this.setProperties(values);
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
/**
|
|
2835
|
-
* Gets a value.
|
|
2836
|
-
* @param {string} key Key name.
|
|
2837
|
-
* @return {*} Value.
|
|
2838
|
-
* @api
|
|
2839
|
-
*/
|
|
2840
|
-
get(key) {
|
|
2841
|
-
let value;
|
|
2842
|
-
if (this.values_ && this.values_.hasOwnProperty(key)) {
|
|
2843
|
-
value = this.values_[key];
|
|
2844
|
-
}
|
|
2845
|
-
return value;
|
|
2846
|
-
}
|
|
2847
|
-
|
|
2848
|
-
/**
|
|
2849
|
-
* Get a list of object property names.
|
|
2850
|
-
* @return {Array<string>} List of property names.
|
|
2851
|
-
* @api
|
|
2852
|
-
*/
|
|
2853
|
-
getKeys() {
|
|
2854
|
-
return (this.values_ && Object.keys(this.values_)) || [];
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
/**
|
|
2858
|
-
* Get an object of all property names and values.
|
|
2859
|
-
* @return {Object<string, *>} Object.
|
|
2860
|
-
* @api
|
|
2861
|
-
*/
|
|
2862
|
-
getProperties() {
|
|
2863
|
-
return (this.values_ && Object.assign({}, this.values_)) || {};
|
|
2864
|
-
}
|
|
2865
|
-
|
|
2866
|
-
/**
|
|
2867
|
-
* @return {boolean} The object has properties.
|
|
2868
|
-
*/
|
|
2869
|
-
hasProperties() {
|
|
2870
|
-
return !!this.values_;
|
|
2871
|
-
}
|
|
2872
|
-
|
|
2873
|
-
/**
|
|
2874
|
-
* @param {string} key Key name.
|
|
2875
|
-
* @param {*} oldValue Old value.
|
|
2876
|
-
*/
|
|
2877
|
-
notify(key, oldValue) {
|
|
2878
|
-
let eventType;
|
|
2879
|
-
eventType = `change:${key}`;
|
|
2880
|
-
if (this.hasListener(eventType)) {
|
|
2881
|
-
this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
|
|
2882
|
-
}
|
|
2883
|
-
eventType = ObjectEventType.PROPERTYCHANGE;
|
|
2884
|
-
if (this.hasListener(eventType)) {
|
|
2885
|
-
this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
|
|
2889
|
-
/**
|
|
2890
|
-
* @param {string} key Key name.
|
|
2891
|
-
* @param {import("./events.js").Listener} listener Listener.
|
|
2892
|
-
*/
|
|
2893
|
-
addChangeListener(key, listener) {
|
|
2894
|
-
this.addEventListener(`change:${key}`, listener);
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
/**
|
|
2898
|
-
* @param {string} key Key name.
|
|
2899
|
-
* @param {import("./events.js").Listener} listener Listener.
|
|
2900
|
-
*/
|
|
2901
|
-
removeChangeListener(key, listener) {
|
|
2902
|
-
this.removeEventListener(`change:${key}`, listener);
|
|
2903
|
-
}
|
|
2904
|
-
|
|
2905
|
-
/**
|
|
2906
|
-
* Sets a value.
|
|
2907
|
-
* @param {string} key Key name.
|
|
2908
|
-
* @param {*} value Value.
|
|
2909
|
-
* @param {boolean} [silent] Update without triggering an event.
|
|
2910
|
-
* @api
|
|
2911
|
-
*/
|
|
2912
|
-
set(key, value, silent) {
|
|
2913
|
-
const values = this.values_ || (this.values_ = {});
|
|
2914
|
-
if (silent) {
|
|
2915
|
-
values[key] = value;
|
|
2916
|
-
} else {
|
|
2917
|
-
const oldValue = values[key];
|
|
2918
|
-
values[key] = value;
|
|
2919
|
-
if (oldValue !== value) {
|
|
2920
|
-
this.notify(key, oldValue);
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2925
|
-
/**
|
|
2926
|
-
* Sets a collection of key-value pairs. Note that this changes any existing
|
|
2927
|
-
* properties and adds new ones (it does not remove any existing properties).
|
|
2928
|
-
* @param {Object<string, *>} values Values.
|
|
2929
|
-
* @param {boolean} [silent] Update without triggering an event.
|
|
2930
|
-
* @api
|
|
2931
|
-
*/
|
|
2932
|
-
setProperties(values, silent) {
|
|
2933
|
-
for (const key in values) {
|
|
2934
|
-
this.set(key, values[key], silent);
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
/**
|
|
2939
|
-
* Apply any properties from another object without triggering events.
|
|
2940
|
-
* @param {BaseObject} source The source object.
|
|
2941
|
-
* @protected
|
|
2942
|
-
*/
|
|
2943
|
-
applyProperties(source) {
|
|
2944
|
-
if (!source.values_) {
|
|
2945
|
-
return;
|
|
2946
|
-
}
|
|
2947
|
-
Object.assign(this.values_ || (this.values_ = {}), source.values_);
|
|
2948
|
-
}
|
|
2949
|
-
|
|
2950
|
-
/**
|
|
2951
|
-
* Unsets a property.
|
|
2952
|
-
* @param {string} key Key name.
|
|
2953
|
-
* @param {boolean} [silent] Unset without triggering an event.
|
|
2954
|
-
* @api
|
|
2955
|
-
*/
|
|
2956
|
-
unset(key, silent) {
|
|
2957
|
-
if (this.values_ && key in this.values_) {
|
|
2958
|
-
const oldValue = this.values_[key];
|
|
2959
|
-
delete this.values_[key];
|
|
2960
|
-
if (isEmpty(this.values_)) {
|
|
2961
|
-
this.values_ = null;
|
|
2962
|
-
}
|
|
2963
|
-
if (!silent) {
|
|
2964
|
-
this.notify(key, oldValue);
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2970
|
-
var BaseObject$1 = BaseObject;
|
|
2971
|
-
|
|
2972
|
-
/**
|
|
2973
|
-
* @module ol/extent
|
|
2974
|
-
*/
|
|
2975
|
-
|
|
2976
|
-
/**
|
|
2977
|
-
* Check if one extent contains another.
|
|
2978
|
-
*
|
|
2979
|
-
* An extent is deemed contained if it lies completely within the other extent,
|
|
2980
|
-
* including if they share one or more edges.
|
|
2981
|
-
*
|
|
2982
|
-
* @param {Extent} extent1 Extent 1.
|
|
2983
|
-
* @param {Extent} extent2 Extent 2.
|
|
2984
|
-
* @return {boolean} The second extent is contained by or on the edge of the
|
|
2985
|
-
* first.
|
|
2986
|
-
* @api
|
|
2987
|
-
*/
|
|
2988
|
-
function containsExtent(extent1, extent2) {
|
|
2989
|
-
return (
|
|
2990
|
-
extent1[0] <= extent2[0] &&
|
|
2991
|
-
extent2[2] <= extent1[2] &&
|
|
2992
|
-
extent1[1] <= extent2[1] &&
|
|
2993
|
-
extent2[3] <= extent1[3]
|
|
2994
|
-
);
|
|
2995
|
-
}
|
|
2996
|
-
|
|
2997
|
-
/**
|
|
2998
|
-
* Get the current computed width for the given element including margin,
|
|
2999
|
-
* padding and border.
|
|
3000
|
-
* Equivalent to jQuery's `$(el).outerWidth(true)`.
|
|
3001
|
-
* @param {!HTMLElement} element Element.
|
|
3002
|
-
* @return {number} The width.
|
|
3003
|
-
*/
|
|
3004
|
-
function outerWidth(element) {
|
|
3005
|
-
let width = element.offsetWidth;
|
|
3006
|
-
const style = getComputedStyle(element);
|
|
3007
|
-
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
|
|
3008
|
-
|
|
3009
|
-
return width;
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3012
|
-
/**
|
|
3013
|
-
* Get the current computed height for the given element including margin,
|
|
3014
|
-
* padding and border.
|
|
3015
|
-
* Equivalent to jQuery's `$(el).outerHeight(true)`.
|
|
3016
|
-
* @param {!HTMLElement} element Element.
|
|
3017
|
-
* @return {number} The height.
|
|
3018
|
-
*/
|
|
3019
|
-
function outerHeight(element) {
|
|
3020
|
-
let height = element.offsetHeight;
|
|
3021
|
-
const style = getComputedStyle(element);
|
|
3022
|
-
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
|
|
3023
|
-
|
|
3024
|
-
return height;
|
|
3025
|
-
}
|
|
3026
|
-
|
|
3027
|
-
/**
|
|
3028
|
-
* @param {Node} node The node to remove.
|
|
3029
|
-
* @return {Node|null} The node that was removed or null.
|
|
3030
|
-
*/
|
|
3031
|
-
function removeNode(node) {
|
|
3032
|
-
return node && node.parentNode ? node.parentNode.removeChild(node) : null;
|
|
3033
|
-
}
|
|
3034
|
-
|
|
3035
|
-
/**
|
|
3036
|
-
* @param {Node} node The node to remove the children from.
|
|
3037
|
-
*/
|
|
3038
|
-
function removeChildren(node) {
|
|
3039
|
-
while (node.lastChild) {
|
|
3040
|
-
node.removeChild(node.lastChild);
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
|
|
3044
|
-
/**
|
|
3045
|
-
* @module ol/css
|
|
3046
|
-
*/
|
|
3047
|
-
|
|
3048
|
-
/**
|
|
3049
|
-
* The CSS class that we'll give the DOM elements to have them selectable.
|
|
3050
|
-
*
|
|
3051
|
-
* @const
|
|
3052
|
-
* @type {string}
|
|
3053
|
-
*/
|
|
3054
|
-
const CLASS_SELECTABLE = 'ol-selectable';
|
|
3055
|
-
|
|
3056
|
-
/**
|
|
3057
|
-
* @module ol/MapEventType
|
|
3058
|
-
*/
|
|
3059
|
-
|
|
3060
|
-
/**
|
|
3061
|
-
* @enum {string}
|
|
3062
|
-
*/
|
|
3063
|
-
var MapEventType = {
|
|
3064
|
-
/**
|
|
3065
|
-
* Triggered after a map frame is rendered.
|
|
3066
|
-
* @event module:ol/MapEvent~MapEvent#postrender
|
|
3067
|
-
* @api
|
|
3068
|
-
*/
|
|
3069
|
-
POSTRENDER: 'postrender',
|
|
3070
|
-
|
|
3071
|
-
/**
|
|
3072
|
-
* Triggered when the map starts moving.
|
|
3073
|
-
* @event module:ol/MapEvent~MapEvent#movestart
|
|
3074
|
-
* @api
|
|
3075
|
-
*/
|
|
3076
|
-
MOVESTART: 'movestart',
|
|
3077
|
-
|
|
3078
|
-
/**
|
|
3079
|
-
* Triggered after the map is moved.
|
|
3080
|
-
* @event module:ol/MapEvent~MapEvent#moveend
|
|
3081
|
-
* @api
|
|
3082
|
-
*/
|
|
3083
|
-
MOVEEND: 'moveend',
|
|
3084
|
-
|
|
3085
|
-
/**
|
|
3086
|
-
* Triggered when loading of additional map data (tiles, images, features) starts.
|
|
3087
|
-
* @event module:ol/MapEvent~MapEvent#loadstart
|
|
3088
|
-
* @api
|
|
3089
|
-
*/
|
|
3090
|
-
LOADSTART: 'loadstart',
|
|
3091
|
-
|
|
3092
|
-
/**
|
|
3093
|
-
* Triggered when loading of additional map data has completed.
|
|
3094
|
-
* @event module:ol/MapEvent~MapEvent#loadend
|
|
3095
|
-
* @api
|
|
3096
|
-
*/
|
|
3097
|
-
LOADEND: 'loadend',
|
|
3098
|
-
};
|
|
3099
|
-
|
|
3100
|
-
/***
|
|
3101
|
-
* @typedef {'postrender'|'movestart'|'moveend'|'loadstart'|'loadend'} Types
|
|
3102
|
-
*/
|
|
3103
|
-
|
|
3104
|
-
/**
|
|
3105
|
-
* @module ol/Overlay
|
|
3106
|
-
*/
|
|
3107
|
-
|
|
3108
|
-
/**
|
|
3109
|
-
* @typedef {'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-center' | 'center-right' | 'top-left' | 'top-center' | 'top-right'} Positioning
|
|
3110
|
-
* The overlay position: `'bottom-left'`, `'bottom-center'`, `'bottom-right'`,
|
|
3111
|
-
* `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`,
|
|
3112
|
-
* `'top-center'`, or `'top-right'`.
|
|
3113
|
-
*/
|
|
3114
|
-
|
|
3115
|
-
/**
|
|
3116
|
-
* @typedef {Object} Options
|
|
3117
|
-
* @property {number|string} [id] Set the overlay id. The overlay id can be used
|
|
3118
|
-
* with the {@link module:ol/Map~Map#getOverlayById} method.
|
|
3119
|
-
* @property {HTMLElement} [element] The overlay element.
|
|
3120
|
-
* @property {Array<number>} [offset=[0, 0]] Offsets in pixels used when positioning
|
|
3121
|
-
* the overlay. The first element in the
|
|
3122
|
-
* array is the horizontal offset. A positive value shifts the overlay right.
|
|
3123
|
-
* The second element in the array is the vertical offset. A positive value
|
|
3124
|
-
* shifts the overlay down.
|
|
3125
|
-
* @property {import("./coordinate.js").Coordinate} [position] The overlay position
|
|
3126
|
-
* in map projection.
|
|
3127
|
-
* @property {Positioning} [positioning='top-left'] Defines how
|
|
3128
|
-
* the overlay is actually positioned with respect to its `position` property.
|
|
3129
|
-
* Possible values are `'bottom-left'`, `'bottom-center'`, `'bottom-right'`,
|
|
3130
|
-
* `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`,
|
|
3131
|
-
* `'top-center'`, and `'top-right'`.
|
|
3132
|
-
* @property {boolean} [stopEvent=true] Whether event propagation to the map
|
|
3133
|
-
* viewport should be stopped. If `true` the overlay is placed in the same
|
|
3134
|
-
* container as that of the controls (CSS class name
|
|
3135
|
-
* `ol-overlaycontainer-stopevent`); if `false` it is placed in the container
|
|
3136
|
-
* with CSS class name specified by the `className` property.
|
|
3137
|
-
* @property {boolean} [insertFirst=true] Whether the overlay is inserted first
|
|
3138
|
-
* in the overlay container, or appended. If the overlay is placed in the same
|
|
3139
|
-
* container as that of the controls (see the `stopEvent` option) you will
|
|
3140
|
-
* probably set `insertFirst` to `true` so the overlay is displayed below the
|
|
3141
|
-
* controls.
|
|
3142
|
-
* @property {PanIntoViewOptions|boolean} [autoPan=false] Pan the map when calling
|
|
3143
|
-
* `setPosition`, so that the overlay is entirely visible in the current viewport.
|
|
3144
|
-
* @property {string} [className='ol-overlay-container ol-selectable'] CSS class
|
|
3145
|
-
* name.
|
|
3146
|
-
*/
|
|
3147
|
-
|
|
3148
|
-
/**
|
|
3149
|
-
* @typedef {Object} PanOptions
|
|
3150
|
-
* @property {number} [duration=1000] The duration of the animation in
|
|
3151
|
-
* milliseconds.
|
|
3152
|
-
* @property {function(number):number} [easing] The easing function to use. Can
|
|
3153
|
-
* be one from {@link module:ol/easing} or a custom function.
|
|
3154
|
-
* Default is {@link module:ol/easing.inAndOut}.
|
|
3155
|
-
*/
|
|
3156
|
-
|
|
3157
|
-
/**
|
|
3158
|
-
* @typedef {Object} PanIntoViewOptions
|
|
3159
|
-
* @property {PanOptions} [animation={}] The animation parameters for the pan
|
|
3160
|
-
* @property {number} [margin=20] The margin (in pixels) between the
|
|
3161
|
-
* overlay and the borders of the map when panning into view.
|
|
3162
|
-
*/
|
|
3163
|
-
|
|
3164
|
-
/**
|
|
3165
|
-
* @enum {string}
|
|
3166
|
-
* @protected
|
|
3167
|
-
*/
|
|
3168
|
-
const Property = {
|
|
3169
|
-
ELEMENT: 'element',
|
|
3170
|
-
MAP: 'map',
|
|
3171
|
-
OFFSET: 'offset',
|
|
3172
|
-
POSITION: 'position',
|
|
3173
|
-
POSITIONING: 'positioning',
|
|
3174
|
-
};
|
|
3175
|
-
|
|
3176
|
-
/**
|
|
3177
|
-
* @typedef {import("./ObjectEventType").Types|'change:element'|'change:map'|'change:offset'|'change:position'|
|
|
3178
|
-
* 'change:positioning'} OverlayObjectEventTypes
|
|
3179
|
-
*/
|
|
3180
|
-
|
|
3181
|
-
/***
|
|
3182
|
-
* @template Return
|
|
3183
|
-
* @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
|
|
3184
|
-
* import("./Observable").OnSignature<OverlayObjectEventTypes, import("./Object").ObjectEvent, Return> &
|
|
3185
|
-
* import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|OverlayObjectEventTypes, Return>} OverlayOnSignature
|
|
3186
|
-
*/
|
|
3187
|
-
|
|
3188
|
-
/**
|
|
3189
|
-
* @classdesc
|
|
3190
|
-
* An element to be displayed over the map and attached to a single map
|
|
3191
|
-
* location. Like {@link module:ol/control/Control~Control}, Overlays are
|
|
3192
|
-
* visible widgets. Unlike Controls, they are not in a fixed position on the
|
|
3193
|
-
* screen, but are tied to a geographical coordinate, so panning the map will
|
|
3194
|
-
* move an Overlay but not a Control.
|
|
3195
|
-
*
|
|
3196
|
-
* Example:
|
|
3197
|
-
*
|
|
3198
|
-
* import Overlay from 'ol/Overlay.js';
|
|
3199
|
-
*
|
|
3200
|
-
* // ...
|
|
3201
|
-
* const popup = new Overlay({
|
|
3202
|
-
* element: document.getElementById('popup'),
|
|
3203
|
-
* });
|
|
3204
|
-
* popup.setPosition(coordinate);
|
|
3205
|
-
* map.addOverlay(popup);
|
|
3206
|
-
*
|
|
3207
|
-
* @api
|
|
3208
|
-
*/
|
|
3209
|
-
class Overlay extends BaseObject$1 {
|
|
3210
|
-
/**
|
|
3211
|
-
* @param {Options} options Overlay options.
|
|
3212
|
-
*/
|
|
3213
|
-
constructor(options) {
|
|
3214
|
-
super();
|
|
3215
|
-
|
|
3216
|
-
/***
|
|
3217
|
-
* @type {OverlayOnSignature<import("./events").EventsKey>}
|
|
3218
|
-
*/
|
|
3219
|
-
this.on;
|
|
3220
|
-
|
|
3221
|
-
/***
|
|
3222
|
-
* @type {OverlayOnSignature<import("./events").EventsKey>}
|
|
3223
|
-
*/
|
|
3224
|
-
this.once;
|
|
3225
|
-
|
|
3226
|
-
/***
|
|
3227
|
-
* @type {OverlayOnSignature<void>}
|
|
3228
|
-
*/
|
|
3229
|
-
this.un;
|
|
3230
|
-
|
|
3231
|
-
/**
|
|
3232
|
-
* @protected
|
|
3233
|
-
* @type {Options}
|
|
3234
|
-
*/
|
|
3235
|
-
this.options = options;
|
|
3236
|
-
|
|
3237
|
-
/**
|
|
3238
|
-
* @protected
|
|
3239
|
-
* @type {number|string|undefined}
|
|
3240
|
-
*/
|
|
3241
|
-
this.id = options.id;
|
|
3242
|
-
|
|
3243
|
-
/**
|
|
3244
|
-
* @protected
|
|
3245
|
-
* @type {boolean}
|
|
3246
|
-
*/
|
|
3247
|
-
this.insertFirst =
|
|
3248
|
-
options.insertFirst !== undefined ? options.insertFirst : true;
|
|
3249
|
-
|
|
3250
|
-
/**
|
|
3251
|
-
* @protected
|
|
3252
|
-
* @type {boolean}
|
|
3253
|
-
*/
|
|
3254
|
-
this.stopEvent = options.stopEvent !== undefined ? options.stopEvent : true;
|
|
3255
|
-
|
|
3256
|
-
/**
|
|
3257
|
-
* @protected
|
|
3258
|
-
* @type {HTMLElement}
|
|
3259
|
-
*/
|
|
3260
|
-
this.element = document.createElement('div');
|
|
3261
|
-
this.element.className =
|
|
3262
|
-
options.className !== undefined
|
|
3263
|
-
? options.className
|
|
3264
|
-
: 'ol-overlay-container ' + CLASS_SELECTABLE;
|
|
3265
|
-
this.element.style.position = 'absolute';
|
|
3266
|
-
this.element.style.pointerEvents = 'auto';
|
|
3267
|
-
|
|
3268
|
-
/**
|
|
3269
|
-
* @protected
|
|
3270
|
-
* @type {PanIntoViewOptions|undefined}
|
|
3271
|
-
*/
|
|
3272
|
-
this.autoPan = options.autoPan === true ? {} : options.autoPan || undefined;
|
|
3273
|
-
|
|
3274
|
-
/**
|
|
3275
|
-
* @protected
|
|
3276
|
-
* @type {{transform_: string,
|
|
3277
|
-
* visible: boolean}}
|
|
3278
|
-
*/
|
|
3279
|
-
this.rendered = {
|
|
3280
|
-
transform_: '',
|
|
3281
|
-
visible: true,
|
|
3282
|
-
};
|
|
3283
|
-
|
|
3284
|
-
/**
|
|
3285
|
-
* @protected
|
|
3286
|
-
* @type {?import("./events.js").EventsKey}
|
|
3287
|
-
*/
|
|
3288
|
-
this.mapPostrenderListenerKey = null;
|
|
3289
|
-
|
|
3290
|
-
this.addChangeListener(Property.ELEMENT, this.handleElementChanged);
|
|
3291
|
-
this.addChangeListener(Property.MAP, this.handleMapChanged);
|
|
3292
|
-
this.addChangeListener(Property.OFFSET, this.handleOffsetChanged);
|
|
3293
|
-
this.addChangeListener(Property.POSITION, this.handlePositionChanged);
|
|
3294
|
-
this.addChangeListener(Property.POSITIONING, this.handlePositioningChanged);
|
|
3295
|
-
|
|
3296
|
-
if (options.element !== undefined) {
|
|
3297
|
-
this.setElement(options.element);
|
|
3298
|
-
}
|
|
3299
|
-
|
|
3300
|
-
this.setOffset(options.offset !== undefined ? options.offset : [0, 0]);
|
|
3301
|
-
|
|
3302
|
-
this.setPositioning(options.positioning || 'top-left');
|
|
3303
|
-
|
|
3304
|
-
if (options.position !== undefined) {
|
|
3305
|
-
this.setPosition(options.position);
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
|
|
3309
|
-
/**
|
|
3310
|
-
* Get the DOM element of this overlay.
|
|
3311
|
-
* @return {HTMLElement|undefined} The Element containing the overlay.
|
|
3312
|
-
* @observable
|
|
3313
|
-
* @api
|
|
3314
|
-
*/
|
|
3315
|
-
getElement() {
|
|
3316
|
-
return /** @type {HTMLElement|undefined} */ (this.get(Property.ELEMENT));
|
|
3317
|
-
}
|
|
3318
|
-
|
|
3319
|
-
/**
|
|
3320
|
-
* Get the overlay identifier which is set on constructor.
|
|
3321
|
-
* @return {number|string|undefined} Id.
|
|
3322
|
-
* @api
|
|
3323
|
-
*/
|
|
3324
|
-
getId() {
|
|
3325
|
-
return this.id;
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
|
-
/**
|
|
3329
|
-
* Get the map associated with this overlay.
|
|
3330
|
-
* @return {import("./Map.js").default|null} The map that the
|
|
3331
|
-
* overlay is part of.
|
|
3332
|
-
* @observable
|
|
3333
|
-
* @api
|
|
3334
|
-
*/
|
|
3335
|
-
getMap() {
|
|
3336
|
-
return /** @type {import("./Map.js").default|null} */ (
|
|
3337
|
-
this.get(Property.MAP) || null
|
|
3338
|
-
);
|
|
3339
|
-
}
|
|
3340
|
-
|
|
3341
|
-
/**
|
|
3342
|
-
* Get the offset of this overlay.
|
|
3343
|
-
* @return {Array<number>} The offset.
|
|
3344
|
-
* @observable
|
|
3345
|
-
* @api
|
|
3346
|
-
*/
|
|
3347
|
-
getOffset() {
|
|
3348
|
-
return /** @type {Array<number>} */ (this.get(Property.OFFSET));
|
|
3349
|
-
}
|
|
3350
|
-
|
|
3351
|
-
/**
|
|
3352
|
-
* Get the current position of this overlay.
|
|
3353
|
-
* @return {import("./coordinate.js").Coordinate|undefined} The spatial point that the overlay is
|
|
3354
|
-
* anchored at.
|
|
3355
|
-
* @observable
|
|
3356
|
-
* @api
|
|
3357
|
-
*/
|
|
3358
|
-
getPosition() {
|
|
3359
|
-
return /** @type {import("./coordinate.js").Coordinate|undefined} */ (
|
|
3360
|
-
this.get(Property.POSITION)
|
|
3361
|
-
);
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3364
|
-
/**
|
|
3365
|
-
* Get the current positioning of this overlay.
|
|
3366
|
-
* @return {Positioning} How the overlay is positioned
|
|
3367
|
-
* relative to its point on the map.
|
|
3368
|
-
* @observable
|
|
3369
|
-
* @api
|
|
3370
|
-
*/
|
|
3371
|
-
getPositioning() {
|
|
3372
|
-
return /** @type {Positioning} */ (this.get(Property.POSITIONING));
|
|
3373
|
-
}
|
|
3374
|
-
|
|
3375
|
-
/**
|
|
3376
|
-
* @protected
|
|
3377
|
-
*/
|
|
3378
|
-
handleElementChanged() {
|
|
3379
|
-
removeChildren(this.element);
|
|
3380
|
-
const element = this.getElement();
|
|
3381
|
-
if (element) {
|
|
3382
|
-
this.element.appendChild(element);
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
|
|
3386
|
-
/**
|
|
3387
|
-
* @protected
|
|
3388
|
-
*/
|
|
3389
|
-
handleMapChanged() {
|
|
3390
|
-
if (this.mapPostrenderListenerKey) {
|
|
3391
|
-
removeNode(this.element);
|
|
3392
|
-
unlistenByKey(this.mapPostrenderListenerKey);
|
|
3393
|
-
this.mapPostrenderListenerKey = null;
|
|
3394
|
-
}
|
|
3395
|
-
const map = this.getMap();
|
|
3396
|
-
if (map) {
|
|
3397
|
-
this.mapPostrenderListenerKey = listen(
|
|
3398
|
-
map,
|
|
3399
|
-
MapEventType.POSTRENDER,
|
|
3400
|
-
this.render,
|
|
3401
|
-
this
|
|
3402
|
-
);
|
|
3403
|
-
this.updatePixelPosition();
|
|
3404
|
-
const container = this.stopEvent
|
|
3405
|
-
? map.getOverlayContainerStopEvent()
|
|
3406
|
-
: map.getOverlayContainer();
|
|
3407
|
-
if (this.insertFirst) {
|
|
3408
|
-
container.insertBefore(this.element, container.childNodes[0] || null);
|
|
3409
|
-
} else {
|
|
3410
|
-
container.appendChild(this.element);
|
|
3411
|
-
}
|
|
3412
|
-
this.performAutoPan();
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
|
|
3416
|
-
/**
|
|
3417
|
-
* @protected
|
|
3418
|
-
*/
|
|
3419
|
-
render() {
|
|
3420
|
-
this.updatePixelPosition();
|
|
3421
|
-
}
|
|
3422
|
-
|
|
3423
|
-
/**
|
|
3424
|
-
* @protected
|
|
3425
|
-
*/
|
|
3426
|
-
handleOffsetChanged() {
|
|
3427
|
-
this.updatePixelPosition();
|
|
3428
|
-
}
|
|
3429
|
-
|
|
3430
|
-
/**
|
|
3431
|
-
* @protected
|
|
3432
|
-
*/
|
|
3433
|
-
handlePositionChanged() {
|
|
3434
|
-
this.updatePixelPosition();
|
|
3435
|
-
this.performAutoPan();
|
|
3436
|
-
}
|
|
3437
|
-
|
|
3438
|
-
/**
|
|
3439
|
-
* @protected
|
|
3440
|
-
*/
|
|
3441
|
-
handlePositioningChanged() {
|
|
3442
|
-
this.updatePixelPosition();
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
/**
|
|
3446
|
-
* Set the DOM element to be associated with this overlay.
|
|
3447
|
-
* @param {HTMLElement|undefined} element The Element containing the overlay.
|
|
3448
|
-
* @observable
|
|
3449
|
-
* @api
|
|
3450
|
-
*/
|
|
3451
|
-
setElement(element) {
|
|
3452
|
-
this.set(Property.ELEMENT, element);
|
|
3453
|
-
}
|
|
3454
|
-
|
|
3455
|
-
/**
|
|
3456
|
-
* Set the map to be associated with this overlay.
|
|
3457
|
-
* @param {import("./Map.js").default|null} map The map that the
|
|
3458
|
-
* overlay is part of. Pass `null` to just remove the overlay from the current map.
|
|
3459
|
-
* @observable
|
|
3460
|
-
* @api
|
|
3461
|
-
*/
|
|
3462
|
-
setMap(map) {
|
|
3463
|
-
this.set(Property.MAP, map);
|
|
3464
|
-
}
|
|
3465
|
-
|
|
3466
|
-
/**
|
|
3467
|
-
* Set the offset for this overlay.
|
|
3468
|
-
* @param {Array<number>} offset Offset.
|
|
3469
|
-
* @observable
|
|
3470
|
-
* @api
|
|
3471
|
-
*/
|
|
3472
|
-
setOffset(offset) {
|
|
3473
|
-
this.set(Property.OFFSET, offset);
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3476
|
-
/**
|
|
3477
|
-
* Set the position for this overlay. If the position is `undefined` the
|
|
3478
|
-
* overlay is hidden.
|
|
3479
|
-
* @param {import("./coordinate.js").Coordinate|undefined} position The spatial point that the overlay
|
|
3480
|
-
* is anchored at.
|
|
3481
|
-
* @observable
|
|
3482
|
-
* @api
|
|
3483
|
-
*/
|
|
3484
|
-
setPosition(position) {
|
|
3485
|
-
this.set(Property.POSITION, position);
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
/**
|
|
3489
|
-
* Pan the map so that the overlay is entirely visible in the current viewport
|
|
3490
|
-
* (if necessary) using the configured autoPan parameters
|
|
3491
|
-
* @protected
|
|
3492
|
-
*/
|
|
3493
|
-
performAutoPan() {
|
|
3494
|
-
if (this.autoPan) {
|
|
3495
|
-
this.panIntoView(this.autoPan);
|
|
3496
|
-
}
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
/**
|
|
3500
|
-
* Pan the map so that the overlay is entirely visible in the current viewport
|
|
3501
|
-
* (if necessary).
|
|
3502
|
-
* @param {PanIntoViewOptions} [panIntoViewOptions] Options for the pan action
|
|
3503
|
-
* @api
|
|
3504
|
-
*/
|
|
3505
|
-
panIntoView(panIntoViewOptions) {
|
|
3506
|
-
const map = this.getMap();
|
|
3507
|
-
|
|
3508
|
-
if (!map || !map.getTargetElement() || !this.get(Property.POSITION)) {
|
|
3509
|
-
return;
|
|
3510
|
-
}
|
|
3511
|
-
|
|
3512
|
-
const mapRect = this.getRect(map.getTargetElement(), map.getSize());
|
|
3513
|
-
const element = this.getElement();
|
|
3514
|
-
const overlayRect = this.getRect(element, [
|
|
3515
|
-
outerWidth(element),
|
|
3516
|
-
outerHeight(element),
|
|
3517
|
-
]);
|
|
3518
|
-
|
|
3519
|
-
panIntoViewOptions = panIntoViewOptions || {};
|
|
3520
|
-
|
|
3521
|
-
const myMargin =
|
|
3522
|
-
panIntoViewOptions.margin === undefined ? 20 : panIntoViewOptions.margin;
|
|
3523
|
-
if (!containsExtent(mapRect, overlayRect)) {
|
|
3524
|
-
// the overlay is not completely inside the viewport, so pan the map
|
|
3525
|
-
const offsetLeft = overlayRect[0] - mapRect[0];
|
|
3526
|
-
const offsetRight = mapRect[2] - overlayRect[2];
|
|
3527
|
-
const offsetTop = overlayRect[1] - mapRect[1];
|
|
3528
|
-
const offsetBottom = mapRect[3] - overlayRect[3];
|
|
3529
|
-
|
|
3530
|
-
const delta = [0, 0];
|
|
3531
|
-
if (offsetLeft < 0) {
|
|
3532
|
-
// move map to the left
|
|
3533
|
-
delta[0] = offsetLeft - myMargin;
|
|
3534
|
-
} else if (offsetRight < 0) {
|
|
3535
|
-
// move map to the right
|
|
3536
|
-
delta[0] = Math.abs(offsetRight) + myMargin;
|
|
3537
|
-
}
|
|
3538
|
-
if (offsetTop < 0) {
|
|
3539
|
-
// move map up
|
|
3540
|
-
delta[1] = offsetTop - myMargin;
|
|
3541
|
-
} else if (offsetBottom < 0) {
|
|
3542
|
-
// move map down
|
|
3543
|
-
delta[1] = Math.abs(offsetBottom) + myMargin;
|
|
3544
|
-
}
|
|
3545
|
-
|
|
3546
|
-
if (delta[0] !== 0 || delta[1] !== 0) {
|
|
3547
|
-
const center = /** @type {import("./coordinate.js").Coordinate} */ (
|
|
3548
|
-
map.getView().getCenterInternal()
|
|
3549
|
-
);
|
|
3550
|
-
const centerPx = map.getPixelFromCoordinateInternal(center);
|
|
3551
|
-
if (!centerPx) {
|
|
3552
|
-
return;
|
|
3553
|
-
}
|
|
3554
|
-
const newCenterPx = [centerPx[0] + delta[0], centerPx[1] + delta[1]];
|
|
3555
|
-
|
|
3556
|
-
const panOptions = panIntoViewOptions.animation || {};
|
|
3557
|
-
map.getView().animateInternal({
|
|
3558
|
-
center: map.getCoordinateFromPixelInternal(newCenterPx),
|
|
3559
|
-
duration: panOptions.duration,
|
|
3560
|
-
easing: panOptions.easing,
|
|
3561
|
-
});
|
|
3562
|
-
}
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
1749
|
+
const geoserverOptions = options.geoserverVendor;
|
|
1750
|
+
Object.keys(geoserverOptions).forEach((param) => {
|
|
1751
|
+
source.urlParams.set(param, geoserverOptions[param]);
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* @public
|
|
1756
|
+
*/
|
|
1757
|
+
refresh() {
|
|
1758
|
+
const source = this.getSource();
|
|
1759
|
+
// Refrescamos el wms
|
|
1760
|
+
source.refresh();
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Use this to update Geoserver Wms Vendors (https://docs.geoserver.org/latest/en/user/services/wms/vendor.html)
|
|
1764
|
+
* and other arguements (https://docs.geoserver.org/stable/en/user/services/wms/reference.html#getmap)
|
|
1765
|
+
* in all the getMap requests.
|
|
1766
|
+
*
|
|
1767
|
+
* Example: you can use this to change the style of the WMS, add a custom sld, set a cql_filter, etc.
|
|
1768
|
+
*
|
|
1769
|
+
* @public
|
|
1770
|
+
* @param paramName
|
|
1771
|
+
* @param value Use `undefined` or `null` to remove the param
|
|
1772
|
+
* @param refresh
|
|
1773
|
+
*/
|
|
1774
|
+
setCustomParam(paramName, value = null, refresh = true) {
|
|
1775
|
+
const source = this.getSource();
|
|
1776
|
+
if (value === undefined || value === null) {
|
|
1777
|
+
source.urlParams.delete(paramName);
|
|
1778
|
+
}
|
|
1779
|
+
else {
|
|
1780
|
+
source.urlParams.set(paramName, value);
|
|
1781
|
+
}
|
|
1782
|
+
if (refresh) {
|
|
1783
|
+
this.refresh();
|
|
1784
|
+
}
|
|
1785
|
+
return source.urlParams;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
3565
1788
|
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
* @param {import("./size.js").Size} size The size of the element.
|
|
3570
|
-
* @return {import("./extent.js").Extent} The extent.
|
|
3571
|
-
* @protected
|
|
3572
|
-
*/
|
|
3573
|
-
getRect(element, size) {
|
|
3574
|
-
const box = element.getBoundingClientRect();
|
|
3575
|
-
const offsetX = box.left + window.pageXOffset;
|
|
3576
|
-
const offsetY = box.top + window.pageYOffset;
|
|
3577
|
-
return [offsetX, offsetY, offsetX + size[0], offsetY + size[1]];
|
|
3578
|
-
}
|
|
1789
|
+
/**
|
|
1790
|
+
* @module ol/TileState
|
|
1791
|
+
*/
|
|
3579
1792
|
|
|
1793
|
+
/**
|
|
1794
|
+
* @enum {number}
|
|
1795
|
+
*/
|
|
1796
|
+
var TileState = {
|
|
1797
|
+
IDLE: 0,
|
|
1798
|
+
LOADING: 1,
|
|
1799
|
+
LOADED: 2,
|
|
3580
1800
|
/**
|
|
3581
|
-
*
|
|
3582
|
-
* @
|
|
3583
|
-
* positioned relative to its point on the map.
|
|
3584
|
-
* @observable
|
|
3585
|
-
* @api
|
|
1801
|
+
* Indicates that tile loading failed
|
|
1802
|
+
* @type {number}
|
|
3586
1803
|
*/
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
1804
|
+
ERROR: 3,
|
|
1805
|
+
EMPTY: 4,
|
|
1806
|
+
};
|
|
3590
1807
|
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
1808
|
+
/**
|
|
1809
|
+
* Layer source to retrieve WMS information from geoservers
|
|
1810
|
+
* https://docs.geoserver.org/stable/en/user/services/wms/reference.html
|
|
1811
|
+
*
|
|
1812
|
+
* @extends {ol/source/TieWMS~TileWMS}
|
|
1813
|
+
* @param options
|
|
1814
|
+
*/
|
|
1815
|
+
class WmsSource extends TileWMS {
|
|
1816
|
+
constructor(options) {
|
|
1817
|
+
super(Object.assign({ url: options.geoserverUrl, serverType: 'geoserver', params: Object.assign({ SERVICE: 'wms', TILED: true, LAYERS: options.name, EXCEPTIONS: 'application/json' }, (options.geoserverVendor && options.geoserverVendor)), tileLoadFunction: async (tile, src) => {
|
|
1818
|
+
const blobToJson = (blob) => {
|
|
1819
|
+
return new Promise((resolve) => {
|
|
1820
|
+
const reader = new FileReader();
|
|
1821
|
+
reader.onloadend = () => resolve(JSON.parse(reader.result));
|
|
1822
|
+
reader.readAsText(blob);
|
|
1823
|
+
});
|
|
1824
|
+
};
|
|
1825
|
+
try {
|
|
1826
|
+
const response = await fetch(src, {
|
|
1827
|
+
headers: options.headers,
|
|
1828
|
+
credentials: options.credentials
|
|
1829
|
+
});
|
|
1830
|
+
if (!response.ok) {
|
|
1831
|
+
throw new Error('');
|
|
1832
|
+
}
|
|
1833
|
+
let data = await response.blob();
|
|
1834
|
+
// Check if the response has an error
|
|
1835
|
+
if (data.type == 'application/json') {
|
|
1836
|
+
const parsedError = await blobToJson(data);
|
|
1837
|
+
throw new Error(parseError(parsedError));
|
|
1838
|
+
}
|
|
1839
|
+
tile.getImage().src =
|
|
1840
|
+
URL.createObjectURL(data);
|
|
1841
|
+
tile.setState(TileState.LOADED);
|
|
1842
|
+
}
|
|
1843
|
+
catch (err) {
|
|
1844
|
+
showError(I18N.errors.geoserver, err, options.name);
|
|
1845
|
+
tile.setState(TileState.ERROR);
|
|
1846
|
+
}
|
|
1847
|
+
} }, options));
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
3602
1850
|
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
1851
|
+
/**
|
|
1852
|
+
* Layer to retrieve WMS information from geoservers
|
|
1853
|
+
* https://docs.geoserver.org/stable/en/user/services/wms/reference.html
|
|
1854
|
+
*
|
|
1855
|
+
* @fires layerRendered
|
|
1856
|
+
* @extends {ol/layer/Tile~TileLayer}
|
|
1857
|
+
* @param options
|
|
1858
|
+
*/
|
|
1859
|
+
class WmsLayer extends Mixin(BaseLayer, (TileLayer)) {
|
|
1860
|
+
constructor(options) {
|
|
1861
|
+
super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
|
|
1862
|
+
this._loadingCount = 0;
|
|
1863
|
+
this._loadedCount = 0;
|
|
1864
|
+
if (options.beforeTransactFeature) {
|
|
1865
|
+
this.beforeTransactFeature = options.beforeTransactFeature;
|
|
1866
|
+
}
|
|
1867
|
+
this._formatGeoJSON = new GeoJSON();
|
|
1868
|
+
const geoserver = options.geoserver;
|
|
1869
|
+
const source = new WmsSource({
|
|
1870
|
+
name: options.name,
|
|
1871
|
+
geoserverUrl: geoserver.getUrl(),
|
|
1872
|
+
geoServerAdvanced: geoserver.getAdvanced(),
|
|
1873
|
+
geoserverVendor: options.geoserverVendor
|
|
1874
|
+
});
|
|
1875
|
+
this._loadingCount = 0;
|
|
1876
|
+
this._loadedCount = 0;
|
|
1877
|
+
source.on('tileloadstart', () => {
|
|
1878
|
+
this._loadingCount++;
|
|
1879
|
+
if (this._loadingCount === 1 && this.isVisibleByZoom()) {
|
|
1880
|
+
showLoading();
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
source.on(['tileloadend', 'tileloaderror'], () => {
|
|
1884
|
+
this._loadedCount++;
|
|
1885
|
+
if (this._loadingCount === this._loadedCount) {
|
|
1886
|
+
this._loadingCount = 0;
|
|
1887
|
+
this._loadedCount = 0;
|
|
1888
|
+
setTimeout(() => {
|
|
1889
|
+
this.dispatchEvent('layerRendered');
|
|
1890
|
+
}, 300);
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
this.setSource(source);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Get the features on the click area
|
|
1897
|
+
* @param evt
|
|
1898
|
+
* @returns
|
|
1899
|
+
* @private
|
|
1900
|
+
*/
|
|
1901
|
+
async _getFeaturesByClickEvent(evt) {
|
|
1902
|
+
const coordinate = evt.coordinate;
|
|
1903
|
+
const view = getMap().getView();
|
|
1904
|
+
// Si la vista es lejana, disminumos el buffer
|
|
1905
|
+
// Si es cercana, lo aumentamos, por ejemplo, para podeer clickear los vectores
|
|
1906
|
+
// y mejorar la sensibilidad en IOS
|
|
1907
|
+
const buffer = view.getZoom() > 10 ? 10 : 5;
|
|
1908
|
+
const source = this.getSource();
|
|
1909
|
+
// Fallback to support a bad name
|
|
1910
|
+
// https://openlayers.org/en/v5.3.0/apidoc/module-ol_source_ImageWMS-ImageWMS.html#getGetFeatureInfoUrl
|
|
1911
|
+
const fallbackOl5 = 'getFeatureInfoUrl' in source
|
|
1912
|
+
? 'getFeatureInfoUrl'
|
|
1913
|
+
: 'getGetFeatureInfoUrl';
|
|
1914
|
+
const url = source[fallbackOl5](coordinate, view.getResolution(), view.getProjection().getCode(), {
|
|
1915
|
+
INFO_FORMAT: 'application/json',
|
|
1916
|
+
BUFFER: buffer,
|
|
1917
|
+
FEATURE_COUNT: 1,
|
|
1918
|
+
EXCEPTIONS: 'application/json'
|
|
1919
|
+
});
|
|
1920
|
+
const geoserver = this.getGeoserver();
|
|
1921
|
+
try {
|
|
1922
|
+
const response = await fetch(url, {
|
|
1923
|
+
headers: geoserver.getHeaders(),
|
|
1924
|
+
credentials: geoserver.getCredentials()
|
|
1925
|
+
});
|
|
1926
|
+
if (!response.ok) {
|
|
1927
|
+
throw new Error(`${I18N.errors.getFeatures} ${response.status}`);
|
|
1928
|
+
}
|
|
1929
|
+
const data = await response.json();
|
|
1930
|
+
const features = this._formatGeoJSON.readFeatures(data);
|
|
1931
|
+
return features;
|
|
1932
|
+
}
|
|
1933
|
+
catch (err) {
|
|
1934
|
+
showError(err.message, err);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* @public
|
|
1939
|
+
*/
|
|
1940
|
+
refresh() {
|
|
1941
|
+
const source = this.getSource();
|
|
1942
|
+
// Refrescamos el wms
|
|
1943
|
+
source.refresh();
|
|
1944
|
+
// Force refresh the tiles
|
|
1945
|
+
const params = source.getParams();
|
|
1946
|
+
params.t = new Date().getMilliseconds();
|
|
1947
|
+
source.updateParams(params);
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Use this to update Geoserver Wfs Vendors (https://docs.geoserver.org/latest/en/user/services/wfs/vendor.html)
|
|
1951
|
+
* and other arguements (https://docs.geoserver.org/stable/en/user/services/wfs/reference.html)
|
|
1952
|
+
* in all the getFeature requests.
|
|
1953
|
+
*
|
|
1954
|
+
* Example: you can use this to set a cql_filter, limit the numbers of features, etc.
|
|
1955
|
+
*
|
|
1956
|
+
* @public
|
|
1957
|
+
* @param paramName
|
|
1958
|
+
* @param value
|
|
1959
|
+
* @param refresh
|
|
1960
|
+
*/
|
|
1961
|
+
setCustomParam(paramName, value = null, refresh = true) {
|
|
1962
|
+
const source = this.getSource();
|
|
1963
|
+
source.updateParams({
|
|
1964
|
+
[paramName]: value
|
|
1965
|
+
});
|
|
1966
|
+
if (refresh) {
|
|
1967
|
+
this.refresh();
|
|
1968
|
+
}
|
|
1969
|
+
return source.getParams();
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
3614
1972
|
|
|
3615
|
-
|
|
3616
|
-
const mapSize = map.getSize();
|
|
3617
|
-
this.updateRenderedPosition(pixel, mapSize);
|
|
3618
|
-
}
|
|
1973
|
+
var img$5 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e";
|
|
3619
1974
|
|
|
3620
|
-
|
|
3621
|
-
* @param {import("./pixel.js").Pixel} pixel The pixel location.
|
|
3622
|
-
* @param {import("./size.js").Size|undefined} mapSize The map size.
|
|
3623
|
-
* @protected
|
|
3624
|
-
*/
|
|
3625
|
-
updateRenderedPosition(pixel, mapSize) {
|
|
3626
|
-
const style = this.element.style;
|
|
3627
|
-
const offset = this.getOffset();
|
|
3628
|
-
|
|
3629
|
-
const positioning = this.getPositioning();
|
|
3630
|
-
|
|
3631
|
-
this.setVisible(true);
|
|
3632
|
-
|
|
3633
|
-
const x = Math.round(pixel[0] + offset[0]) + 'px';
|
|
3634
|
-
const y = Math.round(pixel[1] + offset[1]) + 'px';
|
|
3635
|
-
let posX = '0%';
|
|
3636
|
-
let posY = '0%';
|
|
3637
|
-
if (
|
|
3638
|
-
positioning == 'bottom-right' ||
|
|
3639
|
-
positioning == 'center-right' ||
|
|
3640
|
-
positioning == 'top-right'
|
|
3641
|
-
) {
|
|
3642
|
-
posX = '-100%';
|
|
3643
|
-
} else if (
|
|
3644
|
-
positioning == 'bottom-center' ||
|
|
3645
|
-
positioning == 'center-center' ||
|
|
3646
|
-
positioning == 'top-center'
|
|
3647
|
-
) {
|
|
3648
|
-
posX = '-50%';
|
|
3649
|
-
}
|
|
3650
|
-
if (
|
|
3651
|
-
positioning == 'bottom-left' ||
|
|
3652
|
-
positioning == 'bottom-center' ||
|
|
3653
|
-
positioning == 'bottom-right'
|
|
3654
|
-
) {
|
|
3655
|
-
posY = '-100%';
|
|
3656
|
-
} else if (
|
|
3657
|
-
positioning == 'center-left' ||
|
|
3658
|
-
positioning == 'center-center' ||
|
|
3659
|
-
positioning == 'center-right'
|
|
3660
|
-
) {
|
|
3661
|
-
posY = '-50%';
|
|
3662
|
-
}
|
|
3663
|
-
const transform = `translate(${posX}, ${posY}) translate(${x}, ${y})`;
|
|
3664
|
-
if (this.rendered.transform_ != transform) {
|
|
3665
|
-
this.rendered.transform_ = transform;
|
|
3666
|
-
style.transform = transform;
|
|
3667
|
-
}
|
|
3668
|
-
}
|
|
1975
|
+
var img$4 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e";
|
|
3669
1976
|
|
|
3670
|
-
|
|
3671
|
-
* returns the options this Overlay has been created with
|
|
3672
|
-
* @return {Options} overlay options
|
|
3673
|
-
*/
|
|
3674
|
-
getOptions() {
|
|
3675
|
-
return this.options;
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
1977
|
+
var img$3 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e";
|
|
3678
1978
|
|
|
3679
|
-
var
|
|
1979
|
+
var img$2 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e";
|
|
3680
1980
|
|
|
3681
1981
|
function createElement(tagName, attrs = {}, ...children) {
|
|
3682
1982
|
if (typeof tagName === 'function')
|
|
@@ -3715,14 +2015,6 @@
|
|
|
3715
2015
|
return elem;
|
|
3716
2016
|
}
|
|
3717
2017
|
|
|
3718
|
-
var img$5 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e";
|
|
3719
|
-
|
|
3720
|
-
var img$4 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e";
|
|
3721
|
-
|
|
3722
|
-
var img$3 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e";
|
|
3723
|
-
|
|
3724
|
-
var img$2 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e";
|
|
3725
|
-
|
|
3726
2018
|
/**
|
|
3727
2019
|
* Removes in the DOM the class of the tools
|
|
3728
2020
|
* @private
|
|
@@ -3745,9 +2037,7 @@
|
|
|
3745
2037
|
btn.classList.add('wfst--active');
|
|
3746
2038
|
}
|
|
3747
2039
|
};
|
|
3748
|
-
class LayersControl extends Observable
|
|
3749
|
-
_uploads;
|
|
3750
|
-
_uploadFormats;
|
|
2040
|
+
class LayersControl extends Observable {
|
|
3751
2041
|
constructor(uploads, uploadFormats) {
|
|
3752
2042
|
super();
|
|
3753
2043
|
this._uploads = uploads;
|
|
@@ -3761,17 +2051,17 @@
|
|
|
3761
2051
|
addLayerEl(layer) {
|
|
3762
2052
|
const container = document.querySelector('.wfst--tools-control--select-layers');
|
|
3763
2053
|
const layerName = layer.get(BaseLayerProperty.NAME);
|
|
3764
|
-
const checked = layer === getActiveLayerToInsertEls() ? { checked:
|
|
3765
|
-
const input = (createElement("input", { value: layerName, id: `wfst--${layerName}`, type: "radio", className: "ol-wfst--tools-control-input", name: "wfst--select-layer",
|
|
2054
|
+
const checked = layer === getActiveLayerToInsertEls() ? { checked: true } : {};
|
|
2055
|
+
const input = (createElement("input", Object.assign({ value: layerName, id: `wfst--${layerName}`, type: "radio", className: "ol-wfst--tools-control-input", name: "wfst--select-layer" }, checked, { onChange: (evt) => this._layerChangeHandler(evt, layer) })));
|
|
3766
2056
|
const layerDom = (createElement("div", { className: `wfst--layer-control
|
|
3767
2057
|
${layer.getVisible() ? 'ol-wfst--visible-on' : ''}
|
|
3768
2058
|
${layer === getActiveLayerToInsertEls()
|
|
3769
2059
|
? 'ol-wfst--selected-on'
|
|
3770
2060
|
: ''}`, "data-layer": layerName },
|
|
3771
2061
|
createElement("div", { className: "ol-wfst--tools-control-visible" },
|
|
3772
|
-
createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility,
|
|
2062
|
+
createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
|
|
3773
2063
|
createElement("img", { src: img$3 })),
|
|
3774
|
-
createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility,
|
|
2064
|
+
createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
|
|
3775
2065
|
createElement("img", { src: img$2 }))),
|
|
3776
2066
|
createElement("label", { htmlFor: `wfst--${layerName}` },
|
|
3777
2067
|
input,
|
|
@@ -3870,17 +2160,16 @@
|
|
|
3870
2160
|
return (createElement(null, null,
|
|
3871
2161
|
createElement("div", { className: "wfst--tools-control--head" },
|
|
3872
2162
|
this._uploads && (createElement("div", null,
|
|
3873
|
-
createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats,
|
|
2163
|
+
createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats, onChange: (evt) => this._uploads.process(evt) }),
|
|
3874
2164
|
createElement("label", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload", htmlFor: "ol-wfst--upload", title: I18N.labels.uploadToLayer },
|
|
3875
2165
|
createElement("img", { src: img$5 })))),
|
|
3876
2166
|
createElement("div", { className: "ol-wfst--tools-control-draw-cnt" },
|
|
3877
|
-
createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement,
|
|
2167
|
+
createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement, onClick: () => {
|
|
3878
2168
|
this.dispatchEvent('drawMode');
|
|
3879
2169
|
} },
|
|
3880
2170
|
createElement("img", { src: img$4 })),
|
|
3881
|
-
createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw",
|
|
3882
|
-
const selectedValue = evt.target
|
|
3883
|
-
.value;
|
|
2171
|
+
createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw", onChange: (evt) => {
|
|
2172
|
+
const selectedValue = evt.target.value;
|
|
3884
2173
|
this._changeStateSelect(getActiveLayerToInsertEls(), selectedValue);
|
|
3885
2174
|
this.dispatchEvent('changeGeom');
|
|
3886
2175
|
} }, [
|
|
@@ -3908,22 +2197,15 @@
|
|
|
3908
2197
|
};
|
|
3909
2198
|
|
|
3910
2199
|
// Ol
|
|
3911
|
-
class Uploads extends Observable
|
|
3912
|
-
_options;
|
|
3913
|
-
// Formats
|
|
3914
|
-
_formatWFS;
|
|
3915
|
-
_formatGeoJSON;
|
|
3916
|
-
_formatKml;
|
|
3917
|
-
_xs;
|
|
3918
|
-
_processUpload;
|
|
2200
|
+
class Uploads extends Observable {
|
|
3919
2201
|
constructor(options) {
|
|
3920
2202
|
super();
|
|
3921
2203
|
this._options = options;
|
|
3922
2204
|
this._processUpload = options.processUpload;
|
|
3923
2205
|
// Formats
|
|
3924
|
-
this._formatWFS = new
|
|
3925
|
-
this._formatGeoJSON = new
|
|
3926
|
-
this._formatKml = new
|
|
2206
|
+
this._formatWFS = new WFS();
|
|
2207
|
+
this._formatGeoJSON = new GeoJSON();
|
|
2208
|
+
this._formatKml = new KML({
|
|
3927
2209
|
extractStyles: false,
|
|
3928
2210
|
showPointNames: false
|
|
3929
2211
|
});
|
|
@@ -4033,34 +2315,34 @@
|
|
|
4033
2315
|
const geomTypeLayer = getActiveLayerToInsertEls().getDescribeFeatureType()._parsed
|
|
4034
2316
|
.geomType;
|
|
4035
2317
|
const geomTypeFeature = feature.getGeometry().getType();
|
|
4036
|
-
let geom
|
|
2318
|
+
let geom;
|
|
4037
2319
|
switch (geomTypeFeature) {
|
|
4038
2320
|
case GeometryType.Point: {
|
|
4039
2321
|
if (geomTypeLayer === GeometryType.MultiPoint) {
|
|
4040
2322
|
const coords = feature.getGeometry().getCoordinates();
|
|
4041
|
-
geom
|
|
2323
|
+
geom = new geom_js.MultiPoint([coords]);
|
|
4042
2324
|
}
|
|
4043
2325
|
break;
|
|
4044
2326
|
}
|
|
4045
2327
|
case GeometryType.LineString:
|
|
4046
2328
|
if (geomTypeLayer === GeometryType.MultiLineString) {
|
|
4047
2329
|
const coords = feature.getGeometry().getCoordinates();
|
|
4048
|
-
geom
|
|
2330
|
+
geom = new geom_js.MultiLineString([coords]);
|
|
4049
2331
|
}
|
|
4050
2332
|
break;
|
|
4051
2333
|
case GeometryType.Polygon:
|
|
4052
2334
|
if (geomTypeLayer === GeometryType.MultiPolygon) {
|
|
4053
2335
|
const coords = feature.getGeometry().getCoordinates();
|
|
4054
|
-
geom
|
|
2336
|
+
geom = new geom_js.MultiPolygon([coords]);
|
|
4055
2337
|
}
|
|
4056
2338
|
break;
|
|
4057
2339
|
default:
|
|
4058
|
-
geom
|
|
2340
|
+
geom = null;
|
|
4059
2341
|
}
|
|
4060
|
-
if (!geom
|
|
2342
|
+
if (!geom) {
|
|
4061
2343
|
return null;
|
|
4062
2344
|
}
|
|
4063
|
-
feature.setGeometry(geom
|
|
2345
|
+
feature.setGeometry(geom);
|
|
4064
2346
|
return feature;
|
|
4065
2347
|
}
|
|
4066
2348
|
/**
|
|
@@ -4095,17 +2377,9 @@
|
|
|
4095
2377
|
${I18N.labels.upload}
|
|
4096
2378
|
</button>
|
|
4097
2379
|
`;
|
|
4098
|
-
const modal = new Modal({
|
|
4099
|
-
...this._options.modal,
|
|
4100
|
-
header: true,
|
|
4101
|
-
headerClose: false,
|
|
4102
|
-
title: I18N.labels.uploadFeatures +
|
|
2380
|
+
const modal = new Modal(Object.assign(Object.assign({}, this._options.modal), { header: true, headerClose: false, title: I18N.labels.uploadFeatures +
|
|
4103
2381
|
' ' +
|
|
4104
|
-
getActiveLayerToInsertEls().get(BaseLayerProperty.NAME),
|
|
4105
|
-
content: content,
|
|
4106
|
-
backdrop: 'static',
|
|
4107
|
-
footer: footer
|
|
4108
|
-
}).show();
|
|
2382
|
+
getActiveLayerToInsertEls().get(BaseLayerProperty.NAME), content: content, backdrop: 'static', footer: footer })).show();
|
|
4109
2383
|
modal.on('dismiss', (modal, event) => {
|
|
4110
2384
|
// On saving changes
|
|
4111
2385
|
if (event.target.dataset.action === 'save') {
|
|
@@ -4165,7 +2439,7 @@
|
|
|
4165
2439
|
};
|
|
4166
2440
|
};
|
|
4167
2441
|
|
|
4168
|
-
class EditControlChangesEl extends
|
|
2442
|
+
class EditControlChangesEl extends Control {
|
|
4169
2443
|
constructor(feature) {
|
|
4170
2444
|
super({
|
|
4171
2445
|
element: (createElement("div", { className: "ol-wfst--changes-control" },
|
|
@@ -4175,13 +2449,13 @@
|
|
|
4175
2449
|
" -",
|
|
4176
2450
|
' ',
|
|
4177
2451
|
createElement("i", null, String(feature.getId()))),
|
|
4178
|
-
createElement("button", { type: "button", className: "btn btn-sm btn-secondary",
|
|
2452
|
+
createElement("button", { type: "button", className: "btn btn-sm btn-secondary", onClick: () => {
|
|
4179
2453
|
this.dispatchEvent(new VectorSource.VectorSourceEvent('cancel', feature));
|
|
4180
2454
|
} }, I18N.labels.cancel),
|
|
4181
|
-
createElement("button", { type: "button", className: "btn btn-sm btn-primary",
|
|
2455
|
+
createElement("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => {
|
|
4182
2456
|
this.dispatchEvent(new VectorSource.VectorSourceEvent('apply', feature));
|
|
4183
2457
|
} }, I18N.labels.apply),
|
|
4184
|
-
createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline",
|
|
2458
|
+
createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline", onClick: () => {
|
|
4185
2459
|
this.dispatchEvent(new VectorSource.VectorSourceEvent('delete', feature));
|
|
4186
2460
|
} }, I18N.labels.delete))))
|
|
4187
2461
|
});
|
|
@@ -4200,16 +2474,16 @@
|
|
|
4200
2474
|
function styleFunction(feature) {
|
|
4201
2475
|
const getVertexs = (feature) => {
|
|
4202
2476
|
let geometry = feature.getGeometry();
|
|
4203
|
-
if (geometry instanceof
|
|
2477
|
+
if (geometry instanceof geom_js.GeometryCollection) {
|
|
4204
2478
|
geometry = geometry.getGeometries()[0];
|
|
4205
2479
|
}
|
|
4206
2480
|
const coordinates = geometry.getCoordinates();
|
|
4207
2481
|
let flatCoordinates = null;
|
|
4208
|
-
if (geometry instanceof
|
|
4209
|
-
geometry instanceof
|
|
2482
|
+
if (geometry instanceof geom_js.Polygon ||
|
|
2483
|
+
geometry instanceof geom_js.MultiLineString) {
|
|
4210
2484
|
flatCoordinates = coordinates.flat(1);
|
|
4211
2485
|
}
|
|
4212
|
-
else if (geometry instanceof
|
|
2486
|
+
else if (geometry instanceof geom_js.MultiPolygon) {
|
|
4213
2487
|
flatCoordinates = coordinates.flat(2);
|
|
4214
2488
|
}
|
|
4215
2489
|
else {
|
|
@@ -4218,11 +2492,11 @@
|
|
|
4218
2492
|
if (!flatCoordinates || !flatCoordinates.length) {
|
|
4219
2493
|
return;
|
|
4220
2494
|
}
|
|
4221
|
-
return new
|
|
2495
|
+
return new geom_js.MultiPoint(flatCoordinates);
|
|
4222
2496
|
};
|
|
4223
2497
|
let geometry = feature.getGeometry();
|
|
4224
2498
|
let type = geometry.getType();
|
|
4225
|
-
if (geometry instanceof
|
|
2499
|
+
if (geometry instanceof geom_js.GeometryCollection) {
|
|
4226
2500
|
geometry = geometry.getGeometries()[0];
|
|
4227
2501
|
type = geometry.getType();
|
|
4228
2502
|
}
|
|
@@ -4231,18 +2505,18 @@
|
|
|
4231
2505
|
case GeometryType.MultiPoint:
|
|
4232
2506
|
if (getMode() === Modes.Edit) {
|
|
4233
2507
|
return [
|
|
4234
|
-
new
|
|
4235
|
-
image: new
|
|
2508
|
+
new style_js.Style({
|
|
2509
|
+
image: new style_js.Circle({
|
|
4236
2510
|
radius: 6,
|
|
4237
|
-
fill: new
|
|
2511
|
+
fill: new style_js.Fill({
|
|
4238
2512
|
color: '#000000'
|
|
4239
2513
|
})
|
|
4240
2514
|
})
|
|
4241
2515
|
}),
|
|
4242
|
-
new
|
|
4243
|
-
image: new
|
|
2516
|
+
new style_js.Style({
|
|
2517
|
+
image: new style_js.Circle({
|
|
4244
2518
|
radius: 4,
|
|
4245
|
-
fill: new
|
|
2519
|
+
fill: new style_js.Fill({
|
|
4246
2520
|
color: '#ff0000'
|
|
4247
2521
|
})
|
|
4248
2522
|
})
|
|
@@ -4251,18 +2525,18 @@
|
|
|
4251
2525
|
}
|
|
4252
2526
|
else {
|
|
4253
2527
|
return [
|
|
4254
|
-
new
|
|
4255
|
-
image: new
|
|
2528
|
+
new style_js.Style({
|
|
2529
|
+
image: new style_js.Circle({
|
|
4256
2530
|
radius: 5,
|
|
4257
|
-
fill: new
|
|
2531
|
+
fill: new style_js.Fill({
|
|
4258
2532
|
color: '#ff0000'
|
|
4259
2533
|
})
|
|
4260
2534
|
})
|
|
4261
2535
|
}),
|
|
4262
|
-
new
|
|
4263
|
-
image: new
|
|
2536
|
+
new style_js.Style({
|
|
2537
|
+
image: new style_js.Circle({
|
|
4264
2538
|
radius: 2,
|
|
4265
|
-
fill: new
|
|
2539
|
+
fill: new style_js.Fill({
|
|
4266
2540
|
color: '#000000'
|
|
4267
2541
|
})
|
|
4268
2542
|
})
|
|
@@ -4273,30 +2547,30 @@
|
|
|
4273
2547
|
// If editing mode is active, show bigger vertex
|
|
4274
2548
|
if (getMode() == Modes.Draw || getMode() == Modes.Edit) {
|
|
4275
2549
|
return [
|
|
4276
|
-
new
|
|
4277
|
-
stroke: new
|
|
2550
|
+
new style_js.Style({
|
|
2551
|
+
stroke: new style_js.Stroke({
|
|
4278
2552
|
color: 'rgba( 255, 0, 0, 1)',
|
|
4279
2553
|
width: 4
|
|
4280
2554
|
}),
|
|
4281
|
-
fill: new
|
|
2555
|
+
fill: new style_js.Fill({
|
|
4282
2556
|
color: 'rgba(255, 0, 0, 0.7)'
|
|
4283
2557
|
})
|
|
4284
2558
|
}),
|
|
4285
|
-
new
|
|
4286
|
-
image: new
|
|
2559
|
+
new style_js.Style({
|
|
2560
|
+
image: new style_js.Circle({
|
|
4287
2561
|
radius: 4,
|
|
4288
|
-
fill: new
|
|
2562
|
+
fill: new style_js.Fill({
|
|
4289
2563
|
color: '#ff0000'
|
|
4290
2564
|
}),
|
|
4291
|
-
stroke: new
|
|
2565
|
+
stroke: new style_js.Stroke({
|
|
4292
2566
|
width: 2,
|
|
4293
2567
|
color: 'rgba(5, 5, 5, 0.9)'
|
|
4294
2568
|
})
|
|
4295
2569
|
}),
|
|
4296
2570
|
geometry: (feature) => getVertexs(feature)
|
|
4297
2571
|
}),
|
|
4298
|
-
new
|
|
4299
|
-
stroke: new
|
|
2572
|
+
new style_js.Style({
|
|
2573
|
+
stroke: new style_js.Stroke({
|
|
4300
2574
|
color: 'rgba(255, 255, 255, 0.7)',
|
|
4301
2575
|
width: 2
|
|
4302
2576
|
})
|
|
@@ -4305,21 +2579,21 @@
|
|
|
4305
2579
|
}
|
|
4306
2580
|
else {
|
|
4307
2581
|
return [
|
|
4308
|
-
new
|
|
4309
|
-
image: new
|
|
2582
|
+
new style_js.Style({
|
|
2583
|
+
image: new style_js.Circle({
|
|
4310
2584
|
radius: 2,
|
|
4311
|
-
fill: new
|
|
2585
|
+
fill: new style_js.Fill({
|
|
4312
2586
|
color: '#000000'
|
|
4313
2587
|
})
|
|
4314
2588
|
}),
|
|
4315
2589
|
geometry: (feature) => getVertexs(feature)
|
|
4316
2590
|
}),
|
|
4317
|
-
new
|
|
4318
|
-
stroke: new
|
|
2591
|
+
new style_js.Style({
|
|
2592
|
+
stroke: new style_js.Stroke({
|
|
4319
2593
|
color: '#ff0000',
|
|
4320
2594
|
width: 4
|
|
4321
2595
|
}),
|
|
4322
|
-
fill: new
|
|
2596
|
+
fill: new style_js.Fill({
|
|
4323
2597
|
color: 'rgba(255, 0, 0, 0.7)'
|
|
4324
2598
|
})
|
|
4325
2599
|
})
|
|
@@ -4335,10 +2609,7 @@
|
|
|
4335
2609
|
* @param feature
|
|
4336
2610
|
* @private
|
|
4337
2611
|
*/
|
|
4338
|
-
class EditFieldsModal extends Observable
|
|
4339
|
-
_options;
|
|
4340
|
-
_modal;
|
|
4341
|
-
_feature;
|
|
2612
|
+
class EditFieldsModal extends Observable {
|
|
4342
2613
|
constructor(options) {
|
|
4343
2614
|
super();
|
|
4344
2615
|
this._options = options;
|
|
@@ -4353,14 +2624,7 @@
|
|
|
4353
2624
|
${I18N.labels.save}
|
|
4354
2625
|
</button>
|
|
4355
2626
|
`;
|
|
4356
|
-
this._modal = new Modal({
|
|
4357
|
-
...this._options,
|
|
4358
|
-
header: true,
|
|
4359
|
-
headerClose: true,
|
|
4360
|
-
title: '',
|
|
4361
|
-
content: '<div></div>',
|
|
4362
|
-
footer: footer
|
|
4363
|
-
});
|
|
2627
|
+
this._modal = new Modal(Object.assign(Object.assign({}, this._options), { header: true, headerClose: true, title: '', content: '<div></div>', footer: footer }));
|
|
4364
2628
|
this._modal.on('dismiss', (modal, event) => {
|
|
4365
2629
|
// On saving changes
|
|
4366
2630
|
if (event.target.dataset.action === 'save') {
|
|
@@ -4433,18 +2697,7 @@
|
|
|
4433
2697
|
* @extends {ol/Object~BaseObject}
|
|
4434
2698
|
* @param options
|
|
4435
2699
|
*/
|
|
4436
|
-
class Geoserver extends BaseObject
|
|
4437
|
-
_options;
|
|
4438
|
-
_countRequests;
|
|
4439
|
-
_insertFeatures;
|
|
4440
|
-
_updateFeatures;
|
|
4441
|
-
_deleteFeatures;
|
|
4442
|
-
// Formats
|
|
4443
|
-
_formatWFS;
|
|
4444
|
-
_formatGeoJSON;
|
|
4445
|
-
_formatKml;
|
|
4446
|
-
_xs;
|
|
4447
|
-
state_;
|
|
2700
|
+
class Geoserver extends BaseObject {
|
|
4448
2701
|
constructor(options) {
|
|
4449
2702
|
super();
|
|
4450
2703
|
const defaults = {
|
|
@@ -4784,10 +3037,7 @@
|
|
|
4784
3037
|
transactionType !== TransactionType.Insert) {
|
|
4785
3038
|
payload = payload.replace(`</Transaction>`, `<LockId>${this._options.advanced.lockFeatureParams.lockId}</LockId></Transaction>`);
|
|
4786
3039
|
}
|
|
4787
|
-
const headers = {
|
|
4788
|
-
'Content-Type': 'text/xml',
|
|
4789
|
-
...this.getHeaders()
|
|
4790
|
-
};
|
|
3040
|
+
const headers = Object.assign({ 'Content-Type': 'text/xml' }, this.getHeaders());
|
|
4791
3041
|
const response = await fetch(this.getUrl(), {
|
|
4792
3042
|
method: 'POST',
|
|
4793
3043
|
body: payload,
|
|
@@ -4845,7 +3095,7 @@
|
|
|
4845
3095
|
* @private
|
|
4846
3096
|
*/
|
|
4847
3097
|
_transformCircleToPolygon(feature, geom) {
|
|
4848
|
-
const geomConverted =
|
|
3098
|
+
const geomConverted = Polygon_js.fromCircle(geom);
|
|
4849
3099
|
feature.setGeometry(geomConverted);
|
|
4850
3100
|
}
|
|
4851
3101
|
/**
|
|
@@ -4857,7 +3107,7 @@
|
|
|
4857
3107
|
_transformGeoemtryCollectionToGeometries(feature, geom) {
|
|
4858
3108
|
let geomConverted = geom.getGeometries()[0];
|
|
4859
3109
|
if (geomConverted instanceof Circle) {
|
|
4860
|
-
geomConverted =
|
|
3110
|
+
geomConverted = Polygon_js.fromCircle(geomConverted);
|
|
4861
3111
|
}
|
|
4862
3112
|
feature.setGeometry(geomConverted);
|
|
4863
3113
|
}
|
|
@@ -4969,21 +3219,21 @@
|
|
|
4969
3219
|
|
|
4970
3220
|
var img = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='541' height='512' viewBox='0 0 541 512'%3e %3cpath fill='black' d='M103.306 228.483l129.493-125.249c-17.662-4.272-31.226-18.148-34.98-35.663l-0.055-0.307-129.852 125.248c17.812 4.15 31.53 18.061 35.339 35.662l0.056 0.308z'%3e%3c/path%3e %3cpath fill='black' d='M459.052 393.010c-13.486-8.329-22.346-23.018-22.373-39.779v-0.004c-0.053-0.817-0.082-1.772-0.082-2.733s0.030-1.916 0.089-2.863l-0.007 0.13-149.852 71.94c9.598 8.565 15.611 20.969 15.611 34.779 0 0.014 0 0.029 0 0.043v-0.002c-0.048 5.164-0.94 10.104-2.544 14.711l0.098-0.322z'%3e%3c/path%3e %3cpath fill='black' d='M290.207 57.553c-0.009 15.55-7.606 29.324-19.289 37.819l-0.135 0.093 118.054 46.69c-0.216-1.608-0.346-3.48-0.36-5.379v-0.017c0.033-16.948 9.077-31.778 22.596-39.953l0.209-0.118-122.298-48.056c0.659 2.633 1.098 5.693 1.221 8.834l0.002 0.087z'%3e%3c/path%3e %3cpath fill='black' d='M241.36 410.132l-138.629-160.067c-4.734 17.421-18.861 30.61-36.472 33.911l-0.29 0.045 143.881 166.255c1.668-18.735 14.197-34.162 31.183-40.044l0.327-0.099z'%3e%3c/path%3e %3cpath fill='black' d='M243.446 115.105c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM243.446 21.582c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.104-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M483.224 410.78c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM483.224 317.257c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M57.553 295.531c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM57.553 202.008c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c-0.041-19.835-16.13-35.898-35.97-35.898 0 0 0 0 0 0v0z'%3e%3c/path%3e %3cpath fill='black' d='M256.036 512.072c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM256.036 418.55c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M435.24 194.239c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.785-25.767 57.553-57.553 57.553v0zM435.24 100.716c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e%3c/svg%3e";
|
|
4971
3221
|
|
|
4972
|
-
class EditOverlay extends Overlay
|
|
3222
|
+
class EditOverlay extends Overlay {
|
|
4973
3223
|
constructor(feature, coordinate = null) {
|
|
4974
3224
|
super({
|
|
4975
3225
|
id: feature.getId(),
|
|
4976
|
-
position: coordinate ||
|
|
3226
|
+
position: coordinate || extent_js.getCenter(feature.getGeometry().getExtent()),
|
|
4977
3227
|
positioning: 'center-center',
|
|
4978
3228
|
offset: [0, -40],
|
|
4979
3229
|
stopEvent: true,
|
|
4980
3230
|
element: (createElement("div", null,
|
|
4981
|
-
createElement("div", { className: "ol-wfst--edit-button-cnt",
|
|
3231
|
+
createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
|
|
4982
3232
|
this.dispatchEvent('editFields');
|
|
4983
3233
|
} },
|
|
4984
3234
|
createElement("button", { className: "ol-wfst--edit-button", type: "button", title: I18N.labels.editFields },
|
|
4985
3235
|
createElement("img", { src: img$1, alt: I18N.labels.editFields }))),
|
|
4986
|
-
createElement("div", { className: "ol-wfst--edit-button-cnt",
|
|
3236
|
+
createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
|
|
4987
3237
|
this.dispatchEvent('editGeom');
|
|
4988
3238
|
} },
|
|
4989
3239
|
createElement("button", { class: "ol-wfst--edit-button", type: "button", title: I18N.labels.editGeom },
|
|
@@ -5011,38 +3261,6 @@
|
|
|
5011
3261
|
* @param options Wfst options, see [Wfst Options](#options) for more details.
|
|
5012
3262
|
*/
|
|
5013
3263
|
class Wfst extends Control {
|
|
5014
|
-
_options;
|
|
5015
|
-
_i18n;
|
|
5016
|
-
// Ol
|
|
5017
|
-
_map;
|
|
5018
|
-
_view;
|
|
5019
|
-
_viewport;
|
|
5020
|
-
_initialized = false;
|
|
5021
|
-
_layersControl;
|
|
5022
|
-
_overlay;
|
|
5023
|
-
// Interactions
|
|
5024
|
-
_interactionWfsSelect;
|
|
5025
|
-
_interactionSelectModify;
|
|
5026
|
-
_collectionModify;
|
|
5027
|
-
_interactionModify;
|
|
5028
|
-
_interactionSnap;
|
|
5029
|
-
_interactionDraw;
|
|
5030
|
-
// Obserbable keys
|
|
5031
|
-
_keyClickWms;
|
|
5032
|
-
_keyRemove;
|
|
5033
|
-
_keySelect;
|
|
5034
|
-
// Controls
|
|
5035
|
-
_controlApplyDiscardChanges;
|
|
5036
|
-
_controlWidgetToolsDiv;
|
|
5037
|
-
_selectDraw;
|
|
5038
|
-
// State
|
|
5039
|
-
_currentZoom;
|
|
5040
|
-
_lastZoom;
|
|
5041
|
-
// Editing
|
|
5042
|
-
_editFeature;
|
|
5043
|
-
_editFeatureOriginal;
|
|
5044
|
-
_uploads;
|
|
5045
|
-
_editFields;
|
|
5046
3264
|
constructor(options) {
|
|
5047
3265
|
super({
|
|
5048
3266
|
target: null,
|
|
@@ -5052,6 +3270,7 @@
|
|
|
5052
3270
|
this._init();
|
|
5053
3271
|
}
|
|
5054
3272
|
});
|
|
3273
|
+
this._initialized = false;
|
|
5055
3274
|
setLang(options.language, options.i18n);
|
|
5056
3275
|
const defaultOptions = getDefaultOptions();
|
|
5057
3276
|
this._options = deepObjectAssign(defaultOptions, options);
|
|
@@ -5208,7 +3427,7 @@
|
|
|
5208
3427
|
this._interactionWfsSelect = new Select({
|
|
5209
3428
|
hitTolerance: 10,
|
|
5210
3429
|
style: (feature) => styleFunction(feature),
|
|
5211
|
-
toggleCondition:
|
|
3430
|
+
toggleCondition: condition_js.never,
|
|
5212
3431
|
filter: (feature, layer) => {
|
|
5213
3432
|
return (getMode() !== Modes.Edit &&
|
|
5214
3433
|
layer &&
|
|
@@ -5249,7 +3468,7 @@
|
|
|
5249
3468
|
this._interactionSelectModify = new Select({
|
|
5250
3469
|
style: (feature) => styleFunction(feature),
|
|
5251
3470
|
layers: [getEditLayer()],
|
|
5252
|
-
toggleCondition:
|
|
3471
|
+
toggleCondition: condition_js.never,
|
|
5253
3472
|
removeCondition: () => (getMode() === Modes.Edit ? true : false) // Prevent deselect on clicking outside the feature
|
|
5254
3473
|
});
|
|
5255
3474
|
this._map.addInteraction(this._interactionSelectModify);
|
|
@@ -5305,7 +3524,7 @@
|
|
|
5305
3524
|
},
|
|
5306
3525
|
features: this._collectionModify,
|
|
5307
3526
|
condition: (evt) => {
|
|
5308
|
-
return
|
|
3527
|
+
return condition_js.primaryAction(evt) && getMode() === Modes.Edit;
|
|
5309
3528
|
}
|
|
5310
3529
|
});
|
|
5311
3530
|
this._map.addInteraction(this._interactionModify);
|
|
@@ -5492,7 +3711,7 @@
|
|
|
5492
3711
|
return;
|
|
5493
3712
|
}
|
|
5494
3713
|
if (this._keySelect) {
|
|
5495
|
-
Observable
|
|
3714
|
+
Observable.unByKey(this._keySelect);
|
|
5496
3715
|
}
|
|
5497
3716
|
const layerName = feature.get('_layerName_');
|
|
5498
3717
|
const ll = this.getLayerByName(layerName);
|
|
@@ -5560,9 +3779,7 @@
|
|
|
5560
3779
|
}
|
|
5561
3780
|
};
|
|
5562
3781
|
if (confirm) {
|
|
5563
|
-
const confirmModal = Modal.confirm(I18N.labels.confirmDelete, {
|
|
5564
|
-
...this._options.modal
|
|
5565
|
-
});
|
|
3782
|
+
const confirmModal = Modal.confirm(I18N.labels.confirmDelete, Object.assign({}, this._options.modal));
|
|
5566
3783
|
confirmModal.show().once('dismiss', function (modal, ev, button) {
|
|
5567
3784
|
if (button && button.value) {
|
|
5568
3785
|
deleteEl();
|
|
@@ -5704,9 +3921,7 @@
|
|
|
5704
3921
|
this._map.removeOverlay(overlay);
|
|
5705
3922
|
}
|
|
5706
3923
|
}
|
|
5707
|
-
class WfstEvent extends BaseEvent
|
|
5708
|
-
data;
|
|
5709
|
-
layer;
|
|
3924
|
+
class WfstEvent extends BaseEvent {
|
|
5710
3925
|
constructor(options) {
|
|
5711
3926
|
super(options.type);
|
|
5712
3927
|
this.layer = options.layer;
|
|
@@ -5714,11 +3929,12 @@
|
|
|
5714
3929
|
}
|
|
5715
3930
|
}
|
|
5716
3931
|
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
};
|
|
3932
|
+
const utils = {
|
|
3933
|
+
WfsLayer,
|
|
3934
|
+
WmsLayer,
|
|
3935
|
+
Geoserver
|
|
3936
|
+
};
|
|
3937
|
+
|
|
5722
3938
|
Object.assign(Wfst, utils);
|
|
5723
3939
|
|
|
5724
3940
|
return Wfst;
|