Johannes Zellner 7 лет назад
Родитель
Сommit
b3f87fe36a
6 измененных файлов с 47 добавлено и 13 удалено
  1. 1 0
      .dockerignore
  2. 1 0
      .gitignore
  3. 6 0
      public/index.css
  4. 12 7
      public/index.html
  5. 1 1
      public/index.js
  6. 26 5
      src/places.js

+ 1 - 0
.dockerignore

@@ -2,4 +2,5 @@
 .gitignore
 .dockerignore
 node_modules
+opt/
 

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 node_modules/
+otp/

+ 6 - 0
public/index.css

@@ -132,3 +132,9 @@ html, body {
     height: 80px;
     cursor: pointer;
 }
+
+/* element ui patches */
+
+.el-carousel__item {
+    text-align: center;
+}

+ 12 - 7
public/index.html

@@ -33,7 +33,8 @@
       <div class="query-search-result-container-inner">
         <div v-for="item in querySearchResults" class="query-search-result-item" @click="searchSelectItem(item)">
           <h4><i class="fas" :class="[ item.icon ]"></i> {{ item.name }}</h4>
-          <p>{{ item.address.road }} {{ item.address.house_number }}, {{ item.address.city }} ({{ item.address.city_district }} {{ item.address.postcode }})</p>
+          <p v-if="item.class === 'city'">{{ item.address.postcode }} {{ item.address.country }}</p>
+          <p v-else>{{ item.address.road || item.address.pedestrian }} {{ item.address.house_number }}, {{ item.address.city || item.address.town || item.address.village }} ({{ item.address.city_district }} {{ item.address.postcode }} {{ item.address.country }})</p>
         </div>
       </div>
     </div>
@@ -43,29 +44,33 @@
           <i class="fas fa-arrow-left"></i> Back to search results
         </div>
         <div v-if="markerDetails.class === 'business'">
-          <h3>{{ markerDetails.name }} {{ markerDetails.businessDetails ? markerDetails.businessDetails.price : '' }}</h3>
+          <h3>{{ markerDetails.name }}</h3>
           <div v-if="markerDetails.businessDetails">
-            <el-carousel height="150px" type="card" :autoplay="false">
+            <el-carousel height="150px" :autoplay="false">
               <el-carousel-item v-for="photo in markerDetails.businessDetails.photos">
                 <img :src="photo" height="150px"/>
               </el-carousel-item>
             </el-carousel>
           </div>
           <p v-if="markerDetails.businessDetails"><el-rate v-model="markerDetails.businessDetails.rating" disabled></el-rate></p>
-          <p v-if="markerDetails.businessDetails">Phone: {{ markerDetails.businessDetails.display_phone }}</p>
+          <p v-if="markerDetails.businessDetails.price">Price: {{ markerDetails.businessDetails.price }}</p>
+          <p v-if="markerDetails.businessDetails.display_phone">Phone: {{ markerDetails.businessDetails.display_phone }}</p>
+          <p v-if="markerDetails.businessDetails.hours && markerDetails.businessDetails.hours.length">
+            <p v-if="typeof markerDetails.businessDetails.hours[0].is_open_now !== 'undefined'">Open Now: {{ markerDetails.businessDetails.hours[0].is_open_now ? 'yes' : 'no' }}</p>
+          </p>
         </div>
         <div v-if="markerDetails.class === ''">
           <h3>{{ markerDetails.name }}</h3>
           <p><a :href="markerDetails.businessDetails.url" target="_blank">Wikipedia</a></p>
           <img v-show="markerDetails.businessDetails.photo" :src="markerDetails.businessDetails.photo" style="max-height: 150px; max-width: 100%;"/>
-          <p>{{ markerDetails.businessDetails.summary }}</p>
+          <p style="text-align: justify;">{{ markerDetails.businessDetails.summary }}</p>
         </div>
       </div>
     </div>
   </div>
   <div id="map" class="map"></div>
