I have create a marker using advancedMarkerView
const centerMarkerE = document.createElement("div");
let centerMarkerHtml = "<div class='center_marker'><img src='/images/front/pin.png' /></div>";
centerMarkerE.innerHTML = centerMarkerHtml;
centerMarker = new google.maps.marker.AdvancedMarkerView({
map,
position: initialLocation,
content: centerMarkerE,
});
For normal marker I can use setPosition(initialLocation) but it not work for AdvancedMarkerView
How can I change the position of advance marker ?
Use Dot Notation instead of a setter method
AdvancedMarkerElementOptions interface have a
positionproperty. The documentation describes it this way:So if you are instantiating an advanced marker like this:
You can change position within a click event listener like this:
And this should work as expected.
Here's a sample snippet that you can play around with and check:
I hope this helps!