Don't load URLs when finding route destination

pull/54/merge
Candid Dauth 2016-10-18 13:15:22 +03:00
rodzic a95d0df14a
commit 0971e10de6
3 zmienionych plików z 14 dodań i 12 usunięć

Wyświetl plik

@ -21,7 +21,7 @@
} }
map.loadStart(); map.loadStart();
map.socket.emit("find", { query: scope.searchString }, function(err, results) { map.socket.emit("find", { query: scope.searchString, loadUrls: true }, function(err, results) {
map.loadEnd(); map.loadEnd();
if(err) if(err)

Wyświetl plik

@ -53,7 +53,7 @@ var stateAbbr = {
} }
}; };
function find(query) { function find(query, loadUrls) {
return Promise.resolve().then(function() { return Promise.resolve().then(function() {
query = query.replace(/^\s+/, "").replace(/\s+$/, ""); query = query.replace(/^\s+/, "").replace(/\s+$/, "");
@ -70,6 +70,7 @@ function find(query) {
} ]; } ];
} }
if(loadUrls) {
var m = query.match(/^(node|way|relation)\s+(\d+)$/); var m = query.match(/^(node|way|relation)\s+(\d+)$/);
if(m) if(m)
return loadUrl("https://api.openstreetmap.org/api/0.6/" + m[1] + "/" + m[2] + (m[1] != "node" ? "/full" : ""), true); return loadUrl("https://api.openstreetmap.org/api/0.6/" + m[1] + "/" + m[2] + (m[1] != "node" ? "/full" : ""), true);
@ -80,6 +81,7 @@ function find(query) {
if(query.match(/^https?:\/\//)) if(query.match(/^https?:\/\//))
return loadUrl(query); return loadUrl(query);
}
return request({ return request({
url: nameFinderUrl + "?format=jsonv2&polygon_geojson=1&addressdetails=1&namedetails=1&limit=" + encodeURIComponent(limit) + "&extratags=1&q=" + encodeURIComponent(query), url: nameFinderUrl + "?format=jsonv2&polygon_geojson=1&addressdetails=1&namedetails=1&limit=" + encodeURIComponent(limit) + "&extratags=1&q=" + encodeURIComponent(query),

Wyświetl plik

@ -272,10 +272,10 @@ var appP = Promise.denodeify(app.listen.bind(app))(config.port, config.host).the
find: function(data) { find: function(data) {
return Promise.resolve().then(function() { return Promise.resolve().then(function() {
if(!utils.stripObject(data, { query: "string" })) if(!utils.stripObject(data, { query: "string", loadUrls: "boolean" }))
throw "Invalid parameters."; throw "Invalid parameters.";
return search.find(data.query); return search.find(data.query, data.loadUrls);
}); });
}, },