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 9 forks source link

Warning on browser console: google.maps.Marker is deprecated #106

Closed johndwells closed 7 months ago

johndwells commented 7 months ago

We have a simple "Dynamic" Google Maps implementation, looks just like the example code under Creating a Map in Twig. It renders fine on the front end.

But what has started appearing today is the following warning in the browser console:

As of February 21st, 2024, google.maps.Marker is deprecated. Please use google.maps.marker.AdvancedMarkerElement instead. Please see https://developers.google.com/maps/deprecations for deprecation details

The relevant portion of that page is here:

google.maps.Marker in the Maps JavaScript API (Deprecated as of February 2023) Advanced Markers (google.maps.marker.AdvancedMarkerElement) are better than google.maps.Marker in almost every way: easier to use, more performant, more accessible, more feature-rich, and more customizable. google.maps.Marker in the Maps JavaScript API is deprecated as of 3.56. What do I need to do? The minimum version of the Maps JavaScript API with google.maps.marker.AdvancedMarkerElement is 3.53.2. At this time, google.maps.Marker is not scheduled to be discontinued, but google.maps.marker.AdvancedMarkerElement is recommended over google.maps.Marker. While google.maps.Marker will continue to receive bug fixes for any major regressions, existing bugs in google.maps.Marker will not be addressed. At least 12 months notice will be given before support is discontinued.

The conflicting dates has me confused, makes me wonder if the message has been appearing since before today, and it's only a coincidence that I started noticing it on the exact date the message says the deprecation goes into effect... but regardless, I guess it's something to look into. I've checked a couple of our sites that use Google Maps, and they are all now outputting this message into the console.

Craft Version: 4.7.3 Google Maps version: 4.3.11

lindseydiloreto commented 7 months ago

Good news (mostly)! This has been fixed in v4.4.0.

In order to avoid this deprecation warning, we have pinned the underlying Google Maps API to v3.55. This was the last version of the API before those warnings began being thrown.

This is a good short- to medium-term solution. It should technically work indefinitely, even if the site is stuck on Craft 4.

For a better long-term solution, we'll be exploring our options in Craft 5. We will likely be introducing support for Advanced Markers in C5, and cannot promise any backwards-compatibility.

Thanks for reporting this @johndwells! 🍺