Vue2Leaflet Demo
HTML
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.4/vue.js"></script>
<script src="https://unpkg.com/vue2-leaflet@0.0.55/dist/vue2-leaflet.js"></script>
<body>
<div id="app">
<v-map :zoom="zoom" :center="center">
<v-tilelayer :url="url" :attribution="attribution"></v-tilelayer>
<v-marker v-for="contact in contacts" :lat-lng="contact.address.position">
<v-popup :content="contact.name"></v-popup>
</v-marker>
</v-map>
</div>
</body>
CSS
html, body, #app {
height: 100%;
margin: 0;
}
JavaScript
Vue.component('v-map', Vue2Leaflet.Map);
Vue.component('v-tilelayer', Vue2Leaflet.TileLayer);
Vue.component('v-marker', Vue2Leaflet.Marker);
Vue.component('v-popup', Vue2Leaflet.Popup);
new Vue({
el: '#app',
data() {
return {
zoom: 13,
center: [47.413220, -1.219482],
url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
contacts: [{
name: 'Contact1',
address: {
complete_address: '...',
position: [47.413220, -1.219482]
},
phone_number: '+49.....',
email: 'me@here.com'
},{
name: 'Contact2',
address: {
complete_address: '...',
position: [47.443220, -1.219482]
},
phone_number: '+49.....',
email: 'me@here.com'
}]
}
},
});