kopia lustrzana https://github.com/FacilMap/facilmap
Don't load URLs when finding route destination
rodzic
a95d0df14a
commit
0971e10de6
|
@ -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)
|
||||||
|
|
|
@ -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),
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue