Skip to content

MapMarker component seems to lag significantly when being made conditionally visible #119

@CyberSekure

Description

@CyberSekure

Hey there,

I'm trying to use the MapboxDefaultMarker component to place a result on the map from a custom geocoder result.

My code is something similar to the below:

<MapboxMap
  map-id="main-map"
  :options="{
    style: 'mapbox://styles/mapbox/standard',
    center: center,
    zoom: zoom,
    minZoom: minZoom,
    maxZoom: maxZoom,
  }"
  class="h-full w-full"
>
  <MapboxDefaultMarker
    v-if="searchResultMarkerVisible"
    marker-id="search-result"
    :options="{ color: '#3b82f6', draggable: false }"
    :lnglat="searchResultMarkerCoords"
  >
  </MapboxDefaultMarker>
</MapboxMap>
<script setup>
const center = ref([0, 0]);
const zoom = ref(7);
const minZoom = 5;
const maxZoom = 18;

const handleGeocoderResultClicked = (result) => {
  searchResultMarkerCoords.value = result.center;
  searchResultMarkerVisible.value = true;
  mapRef.value?.flyTo({ center: result.center, zoom: 16 });
};

const handleGeocoderResultCleared = () => {
  searchResultMarkerVisible.value = false;
};
</script>

When I trigger either of the two above functions there's a definite delay with the responsiveness of the geocoder component and the map + marker. Is there some sort of delay that when the component turns visible?

If this helps, when I use a source layer instead of marker to display a point, there is zero lag/delay in updating it. I do this just by setting the data for the source to a point value mapRef.value?.getSource('search-result').setData(searchResultGeojson.value);

My guess is that this is due to the marker component rendering and the source option above works because it's already rendered and I'm just updating the data for it??

Fairly new to Nuxt so please let me know if I'm doing something wrong!

Many thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions