Answer the question
In order to leave comments, you need to log in
How to add map from Leaflet via Vue?
app.vue
<template>
<div id="app">
<AppMap/>
</div>
</template>
<script>
import AppMap from './components/AppMap'
export default {
name: 'App',
components: {
AppMap
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<template>
<div class="AppMap" id="AppMap">
<h1>{{msg}}</h1>
</div>
</template>
<script>
const mymap = L.map('AppMap').setView([55.75222, 37.61556], 13);
const attribution = '© <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors';
const tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const tiles = L.tileLayer (tileUrl, {attribution});
tiles.addTo (mymap)
export default {
name: 'AppMap',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
#AppMap {
height: 500px;
width: 800px;
}
</style>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question