|
|
@@ -33,6 +33,36 @@ function setupMap() {
|
|
|
|
|
|
function findResults(queryString, position, callback) {
|
|
|
|
|
|
+ function amendDetails(results) {
|
|
|
+ results.forEach(function (r) {
|
|
|
+ // icons
|
|
|
+ r.icon = 'fa-address-card';
|
|
|
+ if (r.type === 'restaurant') r.icon = 'fa-utensils';
|
|
|
+ if (r.type === 'doctors') r.icon = 'fa-user-md';
|
|
|
+ if (r.type === 'dentist') r.icon = 'fa-tooth';
|
|
|
+ if (r.type === 'car') r.icon = 'fa-car';
|
|
|
+ if (r.type === 'bicycle-rental') r.icon = 'fa-bicycle';
|
|
|
+ if (r.type === 'school') r.icon = 'fa-graduation-cap';
|
|
|
+ if (r.type === 'canal' || r.type === 'river' || r.type === 'water') r.icon = 'fa-water';
|
|
|
+ if (r.type === 'station' || r.type === 'stop') r.icon = 'fa-subway';
|
|
|
+ if (r.type === 'attraction') r.icon = 'fa-monument';
|
|
|
+ if (r.type === 'city' || r.type === 'village' || r.type === 'administrative') r.icon = 'fa-city';
|
|
|
+ if (r.type === 'administrative') r.icon = 'fa-building';
|
|
|
+ if (r.type === 'pub' || r.type === 'bar') r.icon = 'fa-beer';
|
|
|
+ if (r.type === 'hotel' || r.type === 'hostel') r.icon = 'fa-bed';
|
|
|
+
|
|
|
+ // ensure we have some city if only town is mentioned
|
|
|
+ if (!r.address.city) r.address.city = r.address.town;
|
|
|
+
|
|
|
+ // name
|
|
|
+ r.name = r.display_name.split(',')[0];
|
|
|
+ if (r.class === 'place' || r.class === 'building') r.name = r.address.road + ' ' + r.address.house_number;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+
|
|
|
function removeDuplicates(results) {
|
|
|
var tmp = [];
|
|
|
|
|
|
@@ -48,6 +78,7 @@ function findResults(queryString, position, callback) {
|
|
|
var params = {
|
|
|
format: 'json',
|
|
|
limit: 20,
|
|
|
+ addressdetails: 1,
|
|
|
q: (detail && queryString.indexOf(detail) === -1) ? (queryString + ' , ' + detail) : queryString
|
|
|
};
|
|
|
|
|
|
@@ -66,16 +97,16 @@ function findResults(queryString, position, callback) {
|
|
|
|
|
|
query(position.details.address.city + ' , ' + position.details.address.country, function (result) {
|
|
|
results = removeDuplicates(results.concat(result));
|
|
|
- if (results.length >= 20) return callback(results);
|
|
|
+ if (results.length >= 20) return callback(amendDetails(results));
|
|
|
|
|
|
query(position.details.address.country, function (result) {
|
|
|
results = removeDuplicates(results.concat(result));
|
|
|
- if (results.length >= 20) return callback(results);
|
|
|
+ if (results.length >= 20) return callback(amendDetails(results));
|
|
|
|
|
|
query(null, function (result) {
|
|
|
results = removeDuplicates(results.concat(result));
|
|
|
|
|
|
- return callback(results);
|
|
|
+ return callback(amendDetails(results));
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
@@ -163,5 +194,8 @@ app = new Vue({
|
|
|
created: function () {
|
|
|
setupMap();
|
|
|
this.getPositionDetails();
|
|
|
+ setTimeout(function () {
|
|
|
+ document.getElementById('querySearchInput').focus();
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
});
|