doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 8 forks source link

Cluster and infowindow bug #95

Closed twitcher07 closed 9 months ago

twitcher07 commented 10 months ago

Hi there,

First of all, let me say I love using this plugin for Craft. It's always been a useful tool in my web development process.

However, I'm using the marker clustering feature for the first time and I seem to be experiencing a bug. I'm using just the default cluster rendering (no custom rendering in my example) and markers have info windows associated with them. I can replicate the bug usually by following these steps:

  1. Click on a cluster.
  2. Click on a marker that has a info window and let it show.
  3. Zoom out until the info window is hidden because the markers in cluster #​1 turn back into a cluster marker.
  4. Click on a different cluster.

For me the bug (like you will see in the screen recording below) is that the map will zoom into the cluster in step #​4 but then will quickly pan to the info window that wasn't closed in step #​2.

https://github.com/doublesecretagency/craft-googlemaps/assets/8517321/0d8bbc63-09ba-4ae5-9771-823663023340

Let me know if you need to see any examples of my code or what i should do to fix this bug. Thank you!

lindseydiloreto commented 9 months ago

Hi @twitcher07, thanks for reporting. Glad you're digging the plugin! 🙏

This turned out to be a very tricky issue to solve. Clustering is managed by a separate external library, which was only acquired by Google within the past few years. There are some notable gaps between the two libraries... in this case, it turns out there is no callback when a marker becomes hidden within a cluster.

I tried several different hacky solutions, but most of them didn't even work. Hats off to @zizther, who gave me a fix early on which largely resolved the problem. His solution gets us about 90% of the way there. And after battling with it for a few days, I now believe that last 10% may be impossible to achieve.

The remaining 10% is simply when the map animates while zooming. This zoom animation cannot be controlled or disabled. The timing of this animation disrupts our solution, with no alternative workarounds available to replace it. We may have to accept that our 90% is as good as it's going to get.

When you get a chance, would you mind testing this patch?

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

Hope that helps, let me know if it does the trick for you!

lindseydiloreto commented 9 months ago

Good news, this fix has been officially released in v4.3.6. 👍

twitcher07 commented 9 months ago

@lindseydiloreto Sounds like it was a really tricky issue. I appreciate you looking into it.

I installed v4.3.6 of the plugin and can confirm that what you have done solves the bug I was experiencing. Thank you so much!

lindseydiloreto commented 9 months ago

Excellent, thanks for reporting back! 🍺