<script setup>
import { watch } from "vue";
import { bindGoogleMapsEvents, useGoogleMapsResource } from "./useGoogleMapsResource";
const props = defineProps({
  options: { type: Object, required: false }
});
const emit = defineEmits(["click", "contextmenu", "dblclick", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "drag", "dragend", "dragstart"]);
const eventsWithPolyMouseEventPayload = [
  "click",
  "contextmenu",
  "dblclick",
  "mousedown",
  "mousemove",
  "mouseout",
  "mouseover",
  "mouseup"
];
const eventsWithMapMouseEventPayload = [
  "drag",
  "dragend",
  "dragstart"
];
const polyline = useGoogleMapsResource({
  create({ mapsApi, map }) {
    const p = new mapsApi.Polyline({ map, ...props.options });
    bindGoogleMapsEvents(p, emit, {
      withPayload: [...eventsWithPolyMouseEventPayload, ...eventsWithMapMouseEventPayload]
    });
    return p;
  },
  cleanup(p, { mapsApi }) {
    mapsApi.event.clearInstanceListeners(p);
    p.setMap(null);
  }
});
watch(() => props.options, (options) => {
  if (polyline.value && options) {
    polyline.value.setOptions(options);
  }
}, { deep: true });
</script>

<template>

</template>
