]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/query.js
Allow query mode to be turned off at low zoom
[rails.git] / app / assets / javascripts / index / query.js
index d0e9cc299e999058d9c4743aea95cba74f9adc36..99bb9d9c8abcf368875256a37b8f089395494060 100644 (file)
@@ -19,11 +19,9 @@ OSM.Query = function(map) {
     e.preventDefault();
     e.stopPropagation();
 
-    if (queryButton.hasClass("disabled")) return;
-
     if (queryButton.hasClass("active")) {
       disableQueryMode();
-    } else {
+    } else if (!queryButton.hasClass("disabled")) {
       enableQueryMode();
     }
   }).on("disabled", function (e) {
@@ -83,7 +81,7 @@ OSM.Query = function(map) {
     var tags = feature.tags;
     var prefix = "";
 
-    if (tags.boundary === "administrative") {
+    if (tags.boundary === "administrative" && tags.admin_level) {
       prefix = I18n.t("geocoder.search_osm_nominatim.admin_levels.level" + tags.admin_level)
     } else {
       var prefixes = I18n.t("geocoder.search_osm_nominatim.prefix");
@@ -112,7 +110,14 @@ OSM.Query = function(map) {
   }
 
   function featureName(feature) {
-    var tags = feature.tags;
+    var tags = feature.tags,
+      locales = I18n.locales.get();
+
+    for (var i = 0; i < locales.length; i++) {
+      if (tags["name:" + locales[i]]) {
+        return tags["name:" + locales[i]];
+      }
+    }
 
     if (tags["name"]) {
       return tags["name"];