Icon roatation
by Vladimir Vershinin
HTML
<script src="https://unpkg.com/vue@latest/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vuelayers.umd.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/vuelayers.css">
<div id="app">
<vl-map ref="map" data-projection="EPSG:4326">
<vl-view ref="view" :zoom.sync="zoom" :center.center="center"></vl-view>
<vl-layer-tile>
<vl-source-osm></vl-source-osm>
</vl-layer-tile>
<vl-layer-vector ref="layer" :z-index="1">
<vl-source-vector ref="source">
<vl-feature>
<vl-geom-point :coordinates="[10, 10]"></vl-geom-point>
<vl-style-box>
<vl-style-icon :src="markerUrl" :scale="0.1" :anchor="[0.5, 1]"></vl-style-icon>
</vl-style-box>
<vl-style-box>
<vl-style-circle :radius="5">
<vl-style-stroke :width="1" color="green"></vl-style-stroke>
</vl-style-circle>
</vl-style-box>
</vl-feature>
<vl-feature ref="feature">
<vl-geom-point :coordinates="[-10, -10]"></vl-geom-point>
<vl-style-box>
<vl-style-icon :src="markerUrl" :scale="0.1" :anchor="[0.5, 1]" :rotate-with-view="true"></vl-style-icon>
</vl-style-box>
<vl-style-box>
<vl-style-circle :radius="5">
<vl-style-stroke :width="1" color="green"></vl-style-stroke>
</vl-style-circle>
</vl-style-box>
</vl-feature>
</vl-source-vector>
</vl-layer-vector>
</vl-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
new Vue({
el: '#app',
data() {
return {
zoom: 2,
center: [0, 0],
markerUrl: 'https://cdn0.iconfinder.com/data/icons/small-n-flat/24/678111-map-marker-512.png',
}
},
})