You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library includes a helper to wrap around the Google maps API. The `GoogleApiWrapper` Higher-Order component accepts a configuration object which *must* include an `apiKey`. See [lib/GoogleApi.js](https://github.com/fullstackreact/google-maps-react/blob/master/src/lib/GoogleApi.js#L4) for all options it accepts.
The `<Polygon />` component listens to `onClick`, `onMouseover` and `onMouseout` events.
287
+
210
288
### InfoWindow
211
289
212
290
The `<InfoWindow />` component included in this library is gives us the ability to pop up a "more info" window on our Google map.
@@ -215,16 +293,25 @@ The `<InfoWindow />` component included in this library is gives us the ability
215
293
216
294
The visibility of the `<InfoWindow />` component is controlled by a `visible` prop. The `visible` prop is a boolean (`PropTypes.bool`) that shows the `<InfoWindow />` when true and hides it when false.
217
295
296
+
There are two ways how to control a position of the `<InfoWindow />` component.
297
+
You can use a `position` prop or connect the `<InfoWindow />` component directly to an existing `<Marker />` component by using a `marker` prop.
298
+
218
299
```javascript
219
-
constWithMarkers=React.createClass({
220
-
getInitialState:function() {
221
-
return {
300
+
//note: code formatted for ES6 here
301
+
exportclassMapContainerextendsComponent {
302
+
constructor(props) {
303
+
super(props);
304
+
this.state= {
222
305
showingInfoWindow:false,
223
306
activeMarker: {},
224
307
selectedPlace: {},
225
308
}
226
-
},
227
-
309
+
310
+
// binding this to event-handler functions
311
+
this.onMarkerClick=this.onMarkerClick.bind(this);
312
+
this.onMapClicked=this.onMapClicked.bind(this);
313
+
}
314
+
228
315
onMarkerClick:function(props, marker, e) {
229
316
this.setState({
230
317
selectedPlace: props,
@@ -285,28 +372,17 @@ The `onClose` event is fired when the `<InfoWindow />` has been closed. It's use
285
372
286
373
The `onOpen` event is fired when the window has been mounted in the Google map instance. It's useful for keeping track of the state of the `<InfoWindow />` from within the parent component.
287
374
288
-
## Automatically Lazy-loading Google API
289
-
290
-
The library includes a helper to wrap around the Google maps API. The `GoogleApiWrapper` Higher-Order component accepts a configuration object which *must* include an `apiKey`. See [lib/GoogleApi.js](https://github.com/fullstackreact/google-maps-react/blob/master/src/lib/GoogleApi.js#L4) for all options it accepts.
0 commit comments