a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Other
125 stars 63 forks source link

Fit bounds doesn't fit properly #112

Closed exilonX closed 2 years ago

exilonX commented 2 years ago

As far as I can imagine, map.fitBounds(LatLngBounds) should position the camera (change zoom level) to match the given bounds.

I noticed some problems with this feature:

  1. I used the position of two markers as bounds. If I initialize LatLngBounds to ((47.072481, 15.417507), (48.185184, 16.376413)) it works fine and it fits correctly, but if I switch the two coordinates ( (48.185184, 16.376413), (47.072481, 15.417507)) then the bounds are set across the globe:

image

  1. After using map.fitBounds zoom becomes unusable, apparently it changes (you can see some flashes on the map, text changing size) but it actually stays the same...

Any ideas how to get around these issues ?

a14n commented 2 years ago

This behaviour comes from the underlying js map API. Instead of creating the LatLngBounds with LatLngBounds(p1, p2) you can use LatLngBounds().extend(p1).extend(p2) to get the behaviour you expect.

exilonX commented 2 years ago

Thanks for the fast reply, this fixes the Bounds across the globe problem.

What about the zoom ? As I told you it stops working, I can move the camera, but zoom in / zoom out doesn't change anything...

a14n commented 2 years ago

Testing on example/02-events/event-closure I don't face the problem you describe. Perhaps something in your code is the cause of this zoom problem.

exilonX commented 2 years ago

Could be 👍 I will investigate further :) Hope to find out the problem...