-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access the internal ol.Map instance? #220
Comments
Hello @frankhommers! So for your use case, you should listen for <template>
<vl-map @created="mapCreated">
...
</vl-map>
</template>
<script>
export default {
...
methods: {
/**
* @param vm vl-map component instance
*/
mapCreated (vm) {
console.log(vm) // vl-map instance
console.log(vm.$map) // ol.Map instance
},
},
}
</script> Another method is based on the using of the <template>
<vl-map ref="map">
...
</vl-map>
</template>
<script>
export default {
...
mounted () {
this.$refs.map.$createPromise.then(vm => {
console.log(vm) // vl-map instance
console.log(vm.$map) // ol.Map instance
})
},
}
</script> You can use this methods to get openlayers instance from any component.
|
Thanks for the answers! I will check them (or a colleague) tomorrow ;-) |
Yes this works! Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
In #95 you mention the accessing of the ol.Map instance directly. I want to do this, but I am not sure how? Can you point me in the right direction? Or preferrably give an example?
The text was updated successfully, but these errors were encountered: