Projections v0.12
by Vladimir Vershinin
HTML
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.4.3/build/ol.js"></script>
<script src="https://unpkg.com/[email protected]/dist/proj4.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/vuelayers.css">
<script src="https://unpkg.com/[email protected]/dist/vuelayers.umd.js"></script>
<div id="app">
<my-map :features="features"></my-map>
</div>
CSS
html, body, #app {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#app {
display: flex;
flex-direction: column;
}
.vl-map {
overflow: hidden;
}
JavaScript
proj4.defs('EPSG:25832', '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs')
ol.proj.proj4.register(proj4)
const MyMap = Vue.component('my-map', {
props: {
features: {
type: Array,
required: true
}
},
data() {
return {
center: [598703.7995171356, 6225813.035968694],
zoom: 3,
};
},
template: `<vl-map data-projection="EPSG:25832">
<vl-view :zoom.sync="zoom" :center.sync="center" projection="EPSG:25832"></vl-view>
<vl-layer-tile>
<vl-source-osm></vl-source-osm>
</vl-layer-tile>
<vl-layer-vector>
<vl-source-vector :features="features" projection="EPSG:4326"></vl-source-vector>
</vl-layer-vector>
</vl-map>`
});
new Vue({
el: '#app',
components: {
MyMap
},
data() {
return {
features: []
}
},
mounted() {
this.features = [{
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[8.41552734375, 56.41390137600676],
[8.173828125, 55.4040698270061],
[10.04150390625, 55.02802211299252],
[10.87646484375, 55.85064987433714],
[9.33837890625, 55.801280971180454],
[9.64599609375, 56.401744392758964],
[11.2939453125, 56.389583525613055],
[11.44775390625, 55.7765730186677],
[12.041015625, 56.401744392758964],
[11.557617187499998, 56.728621973140726],
[9.16259765625, 56.80087831233043],
[8.41552734375, 56.41390137600676]
]
]
}
}, {
type: 'Feature',
properties: {},
geometry: {
type: 'Polygon',
coordinates: [
[
[9.9371337890625, 56.258608725706935],
[9.931640625, 55.979945357882315],
[10.4864501953125, 55.979945357882315],
[10.546875, 56.14860953861174],
...