ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
680 stars 227 forks source link

How to handle geolocation errors #372

Closed yyuri closed 3 years ago

yyuri commented 3 years ago

I'm having issues with timeouts when using geolocation and so I was looking to implement a simple exponential backoff algorithm to properly set the timeout value whenever this errors start to appear.

But I do not know how to handle or watch for this errors as there is no error event on vl-geoloc, how can I watch for this errors?

Thanks!

ghettovoice commented 3 years ago

I'm totally missed this event in v0.11.x and v0.12.x. I should definitely add them.

For a while you can subscribe through openlayers object:

<vl-geoloc @created="geolocCreated" />

export default {
  methods: {
    geolocCreated (vm) {
      vm.$geolocation.on('error', evt => console.log(evt))
    },
  },
}