vue3-google-map icon indicating copy to clipboard operation
vue3-google-map copied to clipboard

is draggable option supported in CustomMarker?

Open KunalKshatriya opened this issue 2 years ago • 4 comments
trafficstars

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

KunalKshatriya avatar Apr 14 '23 18:04 KunalKshatriya

No this isn't yet supported but it's something we can add.

HusamElbashir avatar May 31 '23 05:05 HusamElbashir

What about AdvancedMarker, e.g. this?

wickedest avatar Nov 04 '24 16:11 wickedest

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...".

wickedest avatar Nov 04 '24 17:11 wickedest

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;
}

scottix avatar Nov 05 '24 19:11 scottix