src/macros/Circle.jsx
/* global google */
import React from "react"
import PropTypes from "prop-types"
import {
construct,
componentDidMount,
componentDidUpdate,
componentWillUnmount,
} from "../utils/MapChildHelper"
import { MAP, CIRCLE } from "../constants"
export const __jscodeshiftPlaceholder__ = `{
"eventMapOverrides": {
"onDblClick": "dblclick",
"onDragEnd": "dragend",
"onDragStart": "dragstart",
"onMouseDown": "mousedown",
"onMouseMove": "mousemove",
"onMouseOut": "mouseout",
"onMouseOver": "mouseover",
"onMouseUp": "mouseup",
"onRightClick": "rightclick"
},
"getInstanceFromComponent": "this.state[CIRCLE]"
}`
/**
* A wrapper around `google.maps.Circle`
*
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Circle
*/
export class Circle extends React.PureComponent {
static propTypes = {
__jscodeshiftPlaceholder__: null,
}
static contextTypes = {
[MAP]: PropTypes.object,
}
/*
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Circle
*/
constructor(props, context) {
super(props, context)
const circle = new google.maps.Circle()
construct(Circle.propTypes, updaterMap, this.props, circle)
circle.setMap(this.context[MAP])
this.state = {
[CIRCLE]: circle,
}
}
componentDidMount() {
componentDidMount(this, this.state[CIRCLE], eventMap)
}
componentDidUpdate(prevProps) {
componentDidUpdate(
this,
this.state[CIRCLE],
eventMap,
updaterMap,
prevProps
)
}
componentWillUnmount() {
componentWillUnmount(this)
const circle = this.state[CIRCLE]
if (circle) {
circle.setMap(null)
}
}
render() {
return false
}
}
export default Circle
const eventMap = {}
const updaterMap = {}