Created
May 13, 2015 12:34
-
-
Save wuct/af94d388ea8b8c3fa2d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import GoogleMapsInfobox from 'google-maps-infobox'; | |
import SimpleChildComponent from 'react-google-maps/lib/internals/SimpleChildComponent'; | |
import createRegisterEvents from 'react-google-maps/lib/internals/createRegisterEvents'; | |
import exposeGetters from 'react-google-maps/lib/internals/exposeGetters'; | |
const {PropTypes} = React; | |
class InfoBox extends SimpleChildComponent { | |
constructor (...args) { | |
super(...args); | |
this.state = {}; | |
} | |
_createOrUpdateInstance () { | |
const props = this.props; | |
const {key, ref, ...googleMapsConfig} = props; | |
let {instance} = this.state; | |
if (instance) { | |
instance = super._createOrUpdateInstance(); | |
} else { | |
instance = new GoogleMapsInfobox(googleMapsConfig); | |
exposeGetters(this, GoogleMapsInfobox.prototype, instance); | |
this.setState({instance}); | |
instance.open( | |
this.props.map, | |
this.props.anchor | |
); | |
} | |
return instance; | |
} | |
} | |
// TODO fix this in jscs | |
// InfoBox.propTypes = { | |
// ...SimpleChildComponent.propTypes, | |
// anchor: PropTypes.object | |
// }; | |
InfoBox._GoogleMapsClassName = 'InfoBox'; | |
InfoBox._registerEvents = createRegisterEvents( | |
'closeclick content_changed domready position_changed zindex_changed' | |
); | |
export default InfoBox; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment