Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ov = <OverlayView
- position={{lat: 51.47879, lng: 0.0}}
- mapPaneName={OverlayView.MAP_PANE}
- >
- <div>
- <h1>Overlay</h1>
- </div>
- </OverlayView>;
- const GMap = withGoogleMap(props => (
- <GoogleMap
- defaultZoom={2}
- defaultCenter={{ lat: 51.47879, lng: 0.0 }}
- >
- {ov}
- </GoogleMap>
- ));
- class Map extends React.Component{
- constructor(props, context) {
- super(props, context);
- }
- componentDidMount() {
- // тут я хочу удалить оверлей через 3 сеекунды после монтирования в DOM компонента Map
- // но получаю исключение: Uncaught TypeError: ov.setMap is not a function
- setTimeout(function () {
- ov.setMap(null);
- }, 3000);
- }
- render() {
- return (
- <GMap
- containerElement={
- <div style={{ height: '600px' }} />
- }
- mapElement={
- <div style={{ height: '600px' }} />
- }
- />
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement