FlowingCode / GoogleMapsAddon

Vaadin Addon based on Google Maps Web Component
https://www.flowingcode.com/en/open-source/
Apache License 2.0
19 stars 7 forks source link

"google.maps.Marker is deprecated" warning #121

Open paodb opened 3 months ago

paodb commented 3 months ago

Got this message while running the add-on:

image

The mentioned link is https://developers.google.com/maps/documentation/javascript/advanced-markers/migration

This needs to be investigated.

paodb commented 2 months ago

I did some testing regarding this issue. Following the instructions in the migration link did not work as straight forward at it is supposed to. Problems or differences I found: 1- To use AdvancedMarkers it is required to define a mapId 2- AdvancedMarkers library needs to be load from within an async function when needed or add the '&libraries=marker' parameter to the API url

Then, found this blogpost that mentions that an Advanced Markers Utility Library for JavaScript developers was also released, and can be use to define Advanced Markers. The web component will need to add the import import {Marker} from '@googlemaps/adv-markers-utils'; and the 2 points mentioned above are needed as well.

Tested both approachs and they both make the demos using markers to break in different ways. For example, icons or colors are not being taken into consideration, clustering does not work (the version of markerclusterer library need to be updated to a newer version to support AdvancedMarkers), there's a setMap method that doesn't seem valid anymore. Logic on how markers are added will need to be reviewed and updated if the migration takes place.