AlexLavoie42 / Nuxt-Mapbox

Elegant Mapbox integration with Nuxt
81 stars 11 forks source link

Markers rendering in v-for update error? #35

Closed uwaovo closed 1 year ago

uwaovo commented 1 year ago

Environment: OS: MacOSX 13.4 Node: v18.16.0 Nuxt: 3.5.3 Nuxt-Mapbox: 1.3.7

Screenshot:

2023-06-06 21 10 58

Reproduce: When I make a markers template

<template>
  <mapbox-default-marker
    v-for="marker, index in markers"
    :key="`marker ${index + 1}`"
    :marker-id="`marker ${index + 1}`"
    :lnglat="marker.lnglat"
    :options="{
      color: '#ff0000',
    }"
  />
</template>

<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useGlobalStore } from '~/stores/global';

const store = useGlobalStore()
const { markers } = $(storeToRefs(store))

// const markers = $ref<Marker[]>([
//   {
//     lnglat: [113.931, 22.539]
//   },
//   {
//     lnglat: [113.931, 22.538]
//   }
// ])

// onMounted(() => {
//   store.markers.push({
//     lnglat: [113.930, 22.539]
//   })
// })
</script>

This template was fine at first, two markers appeared successfully. When I went to update the markers in the store elsewhere, I encountered the error in the screenshot. As you can see, the latitude and longitude have been passed correctly to the component. However, when I tried to push a new marker in onMounted, it worked fine again. Any suggestions?

AlexLavoie42 commented 1 year ago

Could you please reproduce the issue in the playground? Would help me a lot in finding the issue.

AlexLavoie42 commented 1 year ago

I attempted a fix with 1.3.8-dev.0, can you try using that version and let me know if you still have the same error?

AlexLavoie42 commented 1 year ago

Fixed in #36