I am trying to use the leaflet map in Vue, but keep getting the error:
Uncaught Error: Map container not found.
This is what my component looks like:
<template>
<div id="app" class="container">
Map
<div class="col-md-9">
<div id="mapid"></div>
</div>
</div>
</template>
<style scoped>
#mapid {
height: 800px;
}
</style>
<script>
import L from 'leaflet'
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ? <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: ''
}).addTo(mymap);
</script>
I have also added the Leaflet CSS and JavaScript under that in my index.html
head.