From c2270a860e7e583f1d1af1582eee947cf067f07b Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 18:50:38 +0100 Subject: [PATCH] Fix error message in geolocation --- .../CenterInMyPosition/CenterInMyPosition.js | 11 +++++++++++ public/locales/en/common.json | 4 +++- public/locales/es/common.json | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js index c143a23..3ee6020 100644 --- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js +++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js @@ -5,6 +5,7 @@ import { Tracker } from 'meteor/tracker'; import { ReactiveVar } from 'meteor/reactive-var'; import { Button } from 'react-bootstrap'; import { translate } from 'react-i18next'; +import { Bert } from 'meteor/themeteorchef:bert'; import './CenterInMyPosition.scss'; @@ -32,6 +33,16 @@ class CenterInMyPosition extends React.Component { // self.onViewportChanged(viewport); 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(); + } }); } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 909a0bb..d45b7ac 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -225,5 +225,7 @@ "Salir de pantalla completa": "Exit fullscreen mode", "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" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 6f2051f..5d3e5fa 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -312,5 +312,7 @@ "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", + "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" }