Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triggerEvent('resize') does...what? #337

Closed
ariesshrimp opened this issue Sep 16, 2016 · 7 comments
Closed

triggerEvent('resize') does...what? #337

ariesshrimp opened this issue Sep 16, 2016 · 7 comments

Comments

@ariesshrimp
Copy link

ariesshrimp commented Sep 16, 2016

http://react-google-maps.tomchentw.com/#/?_k=vkf06f

If you load this in Chrome nightly and open the console, you can see the logs dump on the window resize event, but the map is not being updated to reflect the changing screen size.

The example code just logs the component instance on resize. But how does one actually trigger the resize on the map, with access only to the component? Looking at the source code, it looks like triggerEvent just spreads the args, but my understanding of the gMaps API is that I need to run something like map.setCenter or setBounds or something on the event?

What's the way to do this on the given implementation? I wouldn't ask, but it just doesn't seem to be working in the demo example.

Thanks!

@tomchentw
Copy link
Owner

Could you check if this issue still exists on 6.0.0? It's released on npm beta tag now. We also have a new demo page. Feel free to try it:
https://tomchentw.github.io/react-google-maps/

@r2dev
Copy link

r2dev commented Oct 26, 2016

I have updated to v6, and used ref to expose the google map element. since there is no 'util/triggerEvent' any more, I just call the google.map.event.trigger to trigger 'resize' on the element, unfortunately it doesnt work correctly. I assume the google map element i got is modified by library because I saw there is no setCenter and setZoom.

Is there any implementation related to this issue, much appreciated!

update Nov 21, 2016:
For anyone who has the same problem. the solution for me is:

the google map element which I exposed by refs has a secrect map object on its context
code:

google.maps.event.trigger(this._map.context['__SECRET_MAP_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'], 'resize')

__SECRET_MAP_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is a real thing

@reintroducing
Copy link

I'm also looking for setZoom which used to be available and no longer is. What is the new implementation of this in v6.x?

@davidcole1340
Copy link

@reintroducing You can change the zoom with the zoom prop on your GoogleMap.

@reintroducing
Copy link

@uniquoooo I could have sworn I tried that and it was causing performance issues but I may be thinking of a different library I tried (these past few days have been a nightmare of Google Maps for me :) Thanks, when I can I'll circle back to upgrading and see if that works.

@tomchentw
Copy link
Owner

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

@danadn
Copy link

danadn commented Jul 26, 2017

@r2dev could you please share a code snippet about how/where to make the ref for example in the main sample?
https://github.com/tomchentw/react-google-maps#withgooglemap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants