Advertisement
Guest User

Untitled

a guest
May 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ov = <OverlayView
  2.     position={{lat: 51.47879, lng: 0.0}}
  3.     mapPaneName={OverlayView.MAP_PANE}
  4. >
  5.     <div>
  6.         <h1>Overlay</h1>
  7.     </div>
  8. </OverlayView>;
  9.  
  10. const GMap = withGoogleMap(props => (
  11.  
  12.     <GoogleMap
  13.         defaultZoom={2}
  14.         defaultCenter={{ lat: 51.47879, lng: 0.0 }}
  15.     >
  16.     {ov}
  17.  
  18.     </GoogleMap>
  19. ));
  20.  
  21. class Map extends React.Component{
  22.     constructor(props, context) {
  23.         super(props, context);
  24.     }
  25.  
  26.     componentDidMount() {
  27. // тут я хочу удалить оверлей через 3 сеекунды после монтирования в DOM компонента Map
  28. // но получаю исключение: Uncaught TypeError: ov.setMap is not a function
  29.         setTimeout(function () {
  30.             ov.setMap(null);
  31.         }, 3000);
  32.     }
  33.  
  34.     render() {
  35.         return (
  36.             <GMap
  37.                 containerElement={
  38.                     <div style={{ height: '600px' }} />
  39.                 }
  40.                 mapElement={
  41.                     <div style={{ height: '600px' }} />
  42.                 }
  43.             />
  44.         );
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement