Fix error message in geolocation

This commit is contained in:
vjrj 2018-02-27 18:50:38 +01:00
parent 5d216d81d4
commit c2270a860e
3 changed files with 17 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import { Tracker } from 'meteor/tracker';
import { ReactiveVar } from 'meteor/reactive-var'; import { ReactiveVar } from 'meteor/reactive-var';
import { Button } from 'react-bootstrap'; import { Button } from 'react-bootstrap';
import { translate } from 'react-i18next'; import { translate } from 'react-i18next';
import { Bert } from 'meteor/themeteorchef:bert';
import './CenterInMyPosition.scss'; import './CenterInMyPosition.scss';
@ -32,6 +33,16 @@ class CenterInMyPosition extends React.Component {
// self.onViewportChanged(viewport); // self.onViewportChanged(viewport);
computation.stop(); computation.stop();
} }
// https://developer.mozilla.org/en-US/docs/Web/API/PositionError)
const error = Geolocation.error();
if (error) {
const cod = error.code;
// window.alert(cod);
if (cod === 1) Bert.alert(self.props.t('geo-not-perms-error'), 'danger');
else if (cod === 2) Bert.alert(self.props.t('geo-not-avail-error'), 'danger');
else Bert.alert(error.message, 'danger');
computation.stop();
}
}); });
} }

View file

@ -225,5 +225,7 @@
"Salir de pantalla completa": "Salir de pantalla completa":
"Exit fullscreen mode", "Exit fullscreen mode",
"Escribe un lugar para centrar el mapa": "Escribe un lugar para centrar el mapa":
"Write a place to center the map" "Write a place to center the map",
"geo-not-perms-error": "Upppps: it seems we do not have permission to know your location",
"geo-not-avail-error": "Upppps: it seems your location is not available"
} }

View file

@ -312,5 +312,7 @@
"Salir de pantalla completa": "Salir de pantalla completa":
"Salir de pantalla completa", "Salir de pantalla completa",
"Escribe un lugar para centrar el mapa": "Escribe un lugar para centrar el mapa":
"Escribe un lugar para centrar el mapa" "Escribe un lugar para centrar el mapa",
"geo-not-perms-error": "Upppps: parece que no tenemos permiso para conocer tu ubicación",
"geo-not-avail-error": "Upppps: parece tu ubicación no está disponible"
} }