-
Notifications
You must be signed in to change notification settings - Fork 817
/
Copy pathresizeEvent.js
46 lines (36 loc) · 1.03 KB
/
resizeEvent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { Component } from 'react';
import Map from '../../src/index';
class Container extends Component {
state = {
showingInfoWindow: false
};
onMapReady = (mapProps, map) => {
this.map = map;
window.onresize = () => {
const currCenter = map.getCenter();
this.props.google.maps.event.trigger(map, 'resize');
map.setCenter(currCenter);
};
};
onMarkerClick = () => this.setState({ showingInfoWindow: true });
onInfoWindowClose = () => this.setState({ showingInfoWindow: false });
onMapClicked = () => {
if (this.state.showingInfoWindow)
this.setState({ showingInfoWindow: false });
};
render() {
if (!this.props.loaded) return <div>Loading...</div>;
return (
<Map
centerAroundCurrentLocation
className="map"
google={this.props.google}
onClick={this.onMapClicked}
onReady={this.onMapReady}
style={{ height: '100%', position: 'relative', width: '100%' }}
zoom={14}
/>
);
}
}
export default Container;