Barcoma
Barcoma

Reputation: 89

MapBox GL Acces Token required

Sorry if this is stupid, i'm new to vue JS

I'm trying to implement a mapbox map in a vue component (SFC).

Everything seems to be working but i keep getting an error that mapbox-gl requires a acces token. But i set the mapboxgl.accesToken to mine.

<template>
<div>
  <p> {{msg}} </p>
  <div id="map" ref="map"></div>
</div>
</template>

<script>
import mapboxgl from 'mapbox-gl'


export default {
  name: 'MapBox',
  props: {
    msg: String
  },
  mounted(){
    mapboxgl.accesToken = 'pk.eyJ1IjoiYmFyY29tYSIsImEiOiJjam9xM3gwYWYwMHlpM3ZrZmY4NWNwam9kIn0.TE3Zma1nEd5mbbdVCfQGMA';
    var map = new mapboxgl.Map({
      container: 'map',
      style: 'mapbox://styles/mapbox/streets-v9',
      center: [-122.420679, 37.772537],
      zoom: 13
  });
  }
}
</script>

Anything helps

Upvotes: 0

Views: 148

Answers (1)

Ryan Hamley
Ryan Hamley

Reputation: 2029

You have a typo. You're setting mapboxgl.accesToken with one s. It should be accessToken.

Upvotes: 1

Related Questions