rc-leaflet
Version:
React Map Components of Leaflet
63 lines (62 loc) • 3.3 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { Children, isValidElement, cloneElement } from 'react';
import L from 'leaflet';
import LayerGroup from '../LayerGroup';
var FeatureGroup = /** @class */ (function (_super) {
__extends(FeatureGroup, _super);
function FeatureGroup() {
return _super !== null && _super.apply(this, arguments) || this;
}
FeatureGroup.prototype.createInstance = function (props) {
return L.featureGroup();
};
Object.defineProperty(FeatureGroup.prototype, "theme", {
get: function () {
if (this.context && this.context.theme && this.context.theme.path) {
return this.context.theme.path;
}
return {};
},
enumerable: true,
configurable: true
});
Object.defineProperty(FeatureGroup.prototype, "pathOptions", {
get: function () {
var _a = this.props, stroke = _a.stroke, color = _a.color, weight = _a.weight, opacity = _a.opacity, lineCap = _a.lineCap, lineJoin = _a.lineJoin, dashArray = _a.dashArray, dashOffset = _a.dashOffset, fill = _a.fill, fillColor = _a.fillColor, fillOpacity = _a.fillOpacity, fillRule = _a.fillRule, renderer = _a.renderer, className = _a.className, interactive = _a.interactive, bubblingMouseEvents = _a.bubblingMouseEvents, pane = _a.pane, attribution = _a.attribution;
return { stroke: stroke, color: color, weight: weight, opacity: opacity, lineCap: lineCap, lineJoin: lineJoin, dashArray: dashArray, dashOffset: dashOffset, fill: fill, fillColor: fillColor, fillOpacity: fillOpacity, fillRule: fillRule, renderer: renderer, className: className, interactive: interactive, bubblingMouseEvents: bubblingMouseEvents, pane: pane, attribution: attribution };
},
enumerable: true,
configurable: true
});
FeatureGroup.prototype.render = function () {
var _this = this;
var _a = this.props, zIndex = _a.zIndex, children = _a.children;
var group = this.instance;
return children ? Children.map(children, function (child) { return (isValidElement(child) ? cloneElement(child, __assign({ zIndex: zIndex, zIndexOffset: zIndex }, _this.theme, _this.pathOptions, child.props, { group: group, layer: group })) : child); }) : null;
};
return FeatureGroup;
}(LayerGroup));
export default FeatureGroup;