Skip to content

Commit a5865a0

Browse files
committed
feat(FusionTablesLayer): revamp with jscodeshift
1 parent 7c5532a commit a5865a0

File tree

2 files changed

+81
-98
lines changed

2 files changed

+81
-98
lines changed

src/lib/FusionTablesLayer.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/macros/FusionTablesLayer.jsx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* global google */
2+
import React from "react"
3+
import PropTypes from "prop-types"
4+
5+
import {
6+
construct,
7+
componentDidMount,
8+
componentDidUpdate,
9+
componentWillUnmount,
10+
} from "../utils/MapChildHelper"
11+
12+
import { MAP, FUSION_TABLES_LAYER } from "../constants"
13+
14+
export const __jscodeshiftPlaceholder__ = `{
15+
"eventMapOverrides": {
16+
},
17+
"getInstanceFromComponent": "this.state[FUSION_TABLES_LAYER]"
18+
}`
19+
20+
/**
21+
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#FusionTablesLayer
22+
*/
23+
export class FusionTablesLayer extends React.PureComponent {
24+
static propTypes = {
25+
__jscodeshiftPlaceholder__: null,
26+
}
27+
28+
static contextTypes = {
29+
[MAP]: PropTypes.object,
30+
}
31+
32+
/*
33+
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#FusionTablesLayer
34+
*/
35+
constructor(props, context) {
36+
super(props, context)
37+
const fusionTablesLayer = new google.maps.FusionTablesLayer()
38+
construct(
39+
FusionTablesLayer.propTypes,
40+
updaterMap,
41+
this.props,
42+
fusionTablesLayer
43+
)
44+
fusionTablesLayer.setMap(this.context[MAP])
45+
this.state = {
46+
[FUSION_TABLES_LAYER]: fusionTablesLayer,
47+
}
48+
}
49+
50+
componentDidMount() {
51+
componentDidMount(this, this.state[FUSION_TABLES_LAYER], eventMap)
52+
}
53+
54+
componentDidUpdate(prevProps) {
55+
componentDidUpdate(
56+
this,
57+
this.state[FUSION_TABLES_LAYER],
58+
eventMap,
59+
updaterMap,
60+
prevProps
61+
)
62+
}
63+
64+
componentWillUnmount() {
65+
componentWillUnmount(this)
66+
const fusionTablesLayer = this.state[FUSION_TABLES_LAYER]
67+
if (fusionTablesLayer) {
68+
fusionTablesLayer.setMap(null)
69+
}
70+
}
71+
72+
render() {
73+
return false
74+
}
75+
}
76+
77+
export default FusionTablesLayer
78+
79+
const eventMap = {}
80+
81+
const updaterMap = {}

0 commit comments

Comments
 (0)