731 lines
16 KiB
JavaScript
731 lines
16 KiB
JavaScript
"use strict"
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true,
|
|
})
|
|
exports.MarkerWithLabel = 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 _MarkerWithLabel$cont /*
|
|
* -----------------------------------------------------------------------------
|
|
* 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 _markerwithlabel = require("markerwithlabel")
|
|
|
|
var _markerwithlabel2 = _interopRequireDefault(_markerwithlabel)
|
|
|
|
var _reactDom = require("react-dom")
|
|
|
|
var _reactDom2 = _interopRequireDefault(_reactDom)
|
|
|
|
var _MapChildHelper = require("../../utils/MapChildHelper")
|
|
|
|
var _constants = require("../../constants")
|
|
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { default: obj }
|
|
}
|
|
|
|
/**
|
|
* A wrapper around `MarkerWithLabel`
|
|
*
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
var MarkerWithLabel = (exports.MarkerWithLabel = (function(
|
|
_React$PureComponent
|
|
) {
|
|
;(0, _inherits3.default)(MarkerWithLabel, _React$PureComponent)
|
|
|
|
/*
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
function MarkerWithLabel(props, context) {
|
|
;(0, _classCallCheck3.default)(this, MarkerWithLabel)
|
|
|
|
var _this = (0, _possibleConstructorReturn3.default)(
|
|
this,
|
|
(MarkerWithLabel.__proto__ ||
|
|
(0, _getPrototypeOf2.default)(MarkerWithLabel)
|
|
).call(this, props, context)
|
|
)
|
|
|
|
var NativeMarkerWithLabel = (0, _markerwithlabel2.default)(google.maps)
|
|
var markerWithLabel = new NativeMarkerWithLabel()
|
|
;(0, _MapChildHelper.construct)(
|
|
MarkerWithLabel.propTypes,
|
|
updaterMap,
|
|
_this.props,
|
|
markerWithLabel
|
|
)
|
|
var markerClusterer = _this.context[_constants.MARKER_CLUSTERER]
|
|
if (markerClusterer) {
|
|
markerClusterer.addMarker(markerWithLabel, !!_this.props.noRedraw)
|
|
} else {
|
|
markerWithLabel.setMap(_this.context[_constants.MAP])
|
|
}
|
|
_this.state = (0, _defineProperty3.default)(
|
|
{},
|
|
_constants.MARKER_WITH_LABEL,
|
|
markerWithLabel
|
|
)
|
|
return _this
|
|
}
|
|
|
|
;(0, _createClass3.default)(MarkerWithLabel, [
|
|
{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
;(0, _MapChildHelper.componentDidMount)(
|
|
this,
|
|
this.state[_constants.MARKER_WITH_LABEL],
|
|
eventMap
|
|
)
|
|
var container = document.createElement("div")
|
|
_reactDom2.default.unstable_renderSubtreeIntoContainer(
|
|
this,
|
|
_react2.default.Children.only(this.props.children),
|
|
container
|
|
)
|
|
this.state[_constants.MARKER_WITH_LABEL].set("labelContent", container)
|
|
},
|
|
},
|
|
{
|
|
key: "componentDidUpdate",
|
|
value: function componentDidUpdate(prevProps) {
|
|
;(0, _MapChildHelper.componentDidUpdate)(
|
|
this,
|
|
this.state[_constants.MARKER_WITH_LABEL],
|
|
eventMap,
|
|
updaterMap,
|
|
prevProps
|
|
)
|
|
if (this.props.children !== prevProps.children) {
|
|
_reactDom2.default.unstable_renderSubtreeIntoContainer(
|
|
this,
|
|
_react2.default.Children.only(this.props.children),
|
|
this.state[_constants.MARKER_WITH_LABEL].get("labelContent")
|
|
)
|
|
}
|
|
},
|
|
},
|
|
{
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
;(0, _MapChildHelper.componentWillUnmount)(this)
|
|
var markerWithLabel = this.state[_constants.MARKER_WITH_LABEL]
|
|
if (markerWithLabel) {
|
|
var markerClusterer = this.context[_constants.MARKER_CLUSTERER]
|
|
if (markerClusterer) {
|
|
markerClusterer.removeMarker(markerWithLabel, !!this.props.noRedraw)
|
|
}
|
|
if (markerWithLabel.get("labelContent")) {
|
|
_reactDom2.default.unmountComponentAtNode(
|
|
markerWithLabel.get("labelContent")
|
|
)
|
|
}
|
|
markerWithLabel.setMap(null)
|
|
}
|
|
},
|
|
},
|
|
{
|
|
key: "render",
|
|
value: function render() {
|
|
return false
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type Animation
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getAnimation",
|
|
value: function getAnimation() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getAnimation()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getClickable",
|
|
value: function getClickable() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getClickable()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getCursor",
|
|
value: function getCursor() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getCursor()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getDraggable",
|
|
value: function getDraggable() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getDraggable()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string|Icon|Symbol
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getIcon",
|
|
value: function getIcon() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getIcon()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerLabel
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getLabel",
|
|
value: function getLabel() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getLabel()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type number
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getOpacity",
|
|
value: function getOpacity() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getOpacity()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerPlace
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getPlace",
|
|
value: function getPlace() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getPlace()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type LatLng
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getPosition",
|
|
value: function getPosition() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getPosition()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type MarkerShape
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getShape",
|
|
value: function getShape() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getShape()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type string
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getTitle",
|
|
value: function getTitle() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getTitle()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type boolean
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getVisible",
|
|
value: function getVisible() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getVisible()
|
|
},
|
|
|
|
/**
|
|
*
|
|
* @type number
|
|
* @public
|
|
*/
|
|
},
|
|
{
|
|
key: "getZIndex",
|
|
value: function getZIndex() {
|
|
return this.state[_constants.MARKER_WITH_LABEL].getZIndex()
|
|
},
|
|
},
|
|
])
|
|
return MarkerWithLabel
|
|
})(_react2.default.PureComponent))
|
|
|
|
MarkerWithLabel.propTypes = {
|
|
/**
|
|
* It will be `MarkerWithLabel#labelContent`.
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
children: _propTypes2.default.node,
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelAnchor: _propTypes2.default.object,
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelClass: _propTypes2.default.string,
|
|
|
|
/**
|
|
* For `MarkerWithLabel`. This is for native JS style object, so you may
|
|
* expect some React shorthands for inline styles not working here.
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelStyle: _propTypes2.default.object,
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelVisible: _propTypes2.default.bool,
|
|
|
|
/**
|
|
* 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,
|
|
}
|
|
MarkerWithLabel.defaultProps = {
|
|
labelVisible: true,
|
|
}
|
|
MarkerWithLabel.contextTypes = ((_MarkerWithLabel$cont = {}),
|
|
(0, _defineProperty3.default)(
|
|
_MarkerWithLabel$cont,
|
|
_constants.MAP,
|
|
_propTypes2.default.object
|
|
),
|
|
(0, _defineProperty3.default)(
|
|
_MarkerWithLabel$cont,
|
|
_constants.MARKER_CLUSTERER,
|
|
_propTypes2.default.object
|
|
),
|
|
_MarkerWithLabel$cont)
|
|
exports.default = MarkerWithLabel
|
|
|
|
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 = {
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelAnchor: function labelAnchor(instance, _labelAnchor) {
|
|
instance.set("labelAnchor", _labelAnchor)
|
|
},
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelClass: function labelClass(instance, _labelClass) {
|
|
instance.set("labelClass", _labelClass)
|
|
},
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelStyle: function labelStyle(instance, _labelStyle) {
|
|
instance.set("labelStyle", _labelStyle)
|
|
},
|
|
|
|
/**
|
|
* For `MarkerWithLabel`
|
|
* @see https://cdn.rawgit.com/googlemaps/v3-utility-library/master/markerwithlabel/src/markerwithlabel.js
|
|
*/
|
|
labelVisible: function labelVisible(instance, _labelVisible) {
|
|
instance.set("labelVisible", _labelVisible)
|
|
},
|
|
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)
|
|
},
|
|
}
|