I am migrating map markers to AdvancedMarkerElement and I want to add custom properties to AdvancedMarkerElement.
Like this:
new AdvancedMarkerElement({
map: this.map,
position: data.position,
dataWHD: data.data,
})
This produces the following error:
Unknown property 'dataWHD' of AdvancedMarkerElement
How can I do this?
You can't add custom properties directly to the
AdvancedMarkerElementconstructor.Instead, you can transfer your custom properties via the
AdvancedMarkerElementcontentproperty so you can build your own markers with whatever data you need.Below is an example from the official documentation.
Method 1
Method 2
Alternatively, you can also set custom properties after you have created the
AdvancedMarkerElementbut not in the constructor.This uses
v: "beta"becausegmpClickableis currently only available in the beta version (March 2024).