React-google-maps: Missing functionality to trigger a resize event

Created on 21 Nov 2016  路  4Comments  路  Source: tomchentw/react-google-maps

Hi,
it seems like there is no official way to trigger a resize event. Before i could use triggerResize(), however I can't find such a helper method anymore. The only way I can trigger a resize event is via google.maps.event.trigger(this.map.context[__SECRET_MAP_DO_NOT_USE_OR_YOU_WILL_BE_FIRED], 'resize') with this.map being the instance passed in onMapMounted. This seems really dirty. Is there a proper way to trigger a resize event?

Most helpful comment

try this one

import { GoogleMap } from 'react-google-maps';
import { MAP } from 'react-google-maps/lib/constants';
import ReactResizeDetector from 'react-resize-detector';
...
const mapInstance = map && map.context[MAP];
const onResize = () => google.maps.event.trigger(mapInstance, 'resize'),
...   
<GoogleMap>
  <ReactResizeDetector handleWidth handleHeight onResize={onResize} />
</GoogleMap>

All 4 comments

Oh my, this is a thing! Thanks for pointing out this 'secret' map object. I finally can do resize on this library

try this one

import { GoogleMap } from 'react-google-maps';
import { MAP } from 'react-google-maps/lib/constants';
import ReactResizeDetector from 'react-resize-detector';
...
const mapInstance = map && map.context[MAP];
const onResize = () => google.maps.event.trigger(mapInstance, 'resize'),
...   
<GoogleMap>
  <ReactResizeDetector handleWidth handleHeight onResize={onResize} />
</GoogleMap>

Any where i can see the full implementation of resize of map on window resize

Please refer to Getting Help section in the README (or #469).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bansalvks picture bansalvks  路  3Comments

ShintaroNippon picture ShintaroNippon  路  3Comments

shrimpy picture shrimpy  路  3Comments

craigcartmell picture craigcartmell  路  4Comments

PaulieScanlon picture PaulieScanlon  路  3Comments