Comments (11)
Hi, @cm-cita !
VueLayers doesn't have some component based abstraction over OpenLayers controls now.
But it is possible to add any custom control, or whatever you want directly through OpenLayers API.
Each VueLayers component have public this.$...
property that references underlying OpenLayers object (vl-map
has $map ol.Map
https://github.com/ghettovoice/vuelayers/blob/master/src/component/map/map.vue#L412, vl-view
has $view ol.View
and etc), and two promises (https://github.com/ghettovoice/vuelayers/blob/master/src/mixin/ol-cmp.js#L197):
$createPromise
- resovles when underlying OpenLayers object created, $mountPromise
- resolves when OpenLayers object added to parent object. You can use this to add any OpenLayers related features:
<template>
<div>
<vl-map ref="map" :load-tiles-while-animating="true" :load-tiles-while-interacting="true">
<vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>
<vl-layer-tile id="osm">
<vl-source-osm></vl-source-osm>
</vl-layer-tile>
</vl-map>
</div>
</template>
<script>
export default {
data () {
return {
zoom: 2,
center: [0, 0],
rotation: 0,
}
},
mounted () {
// get vl-map by ref="map" and await ol.Map creation
this.$refs.map.$createPromise.then(() => {
this.$refs.map.$map.addControl(new ol.control.Sidebar({ element: 'sidebar', position: 'right' }))
...
})
},
}
</script>
Over time, I will describe this in the documentation.
from vuelayers.
A big thank you, for your fast reply, you are awesome!
from vuelayers.
I have still a problem with this. I use Vue with NUXT, can it be because of that?
I added the import VueLayers and Vue.use as plugin in NUXT.
Any idea?
from vuelayers.
Show me source of your index.vue file, please
from vuelayers.
Here is the source of the index.vue, plugin and nuxt config file:
http://content.lu/data/public/1ab4d6
from vuelayers.
Seems like archive is broken
$ unzip ~/Downloads/LiveMap.zip
Archive: /home/ghetto/Downloads/LiveMap.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
from vuelayers.
Ohh sorry, here once again:
from vuelayers.
Now it's ok. You forgot add ref
attribute to vl-map
tag in template. Try this :
<vl-map ref="map" :load-tiles-while-animating="true" :load-tiles-while-interacting="true" data-projection="EPSG:4326">
....
</vl-map>
from vuelayers.
Now I get the error "index.vue?1c37:73 Uncaught (in promise) ReferenceError: ol is not defined
at index.vue?1c37:73"
from vuelayers.
It's probably due to this line
var sidebar = this.$refs.map.$map.addControl(new ol.control.Sidebar({ element: 'sidebar', position: 'right' }));
This ol.control....
is undefined in current context.
Just for example, with OpenLayers additional controls
import EventList from '@/components/List/EventList'
import {findPointOnSurface, createStyle, loadingBBox} from 'vuelayers/lib/_esm/ol-ext'
// import from ol package
import ScaleLine from 'ol/control/scaleline'
export default {
components: {
EventList: EventList
},
mounted(){
// get vl-map by ref="map" and await ol.Map creation
this.$refs.map.$createPromise.then(() => {
this.$refs.map.$map.addControl(new ScaleLine());
})
},
data () {
return {
//controls: sidebar,
zoom: 11,
center: [6.15105, 49.60826],
loadTilesWhileInteracting: true,
clickCoordinate: undefined,
selectedFeatures: [],
baseLayers: [
{
name: 'osm',
title: 'OpenStreetMap',
visible: true,
},
{
name: 'bing-maps',
title: 'Bing Maps',
apiKey: 'ArbsA9NX-AZmebC6VyXAnDqjXk6mo2wGCmeYM8EwyDaxKfQhUYyk0jtx6hX5fpMn',
imagerySet: 'AerialWithLabels',
visible: false,
},
],
}
},
methods: {
//
},
layout: 'openlayers'
}
What about Sidebar plugin , as I can see here, it doesn't support any module system and requires global ol
variable, to use it you need an extra webpack setup (webpack imports loader can help). You need to provide ol.control.
global variable for this plugin.
Extensions from https://github.com/Viglino/ol-ext supports module systems, modern ol
package and can be easily used. https://unpkg.com/[email protected]/
from vuelayers.
I close, if you have another questions, open new one
from vuelayers.
Related Issues (20)
- Vuequery missing peer HOT 1
- Label Vector Fonts don't' have the right rendering [BUG] HOT 4
- Access feature in drawFinsihCondition? HOT 2
- When using vl-geom-line-string or vl-geom-multi-line-string the map tiles arent loaded correcty anymore. HOT 2
- Web browser freezes when trying to view the demo HOT 1
- Dependency conflict installing vuelayers with NPM HOT 2
- unmount maps HOT 2
- Demos not working in Webpack install HOT 6
- Add a scale bar?
- tilePrefix not added when working with GWC HOT 2
- style-box gone in v0.12 HOT 2
- TileJSON source HOT 2
- m
- Using filters for tile layers HOT 1
- Support for Openlayers 7 HOT 4
- error occurs when activating the tab which contains vuelayers HOT 1
- Change to tileSize in 0.12 HOT 4
- forEachFeatureAtPixel layerFilter not excute in right way HOT 3
- Validate draw
- vl-style-text problem
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuelayers.