11 | <template> 12 | <ol-map> 13 | <ol-balloon :anchor="[60,110]"> 14 | <div class="blackballoon"> 15 | <p>If all you have is a hammer, everything looks like a fish. Oh wait.</p> 16 | </div> 17 | </ol-balloon> 18 | </ol-map> 19 | </template> 20 | <style> 21 | .blackballoon { 22 | background-color: black; 23 | color: white; 24 | padding: 1em 1em 1em 1em; 25 | width:100px; 26 | border-radius: 1.5em; 27 | } 28 | </style> 29 |30 |
Hello
7 |11 | <template> 12 | <ol-map :center="balloonpos" @moveend="moveballoon"> 13 | <ol-balloon :coords="balloonpos"> 14 | <div class="greenballoon"> 15 | <p>Hello</p> 16 | </div> 17 | </ol-balloon> 18 | </ol-map> 19 | </template> 20 | <script> 21 | module.exports = { 22 | name: "BalloonPositionChangeExample", 23 | data() { 24 | return { 25 | balloonpos: [-40.5092601, -2.8042712] 26 | }; 27 | }, 28 | methods: { 29 | moveballoon(evt, pos) { 30 | this.balloonpos = pos; 31 | } 32 | } 33 | }; 34 | </script> 35 | <style> 36 | .myballoon { 37 | background-color: #CAFEBA; 38 | padding: 1em 1em 1em 1em; 39 | border-radius: 1.5em; 40 | } 41 | </style> 42 |43 |
Maybe not
8 |Maybe you're there
13 |17 | <template> 18 | <ol-map> 19 | <ol-balloon> 20 | <div class="myballoon"> 21 | <h1>You Are Here</h1> 22 | <p>Maybe not</p> 23 | </div> 24 | </ol-balloon> 25 | <ol-balloon :coords="[-38.57921, -3.70522]"> 26 | <div class="myballoon"> 27 | <h1>You Are Here</h1> 28 | <p>Maybe not</p> 29 | </div> 30 | </ol-balloon> 31 | </ol-map> 32 | </template> 33 | <style> 34 | .myballoon { 35 | background-color: #EEEEEE; 36 | padding: 1em 1em 1em 1em; 37 | border-radius: 1.5em; 38 | } 39 | </style> 40 |41 |
5 | <template> 6 | <ol-map auto-center></ol-map> 7 | </template> 8 |9 |
5 | <template> 6 | <ol-map :center="[-38.7466364,-3.6199158]"></ol-map> 7 | </template> 8 |9 |
6 | <template> 7 | <div> 8 | <ol-map :center="curr" @moveend="showcenter"></ol-map> 9 | <button @click="move">Move it</button> { {curr}} 10 | </div> 11 | </template> 12 | <script> 13 | module.exports = { 14 | name: "MapChangeExample", 15 | data() { 16 | return { 17 | pos1: [-38.7466364, -3.6199158], 18 | pos2: [-38.5792122, -3.7052233], 19 | curr: [-38.5792122, -3.7052233] 20 | }; 21 | }, 22 | methods: { 23 | move() { 24 | if (this.curr[0] == this.pos1[0]) 25 | this.curr = this.pos2; 26 | else 27 | this.curr = this.pos1; 28 | }, 29 | showcenter(evt, pos) { 30 | this.curr = pos; 31 | } 32 | } 33 | } 34 | </script> 35 |36 |
6 | <template> 7 | <div> 8 | <ol-map :nodrag="candrag"></ol-map> 9 | <button @click="candrag = !candrag">push so you can <span v-show="!candrag">NOT</span> drag</button> 10 | </div> 11 | </template> 12 | <script> 13 | module.exports = { 14 | name:"MapNoDragExample", 15 | data(){ 16 | return { 17 | candrag:true 18 | }; 19 | } 20 | }; 21 | </script> 22 |23 |
8 | <template> 9 | <div> 10 | <ol-map :center="center" 11 | :zoom="zoom" 12 | @moveend="currentZoom"></ol-map> 13 | <label>Current zoom</label> <input type="range" min="1" max="20" v-model="zoom" /> { {zoom}} 14 | </div> 15 | </template> 16 | <script> 17 | module.exports = { 18 | name: "MapZoomExample", 19 | data() { 20 | return { 21 | center: [-38.9313415, -4.2642149], 22 | zoom: 14 23 | } 24 | }, 25 | methods: { 26 | currentZoom(evt, lonlat, zoom) { 27 | this.zoom = zoom; 28 | } 29 | } 30 | }; 31 | </script> 32 |33 |
8 | <template> 9 | <div> 10 | <ol-map :center="center" 11 | zoom="7" 12 | @moveend="currentZoom"></ol-map> 13 | <label>Current zoom</label> { {zoom}} 14 | </div> 15 | </template> 16 | <script> 17 | module.exports = { 18 | name: "MapZoomExample", 19 | data() { 20 | return { 21 | center: [-38.7466364, -3.6199158], 22 | zoom: "" 23 | } 24 | }, 25 | methods: { 26 | currentZoom(evt, lonlat, zoom) { 27 | this.zoom = zoom; 28 | } 29 | } 30 | }; 31 | </script> 32 |33 |
5 | <template> 6 | <ol-map></ol-map> 7 | </template> 8 |9 |
8 | <template> 9 | <div> 10 | <ol-map :center="lonlat" @moveend="move"> 11 | <ol-marker :coords="lonlat"></ol-marker> 12 | </ol-map> 13 | { {lonlat}} 14 | </div> 15 | </template> 16 | <script> 17 | module.exports = { 18 | name: "MarkerPosExample", 19 | data() { 20 | return { 21 | lonlat: [-40.900025, -3.823124] 22 | }; 23 | }, 24 | methods: { 25 | move(evt, pos) { 26 | this.lonlat = pos; 27 | } 28 | } 29 | }; 30 | </script> 31 |32 |
7 | <template> 8 | <ol-map> 9 | <ol-marker icon-image-url="./imgs/marker-blue.png"></ol-marker> 10 | </ol-map> 11 | </template> 12 |13 |
7 | <template> 8 | <ol-map :center="[-38.7307940,-3.8897860]"> 9 | <ol-marker :coords="[-38.7776903,-3.9584858]"></ol-marker> 10 | </ol-map> 11 | </template> 12 |13 |
13 | <template> 14 | <div> 15 | <ol-map :center="center" @selfeature="getmarker" zoom="7"> 16 | <ol-marker :coords="pos1" 17 | :icon-image-url="img1"></ol-marker> 18 | <ol-marker :coords="pos2" 19 | :icon-image-url="img2"></ol-marker> 20 | <ol-marker :coords="pos3" 21 | :icon-image-url="img3"></ol-marker> 22 | </ol-map> 23 | <label>Current Position: </label> { {selpos}} 24 | </div> 25 | </template> 26 | <script> 27 | module.exports = { 28 | name: "MarkerSelectionExample", 29 | data() { 30 | return { 31 | center: [-38.49036105926541, -4.20337354770561], 32 | img1: "./imgs/marker-red.png", 33 | img2: "./imgs/marker-green.png", 34 | img3: "./imgs/marker-blue.png", 35 | pos1: [-39.0249678539601, -4.971293155228395], 36 | pos2: [-38.526720707353626, -3.7341277429261197], 37 | pos3: [-37.766775791582134, -4.565608102361821], 38 | selpos: "" 39 | }; 40 | }, 41 | methods: { 42 | getmarker(marker) { 43 | this.selpos = marker.vueComponent.coords; 44 | }, 45 | updatecenter(evt, pos) { 46 | this.center = pos; 47 | } 48 | } 49 | } 50 | </script> 51 |52 |
7 | <template> 8 | <ol-map> 9 | <ol-marker></ol-marker> 10 | </ol-map> 11 | </template> 12 |13 |
7 | Simple wrapper for openlayers map toolkit 8 |
9 |10 | Please see This project 11 | for a maintained version. 12 |
13 |npm install vue-openlayers --save15 |
22 | // require the openlayers css on your project. 23 | require("../node_modules/openlayers/css/ol.css"); 24 | 25 | // require vue and any other shiny library 26 | const Vue = require('vue'); 27 | // ... 28 | // at some point require vue-openlayers 29 | const VueOpenLayers = require("vue-openlayers"); 30 | // ... 31 | // then install the plugin 32 | Vue.use(VueOpenLayers); 33 | // ... 34 | // now you can see the examples on how to use it on .vue components 35 |36 |
7 | This project aims a few goals and we'll log them there. Eventually the goals will appear as github issues as well. 8 |
9 |