651 lines
13 KiB
JavaScript
651 lines
13 KiB
JavaScript
"use strict"
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true,
|
|
})
|
|
exports.Marker = 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 _Marker$contextTypes /*
|
|
* -----------------------------------------------------------------------------
|
|
* 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 _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.Marker`
|
|
*
|
|
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Marker
|
|
*/
|
|
var Marker = (exports.Marker = (function(_React$PureComponent) {
|
|
;(0, _inherits3.default)(Marker, _React$PureComponent)
|
|
|
|
/*
|
|
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Marker
|
|
*/
|
|
function Marker(props, context) {
|
|
;(0, _classCallCheck3.default)(this, Marker)
|
|
|
|
var _this = (0, _possibleConstructorReturn3.default)(
|
|
this,
|
|
(Marker.__proto__ || (0, _getPrototypeOf2.default)(Marker)).call(
|
|
this,
|
|
props,
|
|
context
|
|
)
|
|
)
|
|
|
|
var marker = new google.maps.Marker()
|
|
;(0, _MapChildHelper.construct)(
|
|
Marker.propTypes,
|
|
updaterMap,
|
|
_this.props,
|
|
marker
|
|
)
|
|
var markerClusterer = _this.context[_constants.MARKER_CLUSTERER]
|
|
if (markerClusterer) {
|
|
markerClusterer.addMarker(marker, !!_this.props.noRedraw)
|
|
} else {
|
|
marker.setMap(_this.context[_constants.MAP])
|
|
}
|
|
_this.state = (0, _defineProperty3.default)({}, _constants.MARKER, marker)
|
|
return _this
|
|
}
|
|
|
|
;(0, _createClass3.default)(Marker, [
|
|
{
|
|
key: "getChildContext",
|
|
value: function getChildContext() {
|
|
return (0, _defineProperty3.default)(
|
|
{},
|
|
_constants.ANCHOR,
|
|
this.context[_constants.ANCHOR] || this.state[_constants.MARKER]
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
;(0, _MapChildHelper.componentDidMount)(
|
|
this,
|
|
this.state[_constants.MARKER],
|
|
eventMap
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: "componentDidUpdate",
|
|
value: function componentDidUpdate(prevProps) {
|
|
;(0, _MapChildHelper.componentDidUpdate)(
|
|
this,
|
|
this.state[_constants.MARKER],
|
|
eventMap,
|
|
updaterMap,
|
|
prevProps
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
;(0, _MapChildHelper.componentWillUnmount)(this)
|
|
var marker = this.state[_constants.MARKER]
|
|
if (marker) {
|
|
var markerClusterer = this.context[_constants.MARKER_CLUSTERER]
|
|
if (markerClusterer) {
|
|
markerClusterer.removeMarker(marker, !!this.props.noRedraw)
|
|
}
|
|
marker.setMap(null)
|
|
}
|
|
},
|
|
},
|
|
{
|
|
key: "render",
|
|
value: function render() {
|
|
var children = this.props.children
|
|
|
|
return _react2.default.createElement("div", null, children)
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type Animation
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getAnimation",
|
|
value: function getAnimation() {
|
|
return this.state[_constants.MARKER].getAnimation()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getClickable",
|
|
value: function getClickable() {
|
|
return this.state[_constants.MARKER].getClickable()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getCursor",
|
|
value: function getCursor() {
|
|
return this.state[_constants.MARKER].getCursor()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getDraggable",
|
|
value: function getDraggable() {
|
|
return this.state[_constants.MARKER].getDraggable()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string|Icon|Symbol
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getIcon",
|
|
value: function getIcon() {
|
|
return this.state[_constants.MARKER].getIcon()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerLabel
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getLabel",
|
|
value: function getLabel() {
|
|
return this.state[_constants.MARKER].getLabel()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type number
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getOpacity",
|
|
value: function getOpacity() {
|
|
return this.state[_constants.MARKER].getOpacity()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerPlace
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getPlace",
|
|
value: function getPlace() {
|
|
return this.state[_constants.MARKER].getPlace()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type LatLng
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getPosition",
|
|
value: function getPosition() {
|
|
return this.state[_constants.MARKER].getPosition()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerShape
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getShape",
|
|
value: function getShape() {
|
|
return this.state[_constants.MARKER].getShape()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getTitle",
|
|
value: function getTitle() {
|
|
return this.state[_constants.MARKER].getTitle()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getVisible",
|
|
value: function getVisible() {
|
|
return this.state[_constants.MARKER].getVisible()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type number
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getZIndex",
|
|
value: function getZIndex() {
|
|
return this.state[_constants.MARKER].getZIndex()
|
|
},
|
|
},
|
|
])
|
|
return Marker
|
|
})(_react2.default.PureComponent))
|
|
|
|
Marker.propTypes = {
|
|
/**
|
|
* For the 2nd argument of `MarkerCluster#addMarker`
|
|
* @see https://github.com/mikesaidani/marker-clusterer-plus
|
|
*/
|
|
noRedraw: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type Animation
|
|
*/
|
|
defaultAnimation: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultClickable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
defaultCursor: _propTypes2.default.string,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultDraggable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type string|Icon|Symbol
|
|
*/
|
|
defaultIcon: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type string|MarkerLabel
|
|
*/
|
|
defaultLabel: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type number
|
|
*/
|
|
defaultOpacity: _propTypes2.default.number,
|
|
|
|
/**
|
|
* @type MarkerOptions
|
|
*/
|
|
defaultOptions: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type MarkerPlace
|
|
*/
|
|
defaultPlace: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type LatLng|LatLngLiteral
|
|
*/
|
|
defaultPosition: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type MarkerShape
|
|
*/
|
|
defaultShape: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
defaultTitle: _propTypes2.default.string,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
defaultVisible: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type number
|
|
*/
|
|
defaultZIndex: _propTypes2.default.number,
|
|
|
|
/**
|
|
* @type Animation
|
|
*/
|
|
animation: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
clickable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
cursor: _propTypes2.default.string,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
draggable: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type string|Icon|Symbol
|
|
*/
|
|
icon: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type string|MarkerLabel
|
|
*/
|
|
label: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type number
|
|
*/
|
|
opacity: _propTypes2.default.number,
|
|
|
|
/**
|
|
* @type MarkerOptions
|
|
*/
|
|
options: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type MarkerPlace
|
|
*/
|
|
place: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type LatLng|LatLngLiteral
|
|
*/
|
|
position: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type MarkerShape
|
|
*/
|
|
shape: _propTypes2.default.any,
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
title: _propTypes2.default.string,
|
|
|
|
/**
|
|
* @type boolean
|
|
*/
|
|
visible: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* @type number
|
|
*/
|
|
zIndex: _propTypes2.default.number,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDblClick: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDragEnd: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDragStart: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onMouseDown: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onMouseOut: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onMouseOver: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onMouseUp: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onRightClick: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onAnimationChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onClick: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onClickableChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onCursorChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDrag: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onDraggableChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onFlatChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onIconChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onPositionChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onShapeChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onTitleChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onVisibleChanged: _propTypes2.default.func,
|
|
|
|
/**
|
|
* function
|
|
*/
|
|
onZindexChanged: _propTypes2.default.func,
|
|
}
|
|
Marker.contextTypes = ((_Marker$contextTypes = {}),
|
|
(0, _defineProperty3.default)(
|
|
_Marker$contextTypes,
|
|
_constants.MAP,
|
|
_propTypes2.default.object
|
|
),
|
|
(0, _defineProperty3.default)(
|
|
_Marker$contextTypes,
|
|
_constants.MARKER_CLUSTERER,
|
|
_propTypes2.default.object
|
|
),
|
|
_Marker$contextTypes)
|
|
Marker.childContextTypes = (0, _defineProperty3.default)(
|
|
{},
|
|
_constants.ANCHOR,
|
|
_propTypes2.default.object
|
|
)
|
|
exports.default = Marker
|
|
|
|
var eventMap = {
|
|
onDblClick: "dblclick",
|
|
onDragEnd: "dragend",
|
|
onDragStart: "dragstart",
|
|
onMouseDown: "mousedown",
|
|
onMouseOut: "mouseout",
|
|
onMouseOver: "mouseover",
|
|
onMouseUp: "mouseup",
|
|
onRightClick: "rightclick",
|
|
onAnimationChanged: "animation_changed",
|
|
onClick: "click",
|
|
onClickableChanged: "clickable_changed",
|
|
onCursorChanged: "cursor_changed",
|
|
onDrag: "drag",
|
|
onDraggableChanged: "draggable_changed",
|
|
onFlatChanged: "flat_changed",
|
|
onIconChanged: "icon_changed",
|
|
onPositionChanged: "position_changed",
|
|
onShapeChanged: "shape_changed",
|
|
onTitleChanged: "title_changed",
|
|
onVisibleChanged: "visible_changed",
|
|
onZindexChanged: "zindex_changed",
|
|
}
|
|
|
|
var updaterMap = {
|
|
animation: function animation(instance, _animation) {
|
|
instance.setAnimation(_animation)
|
|
},
|
|
clickable: function clickable(instance, _clickable) {
|
|
instance.setClickable(_clickable)
|
|
},
|
|
cursor: function cursor(instance, _cursor) {
|
|
instance.setCursor(_cursor)
|
|
},
|
|
draggable: function draggable(instance, _draggable) {
|
|
instance.setDraggable(_draggable)
|
|
},
|
|
icon: function icon(instance, _icon) {
|
|
instance.setIcon(_icon)
|
|
},
|
|
label: function label(instance, _label) {
|
|
instance.setLabel(_label)
|
|
},
|
|
opacity: function opacity(instance, _opacity) {
|
|
instance.setOpacity(_opacity)
|
|
},
|
|
options: function options(instance, _options) {
|
|
instance.setOptions(_options)
|
|
},
|
|
place: function place(instance, _place) {
|
|
instance.setPlace(_place)
|
|
},
|
|
position: function position(instance, _position) {
|
|
instance.setPosition(_position)
|
|
},
|
|
shape: function shape(instance, _shape) {
|
|
instance.setShape(_shape)
|
|
},
|
|
title: function title(instance, _title) {
|
|
instance.setTitle(_title)
|
|
},
|
|
visible: function visible(instance, _visible) {
|
|
instance.setVisible(_visible)
|
|
},
|
|
zIndex: function zIndex(instance, _zIndex) {
|
|
instance.setZIndex(_zIndex)
|
|
},
|
|
}
|