vue3-google-map
vue3-google-map copied to clipboard
is draggable option supported in CustomMarker?
Hi, I am using in maps in my application where I wish show the custom marker and provide the drag functionality. I tried using CustomMarker with draggable option. But it seems not to be working.
Is there any workaround I can try?
Thanks
No this isn't yet supported but it's something we can add.
What about AdvancedMarker, e.g. this?
nvm - I was going about it the wrong way trying to get a ref (didn't work) and binding a listener to that, but had a eureka moment when I realized I could just bind the event.
<AdvancedMarker
ref="markerRef"
:options="{ position: center, gmpDraggable: true }"
@dragend="onDragEnd"
/>
☝️ I think this would be handy to show examples of this somewhere. The documentation for events only says "You can listen for the following events...".
I was in the same boat but I got it to work by overriding the content
const markerOptions = computed(() => {
if (!siteForm.lat || !siteForm.lng) return {};
return {
position: { lat: siteForm.lat, lng: siteForm.lng },
gmpDraggable: true,
content: createCustomPin()
}
});
const createCustomPin = () => {
const img = document.createElement('img');
img.src = '/imgs/google_map_pin.png';
img.style.width = '100%';
img.style.height = '100%';
return img;
}