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

Issue with using Marker in Vue 3 #943

Open
UXandre opened this issue May 3, 2022 · 8 comments
Open

Issue with using Marker in Vue 3 #943

UXandre opened this issue May 3, 2022 · 8 comments
Assignees
Labels
bug Something isn't working needs repro 👀 Requires a reproducible example

Comments

@UXandre
Copy link

UXandre commented May 3, 2022

Hi, first of all thank you for maintaining the amazing package.
I managed to add the map in Vue 3 through composition API but have an issue when trying to add the marker.

This is the error I got

[Vue warn]: Missing required prop: "options" 
[Vue warn]: Missing required prop: "popupOptions" 
[Vue warn]: Unhandled error during execution of setup function 

When adding the marker, the whole component can't be resolved. Can't figure out why. I noticed there is a variation between the prop names used in the document and the ones actually used in the examples. Would it be the reason? If so, what prop names I should use for VMarker for vue 3?

Thank you!

<template>
    <v-map class="w-full h-full" :options="state.map">
       // The following line causes the issue.
        <v-marker :coordinates="coordinates" color="blue" />
    </v-map>
</template>

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

export default {
    components: {
        VMap,
        VMarker
    },
    setup() {
        const state = reactive({
            map: {
                accessToken:
                    "pk.eyJ1xxxxxxxxxxxxxxxfdsfasfsdfsadfasfdfdsfaketoken",
                center: [-0.0995, 51.5244],
                zoom: 11,
                maxZoom: 22,
                crossSourceCollisions: false,
                failIfMajorPerformanceCaveat: false,
                attributionControl: false,
                preserveDrawingBuffer: true,
                hash: false,
                minPitch: 0,
                maxPitch: 60
            }
        });

        const coordinates = [-0.0995, 51.5244];
        console.log(coordinates);

        return {
            state,
            coordinates
        };
    }
};
</script>

<style lang="scss">
@import "mapbox-gl/dist/mapbox-gl.css";
@import "v-mapbox/dist/v-mapbox.css";
</style>

Update

After digging into the errors, I've made a bit of progress. It seems like the color needs to be specified in the option prop. And the popupOption needs to be added too. This is a bit confusing to me as I would simply like to get it up and running with all the default setup. I had to pass an empty object like {} to the VMarker component to avoid the error. After I did so, my code became:

<template>
    <v-map class="w-full h-full" :options="state.map">
     
       <VMarker
            :coordinates="coordinates"
            :options="{ color: 'blue' }"
            :popupOptions="{}"
        />
    </v-map>
</template>

Now I get these errors:

[Vue warn]: Unhandled error during execution of setup function 
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug
@vinayakkulkarni vinayakkulkarni self-assigned this May 4, 2022
@vinayakkulkarni vinayakkulkarni added bug Something isn't working needs repro 👀 Requires a reproducible example labels May 4, 2022
@vinayakkulkarni
Copy link
Owner

Can you please create a repro ?

@UXandre
Copy link
Author

UXandre commented May 4, 2022

@vinayakkulkarni sure. Here goes the codesandbox repro

Thank you!

@manualy
Copy link

manualy commented May 8, 2022

I have a similar problem with the marker, it requires :options (can't find anything about them in the docs), also when I add a random option eq: color, the map doesn't load, everything works fine until I try to add the VMarker.

@UXandre
Copy link
Author

UXandre commented May 9, 2022

@vinayakkulkarni hope you had a wonderful weekend! Have you got a chance to look at the issue?

@vinayakkulkarni
Copy link
Owner

@vinayakkulkarni hope you had a wonderful weekend! Have you got a chance to look at the issue?

Hey @UXandre, unfortunately I didn’t get a chance to review this last weekend but will take a look this week

@UXandre
Copy link
Author

UXandre commented May 10, 2022

@vinayakkulkarni sounds good and thank you so much!

@vinayakkulkarni
Copy link
Owner

https://codesandbox.io/s/v-mapbox-w-marker-s-om6yys

I forked this and set up v-mapbox w/ marker, I'll check the events as well

@UXandre
Copy link
Author

UXandre commented May 13, 2022

@vinayakkulkarni thanks so much! By simply copy and pasting I managed to get the marker up and running. Will spend some time to digest the logic of the code later today. What events are you referring to?

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

No branches or pull requests

3 participants