google.maps.Marker is deprecated

Created on 22 February 2024, 4 months ago
Updated 26 February 2024, 4 months ago

Problem/Motivation

Receiving this warning in the console when displaying a map through this module:

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.

Steps to reproduce

Display a map using the Geofield Google Map format in a Views listing.

Proposed resolution

Update the code to use the advanced marker element as identified in the warning.

User interface changes

None

API changes

None

Data model changes

None

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States john.oltman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @john.oltman
  • Assigned to samit.310@gmail.com
  • Status changed to Needs work 4 months ago
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    Thanks for reporting this.
    It looks that more generally requiring a Google Maps API v3 fixes this.
    Please Test, QA and Review the attached patch that looks getting rid of that google.maps APIs warning to me,
    and if confirmed could be committed into dev and be part of the next Geofield Map module release.

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States john.oltman

    The patch didn't help, so i did some more digging, and found this:

    https://stackoverflow.com/questions/78042237/deprecation-of-the-marker-c...

    Not sure if/how you can pin to 3.55 of Google Maps. If you can with a different patch, I'll give it a try. For now I put this in "Needs work" status, but this could end up being a Won't Fix if pinning the version is outside your scope.

  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    @john.oltman could you better elaborate why the #3 patch didn't help you?

    Please bear in mind that it applies (should be applied) to the actual 3.0.x-dev HEAD (and not to 3.0.14 version).

    Actually that patch is being applied to this Geofield Map demo page:
    https://www.geodemocracy.com/drupal_geofield_stack_demo/web/

    fixing / resolving that warning, as you can see form the web browser console,
    how it is being documented in the attached screenshots.

    It looks that change is going to require / load latest Google Maps v.3 library version ...
    and also accomplishing your suggestion in your latest comment.

    Please correctly apply the #3 patch, and clear your drupal & browser cache, and come back again to this review.
    Eventually explain what is not working for you, because #3 looks a general fix to this, to me.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States john.oltman

    Yes I did apply the patch to dev branch (as you mentioned, it doesn't apply anywhere else). I will dig a bit more to see if a second usage of maps is sneaking into our site somehow. But reviewing your patch, it doesn't seem to do anything except switch from Maps API v3 Experimental to Maps API v3 - both are version 3. That wouldn't seem to switch the marker usage.

  • Issue was unassigned.
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    Please clear Drupal & Browser cache after applying.
    It removes the warning reported in this issue, in my general use cases (inspect the mentioned demo page above).

    It wonโ€™t be possible to switch to a general use of google.maps.marker.AdvancedMarkerElement in the context of this issue, because the module still relies on wrapping libraries (such spiderify and markerclusterer that would need refactoring upstream).

    Simply having removed the reported warning from Google maps library looks good here.

    And please donโ€™t move back to โ€œneeds workโ€ unless you clearly reported a negative outcome of the #3 patch.

  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States john.oltman

    Hi @itamair, turns out we were loading the Maps API JS file via a different method - Geofield Map does check this, so it did not attempt to load the library a second time, thankfully. This means our site is not a good test of your patch. However, I did see that version 3.56 is officially released, which includes the deprecation message. So I wonder if your patch will continue to work. Therefore I am uploading a version of the patch that pins the release to v3.55, which is the last release prior to the deprecation message:

    https://developers.google.com/maps/documentation/javascript/releases

    I changed our method of the Maps API load to specify v3.55 in the URL, and that solved the issue for our site, so in this way I can confirm that pinning to v3.55 gets rid of the message. Less than ideal though since anyone pinning to a version will start to fall behind on security patches and features that Google adds to the library over time. In any case, neither of our patches are good long term solutions regardless, as you noted, since the real answer is going to mean a rewrite of a lot of code eventually.

  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    Ok. Got all this ...

    according to this: https://developers.google.com/maps/documentation/javascript/versions
    the v=weekly is the way to go to align with the most current and up-to-date version ...

    New patch attached is still fixing this issue to me.

    • itamair โ†’ committed e1e3f780 on 3.0.x
      Issue #3423207 by itamair, john.oltman: google.maps.Marker is deprecated
      
  • Status changed to Fixed 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    Patch #12 committed into dev, will be part of the next incoming Geofield Map release.
    Thanks ... closing this as Fixed.

  • Status changed to Active 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly itamair

    errata corrige ... the patch #13 and the latest geofield map module release 3.0.15,
    still don't get rid of this issue warning, hence I am reopening this,
    though with "minor" state (as it is ... ).
    Don't have a clear fix for this at the moment ...

    Will welcome any solid and general fix to this issue, if any incoming.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States john.oltman

    Weekly isn't going to work as that brings in v3.56, then v3.57 when that is released, etc etc. Literally, one has to pin the library to v3.55 to stop the message, since 3.56 and later displays it. It's that simple. Hence the patch I uploaded that was tested but then ignored. I agree that v=weekly is best from a "I want the latest updates" perspective, but that will never prevent the deprecation message if that is the goal. I'm not even sure preventing the message by "hiding it via version constraint" is a worthwhile goal any more, but that is a different conversation.

    I agree with keeping this open as a Minor issue. Eventually (and it could be years from now), the existing Marker code will need to be replaced with Advanced Marker to resolve this the right way.

Production build 0.69.0 2024