Skip to content

Instantly share code, notes, and snippets.

@huhn511
Created March 21, 2019 21:52
Show Gist options
  • Save huhn511/6c8d2d9348aca428761a457c307e2cda to your computer and use it in GitHub Desktop.
Save huhn511/6c8d2d9348aca428761a457c307e2cda to your computer and use it in GitHub Desktop.
<template>
<div>
<div class="info" style="height: 15%">
<span>Center: {{ center }}</span>
<span>Zoom: {{ zoom }}</span>
<span>Bounds: {{ bounds }}</span>
</div>
<l-map
style="height: 400px; width: 400px"
:zoom="zoom"
:center="center"
@update:zoom="zoomUpdated"
@update:center="centerUpdated"
@update:bounds="boundsUpdated"
>
<l-tile-layer :url="url"></l-tile-layer>
<l-marker :lat-lng="center"></l-marker>
</l-map>
</div>
</template>
<script>
const iotaAreaCodes = require('@iota/area-codes');
const iac = iotaAreaCodes.encode(52.529562, 13.413047);
console.log("IOTA Area Code", iac);
import {LMap, LTileLayer, LMarker} from 'vue2-leaflet'
export default {
components: { LMap, LTileLayer, LMarker },
data() {
return {
url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
zoom: 13,
center: [52.529562, 13.413047],
bounds: null
}
},
methods: {
zoomUpdated (zoom) {
this.zoom = zoom;
},
centerUpdated (center) {
this.center = center;
},
boundsUpdated (bounds) {
this.bounds = bounds;
}
}
}
</script>
import 'leaflet/dist/leaflet.css'
// fix icon for marker
import { Icon } from 'leaflet'
delete Icon.Default.prototype._getIconUrl;
Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment