Handle google maps authentication errors (fixes #16)
This commit is contained in:
parent
bdca8ad241
commit
34e93aed6c
@ -26,6 +26,7 @@ var mapOptions;
|
|||||||
var loadedAPI = 'gmaps';
|
var loadedAPI = 'gmaps';
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
if (gm_error) { return gm_authFailure(); }
|
||||||
google.maps.visualRefresh = true;
|
google.maps.visualRefresh = true;
|
||||||
polyOptions = {
|
polyOptions = {
|
||||||
strokeColor: '#FF0000',
|
strokeColor: '#FF0000',
|
||||||
@ -171,3 +172,11 @@ function zoomToBounds(b) {
|
|||||||
var bounds = new google.maps.LatLngBounds(sw, ne);
|
var bounds = new google.maps.LatLngBounds(sw, ne);
|
||||||
map.fitBounds(bounds);
|
map.fitBounds(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gm_authFailure() {
|
||||||
|
gm_error = true;
|
||||||
|
message = sprintf(lang['apifailure'], "Google Maps");
|
||||||
|
message += '<br><br>' + lang['gmauthfailure'];
|
||||||
|
message += '<br><br>' + lang['gmapilink'];
|
||||||
|
showModal(message);
|
||||||
|
};
|
||||||
|
12
js/main.js
12
js/main.js
@ -39,6 +39,8 @@ var live = 0;
|
|||||||
var chart;
|
var chart;
|
||||||
var altitudes = new Array();
|
var altitudes = new Array();
|
||||||
var altTimeout;
|
var altTimeout;
|
||||||
|
var gm_error = false;
|
||||||
|
|
||||||
function displayChart() {
|
function displayChart() {
|
||||||
if (chart) { google.visualization.events.removeAllListeners(chart); }
|
if (chart) { google.visualization.events.removeAllListeners(chart); }
|
||||||
var data = new google.visualization.DataTable();
|
var data = new google.visualization.DataTable();
|
||||||
@ -370,7 +372,11 @@ function setTime() {
|
|||||||
var savedBounds;
|
var savedBounds;
|
||||||
function loadMapAPI(api) {
|
function loadMapAPI(api) {
|
||||||
mapapi = api;
|
mapapi = api;
|
||||||
|
try {
|
||||||
savedBounds = getBounds();
|
savedBounds = getBounds();
|
||||||
|
} catch (e) {
|
||||||
|
savedBounds = null;
|
||||||
|
}
|
||||||
document.getElementById("map-canvas").innerHTML = '';
|
document.getElementById("map-canvas").innerHTML = '';
|
||||||
var url = new Array();
|
var url = new Array();
|
||||||
if (api == 'gmaps') {
|
if (api == 'gmaps') {
|
||||||
@ -411,8 +417,12 @@ function waitAndInit(api) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loadTime = 0;
|
loadTime = 0;
|
||||||
|
var update = 1;
|
||||||
|
if (savedBounds) {
|
||||||
zoomToBounds(savedBounds);
|
zoomToBounds(savedBounds);
|
||||||
loadTrack(userid, trackid, 0);
|
update = 0;
|
||||||
|
}
|
||||||
|
loadTrack(userid, trackid, update);
|
||||||
// save current api as default
|
// save current api as default
|
||||||
setCookie('api', api, 30);
|
setCookie('api', api, 30);
|
||||||
}
|
}
|
||||||
|
@ -112,5 +112,7 @@ $lang["passrules"][1] = "It should contain at least one lower case letter, one u
|
|||||||
$lang["passrules"][2] = "It should contain at least one lower case letter, one upper case letter and one digit";
|
$lang["passrules"][2] = "It should contain at least one lower case letter, one upper case letter and one digit";
|
||||||
$lang["passrules"][3] = "It should contain at least one lower case letter, one upper case letter, one digit and one non-alphanumeric character";
|
$lang["passrules"][3] = "It should contain at least one lower case letter, one upper case letter, one digit and one non-alphanumeric character";
|
||||||
$lang["owntrackswarn"] = "Your can only edit your own tracks";
|
$lang["owntrackswarn"] = "Your can only edit your own tracks";
|
||||||
|
$lang["gmauthfailure"] = "There may be problem with Google Maps API key on this page";
|
||||||
|
$lang["gmapilink"] = "You may find more information about API keys on <a target=\"_blank\" href=\"https://developers.google.com/maps/documentation/javascript/get-api-key\">this Google webpage</a>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -107,5 +107,7 @@ $lang["passrules"][1] = "Powinno ono zawierać przynajmniej jedną małą i jedn
|
|||||||
$lang["passrules"][2] = "Powinno ono zawierać przynajmniej jedną małą, jedną wielką literę i jedną cyfrę";
|
$lang["passrules"][2] = "Powinno ono zawierać przynajmniej jedną małą, jedną wielką literę i jedną cyfrę";
|
||||||
$lang["passrules"][3] = "Powinno ono zawierać przynajmniej jedną małą, jedną wielką literę, jedną cyfrę i jeden znak specjalny (nie alfanumeryczny)";
|
$lang["passrules"][3] = "Powinno ono zawierać przynajmniej jedną małą, jedną wielką literę, jedną cyfrę i jeden znak specjalny (nie alfanumeryczny)";
|
||||||
$lang["owntrackswarn"] = "Możesz edytować tylko swoje własne trasy";
|
$lang["owntrackswarn"] = "Możesz edytować tylko swoje własne trasy";
|
||||||
|
$lang["gmauthfailure"] = "Prawdopodobnie na tej stronie występuje problem z kluczem API Google Maps";
|
||||||
|
$lang["gmapilink"] = "Więcej informacji o kluczach API znajdziesz <a target=\"_blank\" href=\"https://developers.google.com/maps/documentation/javascript/get-api-key\">pod tym linkiem</a>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user