UNPKG

react-google-maps-jimmy

Version:
352 lines (296 loc) 7.82 kB
"use strict" Object.defineProperty(exports, "__esModule", { value: true, }) exports.Polygon = undefined var _defineProperty2 = require("babel-runtime/helpers/defineProperty") var _defineProperty3 = _interopRequireDefault(_defineProperty2) var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of") var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf) var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck") var _classCallCheck3 = _interopRequireDefault(_classCallCheck2) var _createClass2 = require("babel-runtime/helpers/createClass") var _createClass3 = _interopRequireDefault(_createClass2) var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn") var _possibleConstructorReturn3 = _interopRequireDefault( _possibleConstructorReturn2 ) var _inherits2 = require("babel-runtime/helpers/inherits") var _inherits3 = _interopRequireDefault(_inherits2) var _react = require("react") var _react2 = _interopRequireDefault(_react) var _propTypes = require("prop-types") var _propTypes2 = _interopRequireDefault(_propTypes) var _MapChildHelper = require("../utils/MapChildHelper") var _constants = require("../constants") function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } /** * A wrapper around `google.maps.Polygon` * * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polygon */ /* * ----------------------------------------------------------------------------- * This file is auto-generated from the corresponding file at `src/macros/`. * Please **DO NOT** edit this file directly when creating PRs. * ----------------------------------------------------------------------------- */ /* global google */ var Polygon = (exports.Polygon = (function(_React$PureComponent) { ;(0, _inherits3.default)(Polygon, _React$PureComponent) /* * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polygon */ function Polygon(props, context) { ;(0, _classCallCheck3.default)(this, Polygon) var _this = (0, _possibleConstructorReturn3.default)( this, (Polygon.__proto__ || (0, _getPrototypeOf2.default)(Polygon)).call( this, props, context ) ) var polygon = new google.maps.Polygon() ;(0, _MapChildHelper.construct)( Polygon.propTypes, updaterMap, _this.props, polygon ) polygon.setMap(_this.context[_constants.MAP]) _this.state = (0, _defineProperty3.default)({}, _constants.POLYGON, polygon) return _this } ;(0, _createClass3.default)(Polygon, [ { key: "componentDidMount", value: function componentDidMount() { ;(0, _MapChildHelper.componentDidMount)( this, this.state[_constants.POLYGON], eventMap ) }, }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { ;(0, _MapChildHelper.componentDidUpdate)( this, this.state[_constants.POLYGON], eventMap, updaterMap, prevProps ) }, }, { key: "componentWillUnmount", value: function componentWillUnmount() { ;(0, _MapChildHelper.componentWillUnmount)(this) var polygon = this.state[_constants.POLYGON] if (polygon) { polygon.setMap(null) } }, }, { key: "render", value: function render() { return false }, /** * Returns whether this shape can be dragged by the user. * @type boolean * @public */ }, { key: "getDraggable", value: function getDraggable() { return this.state[_constants.POLYGON].getDraggable() }, /** * Returns whether this shape can be edited by the user. * @type boolean * @public */ }, { key: "getEditable", value: function getEditable() { return this.state[_constants.POLYGON].getEditable() }, /** * Retrieves the first path. * @type MVCArray<LatLng> * @public */ }, { key: "getPath", value: function getPath() { return this.state[_constants.POLYGON].getPath() }, /** * Retrieves the paths for this polygon. * @type MVCArray<MVCArray<LatLng>> * @public */ }, { key: "getPaths", value: function getPaths() { return this.state[_constants.POLYGON].getPaths() }, /** * Returns whether this poly is visible on the map. * @type boolean * @public */ }, { key: "getVisible", value: function getVisible() { return this.state[_constants.POLYGON].getVisible() }, }, ]) return Polygon })(_react2.default.PureComponent)) Polygon.propTypes = { /** * @type boolean */ defaultDraggable: _propTypes2.default.bool, /** * @type boolean */ defaultEditable: _propTypes2.default.bool, /** * @type PolygonOptions */ defaultOptions: _propTypes2.default.any, /** * @type MVCArray<LatLng>|Array<LatLng|LatLngLiteral> */ defaultPath: _propTypes2.default.any, /** * @type MVCArray<MVCArray<LatLng>>|MVCArray<LatLng>|Array<Array<LatLng|LatLngLiteral>>|Array<LatLng|LatLngLiteral> */ defaultPaths: _propTypes2.default.any, /** * @type boolean */ defaultVisible: _propTypes2.default.bool, /** * @type boolean */ draggable: _propTypes2.default.bool, /** * @type boolean */ editable: _propTypes2.default.bool, /** * @type PolygonOptions */ options: _propTypes2.default.any, /** * @type MVCArray<LatLng>|Array<LatLng|LatLngLiteral> */ path: _propTypes2.default.any, /** * @type MVCArray<MVCArray<LatLng>>|MVCArray<LatLng>|Array<Array<LatLng|LatLngLiteral>>|Array<LatLng|LatLngLiteral> */ paths: _propTypes2.default.any, /** * @type boolean */ visible: _propTypes2.default.bool, /** * function */ onDblClick: _propTypes2.default.func, /** * function */ onDragEnd: _propTypes2.default.func, /** * function */ onDragStart: _propTypes2.default.func, /** * function */ onMouseDown: _propTypes2.default.func, /** * function */ onMouseMove: _propTypes2.default.func, /** * function */ onMouseOut: _propTypes2.default.func, /** * function */ onMouseOver: _propTypes2.default.func, /** * function */ onMouseUp: _propTypes2.default.func, /** * function */ onRightClick: _propTypes2.default.func, /** * function */ onClick: _propTypes2.default.func, /** * function */ onDrag: _propTypes2.default.func, } Polygon.contextTypes = (0, _defineProperty3.default)( {}, _constants.MAP, _propTypes2.default.object ) exports.default = Polygon var eventMap = { onDblClick: "dblclick", onDragEnd: "dragend", onDragStart: "dragstart", onMouseDown: "mousedown", onMouseMove: "mousemove", onMouseOut: "mouseout", onMouseOver: "mouseover", onMouseUp: "mouseup", onRightClick: "rightclick", onClick: "click", onDrag: "drag", } var updaterMap = { draggable: function draggable(instance, _draggable) { instance.setDraggable(_draggable) }, editable: function editable(instance, _editable) { instance.setEditable(_editable) }, options: function options(instance, _options) { instance.setOptions(_options) }, path: function path(instance, _path) { instance.setPath(_path) }, paths: function paths(instance, _paths) { instance.setPaths(_paths) }, visible: function visible(instance, _visible) { instance.setVisible(_visible) }, }