Open MGHawes opened 6 years ago
Yeah, I remove the event trigger in v8.0.0 rewrite.
Since we have a jscodeshift API, I'm thinking we can just add event trigger
function on the component itself:
refs.map.trigger('resize');
// in GoogleMap.js
trigger(...args) {
return google.maps.event.trigger(this.context[MAP], ...args);
}
What do you think?
That seems pretty clean to me and would suit my needs. I can't think of a reason why this would be an unsuitable interface for event.trigger(). My only thought would be that if we expose trigger() would it not also be sensible to expose the rest of the event namespace in some way. And if the whole namespace is exposed maybe there's a better way of doing it?
What are the objections to exposing the map object itself? This would eliminated the need to expose all parts of the Google maps api that interact with the map. I can see that it could lead to messy implementations where react-google-maps users try to overwrite behaviors of the GoogleMap class by using the map object. But really this comes down to the user making a poor choice? I'm open to refusal on this 😄, especially from a learning point of view.
the rest of the event namespace
It's already exposed as React props
What are the objections to exposing the map object itself?
google.maps.MVCObject
are often used in a imperative way, which is in the opposite of what React does. I just want to make it simple, declarative and easy to use. For complex features, I can't find any good way to bridge it into React.
PRs welcomed. Help me please
@tomchentw can i make a PR with your solution:
refs.map.trigger('resize');
// in GoogleMap.js
trigger(...args) {
return google.maps.event.trigger(this.context[MAP], ...args);
}
is there a working example of how to use it?
Any updates? I'd LOVE to see that PR merged.
So I've been using this component for a while and ran into a known issue with the Google Maps Api v3. Namely this issue. The upshot being that when the component updates I need to trigger a resize event. Currently I'm doing this in the most horrible way imaginable:
I've cut a lot out for brevity, essentially my issue is that I want to have the ability to resize as an exposed feature. Or via the map object itself exposed via some stable means; I'm open to suggestions. However, I think we should at least in principal expose as much of the Google Maps Api as possible/feasible?
I am more than happy to work on this an submit a PR but thought I'd get some guidance first about implementation. Hopefully I've been thorough enough and you guys think this is worth some time 😄