X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/6e154d48c0e77ea110fc93772c6a2be113a90bb1..eb7678145a87c1b9e3cd7ff2d3b5dc08132e4b51:/app/assets/javascripts/index/query.js diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 86f24e046..407e088e5 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -1,10 +1,9 @@ //= require jquery.simulate OSM.Query = function(map) { - var protocol = document.location.protocol === "https:" ? "https:" : "http:", - url = protocol + OSM.OVERPASS_URL, + var url = OSM.OVERPASS_URL, queryButton = $(".control-query .control-button"), - uninterestingTags = ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid', 'KSJ2:curve_id', 'KSJ2:lat', 'KSJ2:lon', 'KSJ2:coordinate', 'KSJ2:filename', 'note:ja'], + uninterestingTags = ["source", "source_ref", "source:ref", "history", "attribution", "created_by", "tiger:county", "tiger:tlid", "tiger:upload_uuid", "KSJ2:curve_id", "KSJ2:lat", "KSJ2:lon", "KSJ2:coordinate", "KSJ2:filename", "note:ja"], marker; var featureStyle = { @@ -12,7 +11,7 @@ OSM.Query = function(map) { weight: 4, opacity: 1, fillOpacity: 0.5, - clickable: false + interactive: false }; queryButton.on("click", function (e) { @@ -56,7 +55,7 @@ OSM.Query = function(map) { var geometry = $(this).data("geometry"); if (geometry) map.removeLayer(geometry); - if (!$(e.target).is('a')) { + if (!$(e.target).is("a")) { $(this).find("a").simulate("click", e); } } @@ -146,7 +145,7 @@ OSM.Query = function(map) { if (feature.type === "node" && feature.lat && feature.lon) { geometry = L.circleMarker([feature.lat, feature.lon], featureStyle); - } else if (feature.type === "way" && feature.geometry) { + } else if (feature.type === "way" && feature.geometry && feature.geometry.length > 0) { geometry = L.polyline(feature.geometry.filter(function (point) { return point !== null; }).map(function (point) { @@ -179,7 +178,7 @@ OSM.Query = function(map) { url: url, method: "POST", data: { - data: "[timeout:5][out:json];" + query, + data: "[timeout:10][out:json];" + query, }, success: function(results) { var elements; @@ -226,6 +225,12 @@ OSM.Query = function(map) { } } + if (results.remark) { + $("
  • ") + .text(I18n.t("javascripts.query.error", { server: url, error: results.remark })) + .appendTo($ul); + } + if ($ul.find("li").length === 0) { $("
  • ") .text(I18n.t("javascripts.query.nothing_found")) @@ -282,7 +287,7 @@ OSM.Query = function(map) { nodes = "node(" + around + ")", ways = "way(" + around + ")", relations = "relation(" + around + ")", - nearby = "(" + nodes + ";" + ways + ");out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");", + nearby = "(" + nodes + ";" + ways + ";);out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");", isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids geom(" + bbox + ");relation(pivot.a);out tags bb;"; $("#sidebar_content .query-intro") @@ -337,7 +342,7 @@ OSM.Query = function(map) { }; page.load = function(path, noCentre) { - var params = querystring.parse(path.substring(path.indexOf('?') + 1)), + var params = querystring.parse(path.substring(path.indexOf("?") + 1)), latlng = L.latLng(params.lat, params.lon); if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {