X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/501d13e1c0936cc3ba3d9639620517bae34e5784..9b26dc79c64fd4fde23e03ce15591d22bac3cd98:/app/assets/javascripts/index/query.js?ds=sidebyside diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index e2c8699ff..180e203d5 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -71,11 +71,6 @@ OSM.Query = function(map) { function interestingFeature(feature, origin, radius) { if (feature.tags) { - if (feature.type === "node" && - OSM.distance(origin, L.latLng(feature.lat, feature.lon)) > radius) { - return false; - } - for (var key in feature.tags) { if (uninterestingTags.indexOf(key) < 0) { return true; @@ -134,27 +129,21 @@ OSM.Query = function(map) { } } - function featureGeometry(feature, features) { + function featureGeometry(feature) { var geometry; - if (feature.type === "node") { + if (feature.type === "node" && feature.lat && feature.lon) { geometry = L.circleMarker([feature.lat, feature.lon], featureStyle); - } else if (feature.type === "way") { - geometry = L.polyline(feature.nodes.map(function (node) { - return features["node" + node].getLatLng(); + } else if (feature.type === "way" && feature.geometry) { + geometry = L.polyline(feature.geometry.filter(function (point) { + return point !== null; + }).map(function (point) { + return [point.lat, point.lon]; }), featureStyle); - } else if (feature.type === "relation") { - geometry = L.featureGroup(); - - feature.members.forEach(function (member) { - if (features[member.type + member.ref]) { - geometry.addLayer(features[member.type + member.ref]); - } - }); - } - - if (geometry) { - features[feature.type + feature.id] = geometry; + } else if (feature.type === "relation" && feature.members) { + geometry = L.featureGroup(feature.members.map(featureGeometry).filter(function (geometry) { + return geometry !== undefined; + })); } return geometry; @@ -181,18 +170,15 @@ OSM.Query = function(map) { data: "[timeout:5][out:json];" + query, }, success: function(results) { - var features = {}; - $section.find(".loader").stopTime("loading").hide(); for (var i = 0; i < results.elements.length; i++) { - var element = results.elements[i], - geometry = featureGeometry(element, features); + var element = results.elements[i]; if (interestingFeature(element, latlng, radius)) { var $li = $("
")
.text(featurePrefix(element) + " ")
@@ -227,7 +213,6 @@ OSM.Query = function(map) {
*
* node(around: