GuillaumeLeclerc / vue-google-maps

Google maps component for vue with 2-way data binding
560 stars 653 forks source link

added zoom_changed event #59

Closed plarsson closed 8 years ago

GuillaumeLeclerc commented 8 years ago

This PR does not add any feature. zoom is already a 2 way bounded. You just have to "$watch" it.

If you think there is a use case for events please explain and I will reopen

plarsson commented 8 years ago

Ok, yes I forgot that zoom is 2 way. I'm using the dragend and zoom event to trigger a search when the map is moved / zoomed. I can't use the boundschange event as that one is triggered in many other unwanted occasions. For example a info window popup could move the map. In a perfect world I would like to have a "manual bounds change event" . I think it make kinda sense to expose this zoom event so it can be implemented and used in a similar way to dragend etc. But its not a big deal.

GuillaumeLeclerc commented 8 years ago

My first logic was to remove any event where the name is xxx_changed, where xxx is a props. (because I'm already using this event to trigger changes in the data object).

If you think there is a need for zoom_changed then that means we need to change this policy and therefore do it for every component/props to make it consistent. Consistency is key. It helps users to "guess" how to use this plugin just by reading the Google maps API reference.

plarsson commented 8 years ago

Ok, yes I fully agree. I just figured out it's not working very well anyway. When I receive the zoom_changed events it's not guaranteed in any way that the bounds props has been updated. So I need another solution. I would prefer to just have a simple watch on the bounds or center property and not rely on any raw events. However thats not going to work as they're changing on many other things than a "manual move" which I'm looking for. Any idea how to solve my problem?

GuillaumeLeclerc commented 8 years ago

What do you mean by "manual move". (Maybe you can explain your problem in a new issue, I'll do my best to help you)

plarsson commented 8 years ago

Yes sure, I can do a full example later but quick.. with manual move I meant a user drag or a user initiated zoom.

GuillaumeLeclerc commented 8 years ago

I see, and why does bounds_changed does not fit your needs ?

plarsson commented 8 years ago

The bounds_changed event is triggered also for example when an info window popup doesn't fit fully on the map. This means that the map scrolls and the bounds_changed event is triggered. This is one case where I don't want to take action such as executing a new search request.