Skip to content

Instantly share code, notes, and snippets.

@wuct
Created May 13, 2015 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuct/af94d388ea8b8c3fa2d6 to your computer and use it in GitHub Desktop.
Save wuct/af94d388ea8b8c3fa2d6 to your computer and use it in GitHub Desktop.
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