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';
|
||||
|
||||
function init() {
|
||||
if (gm_error) { return gm_authFailure(); }
|
||||
google.maps.visualRefresh = true;
|
||||
polyOptions = {
|
||||
strokeColor: '#FF0000',
|
||||
@ -171,3 +172,11 @@ function zoomToBounds(b) {
|
||||
var bounds = new google.maps.LatLngBounds(sw, ne);
|
||||
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 altitudes = new Array();
|
||||
var altTimeout;
|
||||
var gm_error = false;
|
||||
|
||||
function displayChart() {
|
||||
if (chart) { google.visualization.events.removeAllListeners(chart); }
|
||||
var data = new google.visualization.DataTable();
|
||||
@ -370,7 +372,11 @@ function setTime() {
|
||||
var savedBounds;
|
||||
function loadMapAPI(api) {
|
||||
mapapi = api;
|
||||
try {
|
||||
savedBounds = getBounds();
|
||||
} catch (e) {
|
||||
savedBounds = null;
|
||||
}
|
||||
document.getElementById("map-canvas").innerHTML = '';
|
||||
var url = new Array();
|
||||
if (api == 'gmaps') {
|
||||
@ -411,8 +417,12 @@ function waitAndInit(api) {
|
||||
return;
|
||||
}
|
||||
loadTime = 0;
|
||||
var update = 1;
|
||||
if (savedBounds) {
|
||||
zoomToBounds(savedBounds);
|
||||
loadTrack(userid, trackid, 0);
|
||||
update = 0;
|
||||
}
|
||||
loadTrack(userid, trackid, update);
|
||||
// save current api as default
|
||||
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"][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["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"][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["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