UNPKG

react-google-maps-jimmy

Version:
331 lines (278 loc) 7.2 kB
"use strict" Object.defineProperty(exports, "__esModule", { value: true, }) exports.Polyline = 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.Polyline` * * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline */ /* * ----------------------------------------------------------------------------- * 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 Polyline = (exports.Polyline = (function(_React$PureComponent) { ;(0, _inherits3.default)(Polyline, _React$PureComponent) /* * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline */ function Polyline(props, context) { ;(0, _classCallCheck3.default)(this, Polyline) var _this = (0, _possibleConstructorReturn3.default)( this, (Polyline.__proto__ || (0, _getPrototypeOf2.default)(Polyline)).call( this, props, context ) ) var polyline = new google.maps.Polyline() ;(0, _MapChildHelper.construct)( Polyline.propTypes, updaterMap, _this.props, polyline ) polyline.setMap(_this.context[_constants.MAP]) _this.state = (0, _defineProperty3.default)( {}, _constants.POLYLINE, polyline ) return _this } ;(0, _createClass3.default)(Polyline, [ { key: "componentDidMount", value: function componentDidMount() { ;(0, _MapChildHelper.componentDidMount)( this, this.state[_constants.POLYLINE], eventMap ) }, }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { ;(0, _MapChildHelper.componentDidUpdate)( this, this.state[_constants.POLYLINE], eventMap, updaterMap, prevProps ) }, }, { key: "componentWillUnmount", value: function componentWillUnmount() { ;(0, _MapChildHelper.componentWillUnmount)(this) var polyline = this.state[_constants.POLYLINE] if (polyline) { polyline.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.POLYLINE].getDraggable() }, /** * Returns whether this shape can be edited by the user. * @type boolean * @public */ }, { key: "getEditable", value: function getEditable() { return this.state[_constants.POLYLINE].getEditable() }, /** * Retrieves the path. * @type MVCArray<LatLng> * @public */ }, { key: "getPath", value: function getPath() { return this.state[_constants.POLYLINE].getPath() }, /** * Returns whether this poly is visible on the map. * @type boolean * @public */ }, { key: "getVisible", value: function getVisible() { return this.state[_constants.POLYLINE].getVisible() }, }, ]) return Polyline })(_react2.default.PureComponent)) Polyline.propTypes = { /** * @type boolean */ defaultDraggable: _propTypes2.default.bool, /** * @type boolean */ defaultEditable: _propTypes2.default.bool, /** * @type PolylineOptions */ defaultOptions: _propTypes2.default.any, /** * @type MVCArray<LatLng>|Array<LatLng|LatLngLiteral> */ defaultPath: _propTypes2.default.any, /** * @type boolean */ defaultVisible: _propTypes2.default.bool, /** * @type boolean */ draggable: _propTypes2.default.bool, /** * @type boolean */ editable: _propTypes2.default.bool, /** * @type PolylineOptions */ options: _propTypes2.default.any, /** * @type MVCArray<LatLng>|Array<LatLng|LatLngLiteral> */ path: _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, } Polyline.contextTypes = (0, _defineProperty3.default)( {}, _constants.MAP, _propTypes2.default.object ) exports.default = Polyline 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) }, visible: function visible(instance, _visible) { instance.setVisible(_visible) }, }