UNPKG

rc-leaflet

Version:
57 lines (56 loc) 2.41 kB
"use strict"; 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 __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = require("react"); var prop_types_1 = __importDefault(require("prop-types")); var leaflet_1 = __importDefault(require("leaflet")); var PropTypes_1 = require("../../util/PropTypes"); var BaseIcon = /** @class */ (function (_super) { __extends(BaseIcon, _super); function BaseIcon() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { instance: undefined }; return _this; } BaseIcon.prototype.render = function () { var children = this.props.children; var icon = this.state.instance; return icon && children ? react_1.Children.map(children, function (child) { return (react_1.isValidElement(child) ? react_1.cloneElement(child, { icon: icon }) : child); }) : null; }; BaseIcon.propTypes = { pane: prop_types_1.default.string, attribution: prop_types_1.default.string, iconUrl: prop_types_1.default.string, iconRetinaUrl: prop_types_1.default.string, iconSize: PropTypes_1.Pixel, iconAnchor: PropTypes_1.Pixel, popupAnchor: PropTypes_1.Pixel, tooltipAnchor: PropTypes_1.Pixel, shadowUrl: prop_types_1.default.string, shadowRetinaUrl: prop_types_1.default.string, shadowSize: PropTypes_1.Pixel, shadowAnchor: PropTypes_1.Pixel, className: prop_types_1.default.string, layer: prop_types_1.default.instanceOf(leaflet_1.default.Marker), children: prop_types_1.default.node }; return BaseIcon; }(react_1.PureComponent)); exports.default = BaseIcon;