89 lines
2.8 KiB
JavaScript
89 lines
2.8 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
|
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
|
|
var _leaflet = require("leaflet");
|
|
|
|
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
|
|
|
|
var _context = require("./context");
|
|
|
|
var _GridLayer2 = _interopRequireDefault(require("./GridLayer"));
|
|
|
|
var _MapEvented = require("./MapEvented");
|
|
|
|
var WMSTileLayer = /*#__PURE__*/function (_GridLayer) {
|
|
(0, _inheritsLoose2.default)(WMSTileLayer, _GridLayer);
|
|
|
|
function WMSTileLayer() {
|
|
return _GridLayer.apply(this, arguments) || this;
|
|
}
|
|
|
|
var _proto = WMSTileLayer.prototype;
|
|
|
|
_proto.createLeafletElement = function createLeafletElement(props) {
|
|
var url = props.url,
|
|
params = (0, _objectWithoutPropertiesLoose2.default)(props, ["url"]);
|
|
|
|
var _this$getOptions = this.getOptions(params),
|
|
_l = _this$getOptions.leaflet,
|
|
options = (0, _objectWithoutPropertiesLoose2.default)(_this$getOptions, ["leaflet"]);
|
|
|
|
return new _leaflet.TileLayer.WMS(url, options);
|
|
};
|
|
|
|
_proto.updateLeafletElement = function updateLeafletElement(fromProps, toProps) {
|
|
_GridLayer.prototype.updateLeafletElement.call(this, fromProps, toProps);
|
|
|
|
var prevUrl = fromProps.url,
|
|
_po = fromProps.opacity,
|
|
_pz = fromProps.zIndex,
|
|
prevProps = (0, _objectWithoutPropertiesLoose2.default)(fromProps, ["url", "opacity", "zIndex"]);
|
|
|
|
var _this$getOptions2 = this.getOptions(prevProps),
|
|
_pl = _this$getOptions2.leaflet,
|
|
prevParams = (0, _objectWithoutPropertiesLoose2.default)(_this$getOptions2, ["leaflet"]);
|
|
|
|
var url = toProps.url,
|
|
_o = toProps.opacity,
|
|
_z = toProps.zIndex,
|
|
props = (0, _objectWithoutPropertiesLoose2.default)(toProps, ["url", "opacity", "zIndex"]);
|
|
|
|
var _this$getOptions3 = this.getOptions(props),
|
|
_l = _this$getOptions3.leaflet,
|
|
params = (0, _objectWithoutPropertiesLoose2.default)(_this$getOptions3, ["leaflet"]);
|
|
|
|
if (url !== prevUrl) {
|
|
this.leafletElement.setUrl(url);
|
|
}
|
|
|
|
if (!(0, _fastDeepEqual.default)(params, prevParams)) {
|
|
this.leafletElement.setParams(params);
|
|
}
|
|
};
|
|
|
|
_proto.getOptions = function getOptions(params) {
|
|
var superOptions = _GridLayer.prototype.getOptions.call(this, params);
|
|
|
|
return Object.keys(superOptions).reduce(function (options, key) {
|
|
if (!_MapEvented.EVENTS_RE.test(key)) {
|
|
options[key] = superOptions[key];
|
|
}
|
|
|
|
return options;
|
|
}, {});
|
|
};
|
|
|
|
return WMSTileLayer;
|
|
}(_GridLayer2.default);
|
|
|
|
var _default = (0, _context.withLeaflet)(WMSTileLayer);
|
|
|
|
exports.default = _default; |