-  <el-input placeholder="Search ..." v-model="querySearchString" id="querySearchInput" class="query-search-input" :class="{ 'open': sidePanelOpen }" @keyup.enter.native="doQuerySearch()"></el-input>
-  <el-input placeholder="Search ..." v-show="directionsOpen" v-model="querySearchStringTo" class="query-search-input second" :class="{ 'open': sidePanelOpen }" @keyup.enter.native="doQuerySearch()"></el-input>
+  <el-input placeholder="Search ..." v-model="querySearchString" id="querySearchInput" class="query-search-input" :class="{ 'open': sidePanelOpen }" @keyup.enter.native="searchPlaces()"></el-input>
+  <el-input placeholder="Search ..." v-show="directionsOpen" v-model="querySearchStringTo" class="query-search-input second" :class="{ 'open': sidePanelOpen }" @keyup.enter.native="searchPlaces()"></el-input>
   <el-button :class="{ 'open': sidePanelOpen, 'el-icon-arrow-left': sidePanelOpen, 'el-icon-arrow-right': !sidePanelOpen }" circle @click="sidePanelOpen = !sidePanelOpen" class="side-panel-toggle-button"></el-button>
 </el-container>
 

+ 1 - 1
public/index.js

@@ -112,7 +112,7 @@ app = new Vue({
             this.querySearchString = item.display_name;
             this.setSearchPositionMarker(item);
         },
-        doQuerySearch: function () {
+        searchPlaces: function () {
             var that = this;
 
             this.querySearchResults = [];

+ 26 - 5
src/places.js

@@ -27,6 +27,13 @@ function search(req, res, next) {
     const lon = req.query.lon;
 
     function translateSearchResultItems(results) {
+        var classCity = [
+            'city',
+            'town',
+            'village',
+            'hamlet'
+        ];
+
         var classBusiness = [
             'fast_food',
             'restaurant',
@@ -38,17 +45,27 @@ function search(req, res, next) {
             'retail'
         ];
 
-        return results.map(function (r) {
+        return results.filter(function (r) {
+            if (r.type === 'political') return false;
+            if (r.type === 'house') return false;
+            if (r.type === 'motorway_junction') return false;
+            if (r.class === 'boundary') return false;
+            return true;
+        }).map(function (r) {
             var tmp = {
                 icon: 'fa-address-card',
                 address: r.address,
                 lat: r.lat,
                 lon: r.lon,
                 type: r.type,
-                class: classBusiness.indexOf(r.type) !== -1 ? 'business' : '',
-                display_name: r.display_name
+                nativeClass: r.class,
+                class: '',
+                displayName: r.display_name
             };
 
+            if (classBusiness.indexOf(r.type) !== -1) tmp.class = 'business';
+            if (classCity.indexOf(r.type) !== -1) tmp.class = 'city';
+
             // icons
             if (r.type === 'fast_food' || r.type === 'restaurant') tmp.icon = 'fa-utensils';
             if (r.type === 'doctors') tmp.icon = 'fa-user-md';
@@ -62,13 +79,14 @@ function search(req, res, next) {
             if (r.type === 'school') tmp.icon = 'fa-graduation-cap';
             if (r.type === 'post_box' || r.type === 'post_office') tmp.icon = 'fa-envelope-square';
             if (r.type === 'canal' || r.type === 'river' || r.type === 'water') tmp.icon = 'fa-water';
-            if (r.type === 'station' || r.type === 'stop') tmp.icon = 'fa-subway';
+            if (r.type === 'station' || r.type === 'stop' || r.type === 'bus_stop') tmp.icon = 'fa-subway';
             if (r.type === 'attraction') tmp.icon = 'fa-monument';
-            if (r.type === 'city' || r.type === 'village' || r.type === 'administrative') tmp.icon = 'fa-city';
+            if (r.type === 'city' || r.type === 'village' || r.type === 'town' || r.type === 'hamlet') tmp.icon = 'fa-city';
             if (r.type === 'administrative' || r.class === 'office') tmp.icon = 'fa-building';
             if (r.type === 'pub' || r.type === 'bar') tmp.icon = 'fa-beer';
             if (r.type === 'hotel' || r.type === 'hostel') tmp.icon = 'fa-bed';
             if (r.type === 'supermarket' || r.type === 'retail') tmp.icon = 'fa-shopping-cart';
+            if (r.class === 'highway') tmp.icon = 'fa-road';
 
             // ensure we have some city if only town is mentioned
             if (!tmp.address.city) tmp.address.city = tmp.address.town;
@@ -77,6 +95,9 @@ function search(req, res, next) {
             tmp.name = r.display_name.split(',')[0];
             if (r.class === 'place' || r.class === 'building') tmp.name = r.address.road + ' ' + r.address.house_number;
             if (r.type === 'city') tmp.name = r.address.city;
+            if (r.type === 'town') tmp.name = r.address.town;
+            if (r.type === 'village') tmp.name = r.address.village;
+            if (r.type === 'hamlet') tmp.name = r.address.hamlet;
 
             // fallback to display name
             if (!tmp.name) tmp.name = r.display_name;