Search code examples
typescriptgoogle-mapsgoogle-maps-api-3

Deprecation of the Marker Class - Google Map API warning


I'm developing an app with google maps typescript api, today I get this warn message when the app was launched ->

Starting February 21, 2024, google.maps.Marker will no longer be available. Instead, use google.maps.marker.AdvancedMarkerElement. Find more information about the discontinuation at https://developers.google.com/maps/deprecations.

but AdvancedMarkerElement has no all the properties that has Marker Class... why is that? I updated @types/google.maps to lastest version and I keep getting the same warn anybody know somethign about it? and how to solve it?


Solution

  • This deprecation warning has nothing to do with @types/google.maps – it's a warning that originates in the Google Maps' libraries you load.

    See, Google Maps is versioned. You can explicitly request a version through the optional loading parameter v. If you don't pass one, Google will default to the weekly version – which is where the deprecation warning likely comes from.

    Quick "fix" to get rid of this warning: downgrade to the closest minor version, namely 3.55.

    Long-term fix: evaluate if and how you can/should migrate your Markers to AdvancedMarkers. Remember, Markers are being deprecated, not discontinued – meaning you can essentially continue using them indefinitely for some (legacy) use cases like 3rd party marker clustering etc. Refer to my Marker Comparison Guide or my Marker Customization Guide if you need to brush up on these concepts.

    Lastly, as @ceejayoz suggests in the comments, AdvancedMarkers are essentially a superset of Markers: they extend their functionality and improve performance.