-
Notifications
You must be signed in to change notification settings - Fork 143
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
Zoom issue #249
Comments
Here is the code: <template>
<MglMap id="map"
:accessToken="accessToken"
:mapStyle="mapStyle"
:center="center"
:zoom="zoom"
@load="onMapLoaded"
@click="userClick">
</template>
<script>
import Mapbox from "mapbox-gl";
import { MglMap } from "vue-mapbox";
export default {
components: {
MglMap
},
data() {
return {
accessToken: process.env.VUE_APP_MAPBOX_ACCESS_TOKEN, // my access token
mapStyle: 'mapbox://styles/mapbox/streets-v11',
center: [4.7500, 52.2900], // starting position
map: null,
zoom: 10, // starting zoom
coordinates: [4.7828,52.2557],
popupTxt: "",
};
},
methods:{
onMapLoaded(event) {
this.map = event.map;
}
},
created() {
// We need to set mapbox-gl library here in order to use it in template
this.mapbox = Mapbox;
}
}; |
I found the cause and solution. I missed the parentheses in <template>
<MglMap id="map"
...
@load="onMapLoaded()"
...
</template> |
I was wrong !! <template>
<MglMap id="map"
:accessToken="accessToken"
:mapStyle="mapStyle"
:center="center"
:zoom="zoom"
@load="onMapLoaded"
@click="userClick">
</template>
<script>
import Mapbox from "mapbox-gl";
import { MglMap } from "vue-mapbox";
let map;
export default {
components: {
MglMap
},
data() {
return {
accessToken: process.env.VUE_APP_MAPBOX_ACCESS_TOKEN, // my access token
mapStyle: 'mapbox://styles/mapbox/streets-v11',
center: [4.7500, 52.2900], // starting position
zoom: 10, // starting zoom
coordinates: [4.7828,52.2557],
popupTxt: "",
};
},
methods:{
onMapLoaded(event) {
map = event.map;
}
},
created() {
// We need to set mapbox-gl library here in order to use it in template
this.mapbox = Mapbox;
}
};
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used the examples in documentation to create new project. As you can see in the following gif when I zoom in, my map get corrupted without any exceptions or error in console. Could you please help me debug this strange issue? 😄
Let me know if you need any part of the source code.
The text was updated successfully, but these errors were encountered: