Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdvancedMarkerElement #861

Closed
castillo-n opened this issue Oct 1, 2024 · 5 comments
Closed

AdvancedMarkerElement #861

castillo-n opened this issue Oct 1, 2024 · 5 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@castillo-n
Copy link

Hi, first of all, thank you all for doing what you are doing! you make my life easier.
Now to the request. I started seen today a message from google maps
As of February 21st, 2024, google.maps.Marker is deprecated. Please use google.maps.marker.AdvancedMarkerElement instead. 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. Please see https://developers.google.com/maps/deprecations for additional details and https://developers.google.com/maps/documentation/javascript/advanced-markers/migration for the migration guide.
I tried it but couldn't make it work. Then I tried looking into the source code for the advanced marker element option but I can't find it. If you do have it already, I am sorry for wasting your time. Thanks!

@castillo-n castillo-n added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Oct 1, 2024
@usefulthink
Copy link
Contributor

Did you see the migration guide? https://developers.google.com/maps/documentation/javascript/advanced-markers/migration

That should contain everything you need. Feel free to ask If you get stuck on that.

@usefulthink usefulthink added type: question Request for information or clarification. Not an issue. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. triage me I really want to be triaged. labels Oct 1, 2024
@castillo-n
Copy link
Author

thank you so much!

@castillo-n
Copy link
Author

castillo-n commented Oct 2, 2024

I tried and it didn't work
After I changed the libraries from

import { Loader } from '@googlemaps/js-api-loader';
...
const google = await new Loader({
    apiKey: GOOGLE_MAPS_API_KEY,
    version: 'weekly',
    libraries: ['places'],
  }).load();

to

import { Loader } from '@googlemaps/js-api-loader';
...
const google = await new Loader({
    apiKey: GOOGLE_MAPS_API_KEY,
    version: 'weekly',
    libraries: ['places', 'marker'],
  }).load();

the map didn't load.
Even when I changed the call from

        return new google.maps.Marker({

to

        return new google.maps.marker.AdvancedMarkerElement({

the map still didn't load

@castillo-n
Copy link
Author

castillo-n commented Oct 2, 2024

this is my old marker

        return new google.maps.Marker({
          position: new google.maps.LatLng(latitude, longitude),
          title: `Marker at latitude: ${latitude} and longitude: ${longitude}`,
          map: vm.map,
          draggable: false,
          icon: vm.image,
          animation: google.maps.Animation.DROP,
        });

this is my new one after all the modifications (I made changes one by one to see if the map would load but it didn't)

const gz = document.createElement('img');
gz.src = vm.image;
return new google.maps.marker.AdvancedMarkerElement({
          position: { lat: latitude, lng: longitude },
          title: `Marker at latitude: ${latitude} and longitude: ${longitude}`,
          map: vm.map,
          draggable: false,
          content: gz,
          animation: google.maps.Animation.DROP,
        });

@castillo-n castillo-n reopened this Oct 2, 2024
@usefulthink
Copy link
Contributor

usefulthink commented Oct 10, 2024

This isn't really the place for questions like this. If you need assistance, you could ask on stackoverflow or join the Google Maps Platform Discord. Links are here: https://developers.google.com/maps/developer-community

One note about the code you posted: the AdvancedMarkerElement is not a "drop in" replacement for the marker and has different properties and features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants