Skip to content

Commit

Permalink
feat(InfoBox): Support for InfoBox
Browse files Browse the repository at this point in the history
  • Loading branch information
wuct committed May 18, 2015
1 parent aeb4afb commit 613e5ef
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/addons/InfoBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import SimpleChildComponent from "../internals/SimpleChildComponent";
import createRegisterEvents from "../internals/createRegisterEvents";
import exposeGetters from "../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 {
// "google-maps-infobox" uses "google" as a global variable. Since we don't
// have "google" on the server, we can not use it in server-side rendering.
// As a result, we import "google-maps-infobox" here to prevent an error on
// a isomorphic server.
const GoogleMapsInfobox = require("google-maps-infobox");
instance = new GoogleMapsInfobox(googleMapsConfig);
exposeGetters(this, GoogleMapsInfobox.prototype, instance);
this.setState({instance});
instance.open(
this.props.map,
this.props.anchor
);
}

return instance;
}
}


InfoBox.propTypes = {
...SimpleChildComponent.propTypes,
anchor: PropTypes.object
};

InfoBox._GoogleMapsClassName = "InfoBox";

InfoBox._registerEvents = createRegisterEvents(
"closeclick content_changed domready position_changed zindex_changed"
);


export default InfoBox;

0 comments on commit 613e5ef

Please sign in to comment.