336 lines
7.2 KiB
JavaScript
336 lines
7.2 KiB
JavaScript
"use strict"
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true,
|
|
})
|
|
exports.Rectangle = 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.Rectangle`
|
|
*
|
|
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Rectangle
|
|
*/
|
|
/*
|
|
* -----------------------------------------------------------------------------
|
|
* 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 Rectangle = (exports.Rectangle = (function(_React$PureComponent) {
|
|
;(0, _inherits3.default)(Rectangle, _React$PureComponent)
|
|
|
|
/*
|
|
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Rectangle
|
|
*/
|
|
function Rectangle(props, context) {
|
|
;(0, _classCallCheck3.default)(this, Rectangle)
|
|
|
|
var _this = (0, _possibleConstructorReturn3.default)(
|
|
this,
|
|
(Rectangle.__proto__ || (0, _getPrototypeOf2.default)(Rectangle)).call(
|
|
this,
|
|
props,
|
|
context
|
|
)
|
|
)
|
|
|
|
var rectangle = new google.maps.Rectangle()
|
|
;(0, _MapChildHelper.construct)(
|
|
Rectangle.propTypes,
|
|
updaterMap,
|
|
_this.props,
|
|
rectangle
|
|
)
|
|
rectangle.setMap(_this.context[_constants.MAP])
|
|
_this.state = (0, _defineProperty3.default)(
|
|
{},
|
|
_constants.RECTANGLE,
|
|
rectangle
|
|
)
|
|
return _this
|
|
}
|
|
|
|
;(0, _createClass3.default)(Rectangle, [
|
|
{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
;(0, _MapChildHelper.componentDidMount)(
|
|
this,
|
|
this.state[_constants.RECTANGLE],
|
|
eventMap
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: "componentDidUpdate",
|
|
value: function componentDidUpdate(prevProps) {
|
|
;(0, _MapChildHelper.componentDidUpdate)(
|
|
this,
|
|
this.state[_constants.RECTANGLE],
|
|
eventMap,
|
|
updaterMap,
|
|
prevProps
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
;(0, _MapChildHelper.componentWillUnmount)(this)
|
|
var rectangle = this.state[_constants.RECTANGLE]
|
|
if (rectangle) {
|
|
rectangle.setMap(null)
|
|
}
|
|
},
|
|
},
|
|
{
|
|
key: "render",
|
|
value: function render() {
|
|
return false
|
|
},
|
|
|
|
/**
|
|
* Returns the bounds of this rectangle.
|
|
* @type LatLngBounds
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getBounds",
|
|
value: function getBounds() {
|
|
return this.state[_constants.RECTANGLE].getBounds()
|
|
},
|
|
|
|
/**
|
|
* Returns whether this rectangle can be dragged by the user.
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getDraggable",
|
|
value: function getDraggable() {
|
|
return this.state[_constants.RECTANGLE].getDraggable()
|
|
},
|
|
|
|
/**
|
|
* Returns whether this rectangle can be edited by the user.
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getEditable",
|
|
value: function getEditable() {
|
|
return this.state[_constants.RECTANGLE].getEditable()
|
|
},
|
|
|
|
/**
|
|
* Returns whether this rectangle is visible on the map.
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getVisible",
|
|
value: function getVisible() {
|
|
return this.state[_constants.RECTANGLE].getVisible()
|
|
},
|
|
},
|
|
])
|
|
return Rectangle
|
|
})(_react2.default.PureComponent))
|
|
|
|
Rectangle.propTypes = {
|
|
/**
|
|
* @type LatLngBounds|LatLngBoundsLiteral
|
|
*/
|
|
defaultBounds: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultDraggable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultEditable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type RectangleOptions
|
|
*/
|
|
defaultOptions: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultVisible: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type LatLngBounds|LatLngBoundsLiteral
|
|
*/
|
|
bounds: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
draggable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
editable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type RectangleOptions
|
|
*/
|
|
options: _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
|
|
*/
|
|
onBoundsChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onClick: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDrag: _propTypes2.default.func,
|
|
}
|
|
Rectangle.contextTypes = (0, _defineProperty3.default)(
|
|
{},
|
|
_constants.MAP,
|
|
_propTypes2.default.object
|
|
)
|
|
exports.default = Rectangle
|
|
|
|
var eventMap = {
|
|
onDblClick: "dblclick",
|
|
onDragEnd: "dragend",
|
|
onDragStart: "dragstart",
|
|
onMouseDown: "mousedown",
|
|
onMouseMove: "mousemove",
|
|
onMouseOut: "mouseout",
|
|
onMouseOver: "mouseover",
|
|
onMouseUp: "mouseup",
|
|
onRightClick: "rightclick",
|
|
onBoundsChanged: "bounds_changed",
|
|
onClick: "click",
|
|
onDrag: "drag",
|
|
}
|
|
|
|
var updaterMap = {
|
|
bounds: function bounds(instance, _bounds) {
|
|
instance.setBounds(_bounds)
|
|
},
|
|
draggable: function draggable(instance, _draggable) {
|
|
instance.setDraggable(_draggable)
|
|
},
|
|
editable: function editable(instance, _editable) {
|
|
instance.setEditable(_editable)
|
|
},
|
|
options: function options(instance, _options) {
|
|
instance.setOptions(_options)
|
|
},
|
|
visible: function visible(instance, _visible) {
|
|
instance.setVisible(_visible)
|
|
},
|
|
}
|