Sfoglia il codice sorgente

Make it more responsive

Johannes Zellner 7 anni fa
parent
commit
8b34d3debb
3 ha cambiato i file con 62 aggiunte e 12 eliminazioni
  1. 24 2
      public/index.css
  2. 3 5
      public/index.html
  3. 35 5
      public/index.js

+ 24 - 2
public/index.css

@@ -49,8 +49,16 @@ html, body {
     width: 390px;
 }
 
-.query-search-input.second {
-    top: 60px;
+
+@media all and (max-width: 768px) {
+    .query-search-input {
+        width: 100%;
+        left: 0;
+    }
+
+    .query-search-input.open {
+        width: 80%;
+    }
 }
 
 .query-search-input-placeholder {
@@ -126,6 +134,13 @@ html, body {
     width: 470px;
 }
 
+@media all and (max-width: 768px) {
+    .side-panel.open {
+        width: 100%;
+    }
+}
+
+
 .side-panel-toggle-button {
     position: fixed;
     left: 5px;
@@ -150,3 +165,10 @@ html, body {
 .el-carousel__item {
     text-align: center;
 }
+
+.whats-here {
+    background-size: cover;
+    background-repeat: no-repeat;
+    width: 128px;
+    height: 128px;
+}

+ 3 - 5
public/index.html

@@ -25,9 +25,9 @@
 <div id="app">
   <div id="map" class="map"></div>
   <div class="side-panel map-overlay" :class="{ 'open': sidePanelOpen }">
-    <div class="query-search-input-placeholder" :class="{ 'second': directionsOpen }">
-      <el-tooltip class="item" effect="dark" content="Directions" placement="bottom-start">
-        <el-button type="primary" icon="el-icon-share" @click="directionsOpen = !directionsOpen"></el-button>
+    <div class="query-search-input-placeholder">
+      <el-tooltip class="item" effect="dark" content="Close" placement="bottom-start">
+        <el-button type="primary" icon="el-icon-close" @click="sidePanelOpen = !sidePanelOpen"></el-button>
       </el-tooltip>
     </div>
     <div :class="{ 'open': !markerDetailsOpen }" class="query-search-result-container">
@@ -72,8 +72,6 @@
     </div>
   </div>
   <el-input placeholder="Search ..." v-model="querySearchString" id="querySearchInput" class="query-search-input map-overlay" :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 map-overlay"></el-button>
 </div>
 
 <script src='index.js'></script>

+ 35 - 5
public/index.js

@@ -7,10 +7,10 @@ var DEFAULT_MARKER_ICON = L.icon({
 });
 
 function setupMap() {
-    map = new L.map('map', { zoomControl: false });
-    map.setView([ 52.520008, 13.404954 ], 18);
+    map = new L.map('map', { zoomControl: false, attributionControl: false });
+    map.setView([ 52.520008, 13.404954 ], 20);
     L.control.scale({ position: 'bottomright', imperial: false }).addTo(map);
-    L.control.zoom({ position: 'topright' }).addTo(map);
+    // L.control.zoom({ position: 'topright' }).addTo(map);
 
     L.tileLayer('https://api.mapbox.com/styles/v1/nebulon/{id}/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoibmVidWxvbiIsImEiOiI3NmNkODc5ZDMyNjcxMWM2M2UyODEyMjdkM2YyMjVlOSJ9.Cpz0-WRwBwE-DNdNfGDu_w', {
         attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
@@ -42,15 +42,44 @@ function setupMap() {
 
         history.replaceState({}, window.document.title, u);
     });
+
+    var mapillaryKey = 'SmRiZXFSN3RJYVpKdGd2V3BQZ0dMdzoxZjY3YjA3MmU2OWU2ODll';
+
+    map.on('contextmenu ', function (event) {
+        console.log(event);
+
+        var popup = L.popup({ closeButton: false })
+            .setLatLng(event.latlng)
+            .setContent('<p>Loading address</p>')
+            .openOn(map);
+
+        var params = {
+            client_id: mapillaryKey,
+            closeto: event.latlng.lng + ',' + event.latlng.lat,
+            pano: false
+        };
+
+        axios.get('https://a.mapillary.com/v3/images', {
+            params: params
+        }).then(function (response) {
+            // console.log(response.data);
+            if (response.data.features.length === 0) {
+                popup.setContent('<p>Nothing found</p>');
+            } else {
+                popup.setContent('<div class="whats-here" style="background-image: url(https://d1cuyjsrcm0gby.cloudfront.net/' + response.data.features[0].properties.key + '/thumb-640.jpg"></div>');
+            }
+        }).catch(function (error) {
+            console.error(error);
+        });
+    });
+
 }
 
 app = new Vue({
     el: '#app',
     data: {
         sidePanelOpen: false,
-        directionsOpen: false,
         querySearchString: '',
-        querySearchStringTo: '',
         querySearchResults: [],
         searchMarker: {},
         markerDetailsOpen: false,
@@ -72,6 +101,7 @@ app = new Vue({
             axios.get('/api/places/details', {
                 params: params
             }).then(function (response) {
+                that.sidePanelOpen = true;
                 that.markerDetailsOpen = true;
                 that.markerDetails = item;
                 that.markerDetails.businessDetails = response.data;