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

Expose raw MapboxGl object #227

Open
Maro8311 opened this issue May 7, 2021 · 1 comment
Open

Expose raw MapboxGl object #227

Maro8311 opened this issue May 7, 2021 · 1 comment

Comments

@Maro8311
Copy link

Maro8311 commented May 7, 2021

Hello everyone,
how I can I get access to the raw MapboxGl object? Thx a lot!

<template>
  <MglMap> /* some properties */> </MglMap>
</template>

<script>
import { Mapbox } from "mapbox-gl"
import { MglMap }  from "vue-mapbox"
export default {
 name: "MapComponent",
  components: {
    MglMap
  },
 created() {
    console.log(Mapbox.getCenter()) // does not work:   Mapbox is undefined
 }
}
</script>
@hicham-saddek
Copy link

You will have to use

<template>
  <MglMap @load="handleMapLoad"> /* some properties */> </MglMap>
</template>

<script>
import { Mapbox } from "mapbox-gl"
import { MglMap }  from "vue-mapbox"
export default {
 name: "MapComponent",
  components: {
    MglMap
  },
 data(){
     return {
         map: null,
         mapbox: null
     }
 },
 created() {
    this.mapbox = Mapbox;
 },
 methods: {
    handleMapLoad(event){
        this.map = event.map
        this.ready();
    },
    ready(){
         console.log(this.map.getCenter());
    }
 }
}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants