diff --git a/app/assets/javascripts/index/layers/data.js b/app/assets/javascripts/index/layers/data.js index 0a996f0c70..7507a5f4e7 100644 --- a/app/assets/javascripts/index/layers/data.js +++ b/app/assets/javascripts/index/layers/data.js @@ -63,6 +63,17 @@ OSM.initializeDataLayer = function (map) { .click(add))); } + function displayLoadError(message) { + $("#browse_status").html( + $("
").append( + $("

") + .text(I18n.t("browse.start_rjs.load_data")), + $("
").append( + $("
").append( + $("

") + .text(I18n.t("browse.start_rjs.feature_error", { message: message })))))); + } + var dataLoader; function getData() { @@ -114,6 +125,18 @@ OSM.initializeDataLayer = function (map) { } dataLoader = null; + }, + error: function (XMLHttpRequest, textStatus) { + dataLoader = null; + if (textStatus === "abort") { return; } + + if (XMLHttpRequest.status === 400 && XMLHttpRequest.responseText) { + displayLoadError(XMLHttpRequest.responseText); + } else if (XMLHttpRequest.statusText) { + displayLoadError(XMLHttpRequest.statusText); + } else { + displayLoadError(String(XMLHttpRequest.status)); + } } }); } diff --git a/config/locales/en.yml b/config/locales/en.yml index da3afb2ee8..38b810d1f6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -392,6 +392,7 @@ en: relation: "relation" start_rjs: feature_warning: "Loading %{num_features} features, which may make your browser slow or unresponsive. Are you sure you want to display this data?" + feature_error: "Features could not be loaded: %{message}" load_data: "Load Data" loading: "Loading..." tag_details: