Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@load not firing #1060

Open
johnl6234 opened this issue Jun 28, 2022 · 6 comments
Open

@load not firing #1060

johnl6234 opened this issue Jun 28, 2022 · 6 comments
Assignees
Labels
needs repro 👀 Requires a reproducible example

Comments

@johnl6234
Copy link

johnl6234 commented Jun 28, 2022

The map loads fine but nothing fires from @load

console

util.js:538 The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead.
<template>
    <main class="map-container">
        <VMap class="w-full h-full" :options="state.map" @load="onMapLoaded" />
    </main>
</template>

<script>
import { VMap, } from "v-mapbox";
import mapbox from "mapbox-gl";
import { reactive } from "vue";

export default {
    components: {
        VMap,
    },
    props: {
        workout: Object,
        startPos: Array
    },
    setup(props) {
        const state = reactive({
            map: {
                accessToken:  import.meta.env.VITE_MAPBOX_ACCESS_TOKEN,
                style: "mapbox://styles/mapbox/streets-v11?optimize=true",
                // style: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
                center: props.startPos,
                zoom: 15,
                maxZoom: 22,
                crossSourceCollisions: false,
                failIfMajorPerformanceCaveat: false,
                attributionControl: false,
                preserveDrawingBuffer: true,
                hash: false,
                minPitch: 0,
                maxPitch: 60,
            }
        });

        return {
            state,
        };
    },
    methods: {
        onMapLoaded(event) {
            console.log(' event', event)
        }
    },
    created() {
        // We need to set mapbox-gl library here in order to use it in template
        this.mapbox = mapbox;
    }
}
@oripka
Copy link

oripka commented Jul 1, 2022

I'm having the same issue.

@vinayakkulkarni
Copy link
Owner

Can you do a repro ?

@vinayakkulkarni vinayakkulkarni self-assigned this Jul 7, 2022
@vinayakkulkarni vinayakkulkarni added the needs repro 👀 Requires a reproducible example label Jul 7, 2022
@mrc-bsllt
Copy link

Same issue me!

@mrc-bsllt
Copy link

Can you do a repro ?

this is a repro: https://stackblitz.com/edit/nuxt-starter-lig9bb?file=app.vue

@Buk1m
Copy link

Buk1m commented Oct 5, 2022

Docs seems to be totally outdated, use @loaded event instead.

  VMap(
    :options="{accessToken: 'your-token', style: 'mapbox://styles/mapbox/streets-v11' }"
    @loaded="onMapLoaded"
  )
onMapLoaded(event) {
  this.map = event
}

@PeterEsenwa
Copy link

@Buk1m, yep, outdated docs. Not just this issue but many other little things I had to figure out myself 🥲

@vinayakkulkarni vinayakkulkarni moved this to Todo in v3.x ✨ Mar 9, 2023
@vinayakkulkarni vinayakkulkarni moved this to 📋 Backlog in v4.x ✨ Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro 👀 Requires a reproducible example
Projects
None yet
Development

No branches or pull requests

6 participants