-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.vue
60 lines (58 loc) · 1.33 KB
/
example.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<template>
<div style="height: 100%; width: 100%">
<l-map
style="height: 400px"
:center="mapCentre"
:zoom="mapZoom"
@fullscreenchange="fullscreenChanged"
ref="map"
>
<l-tile-layer
:url="tileUrl"
:attribution="tileAttribution"
/>
<l-control-fullscreen
position="topleft"
:options="fullscreenOptions"
/>
</l-map>
</div>
</template>
<script>
import L from 'leaflet';
import { LMap, LTileLayer } from 'vue2-leaflet';
import LControlFullscreen from './LControlFullscreen.vue';
export default {
components: {
LMap,
LTileLayer,
LControlFullscreen,
},
data () {
return {
mapCentre: [51, -114],
mapZoom: 10,
tileUrl: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
tileAttribution: '© <a href="//osm.org/copyright">OpenStreetMap</a> contributors',
fullscreenOptions: {
title: {
'false': 'Switch to full-screen view',
'true': 'Exit full-screen mode',
},
},
};
},
methods: {
fullscreenChanged () {
if (this.$refs.map.mapObject.isFullscreen()) {
console.log('Entered full-screen mode');
} else {
console.log('Left full-screen mode');
}
},
}
};
</script>
<style>
@import '~leaflet/dist/leaflet.css';
</style>