소스 검색

Add custom pins

Johannes Zellner 8 년 전
부모
커밋
121e152550
6개의 변경된 파일과 246개의 추가작업 그리고 40개의 파일을 삭제
  1. 1 1
      Dockerfile
  2. 85 9
      index.css
  3. 24 23
      index.html
  4. 34 7
      index.js
  5. 51 0
      pin.svg
  6. 51 0
      pinsmile.svg

+ 1 - 1
Dockerfile

@@ -6,6 +6,6 @@ WORKDIR /app/code
 RUN npm install -g serve
 
 ADD 3rdparty/ /app/code/3rdparty/
-ADD start.sh index.css index.html index.js /app/code/
+ADD start.sh index.css index.html index.js pin.svg logo.png /app/code/
 
 CMD [ "/app/code/start.sh" ]

+ 85 - 9
index.css

@@ -1,27 +1,103 @@
 html, body { margin:0; padding:0; width: 100%; height: 100% }
 
-#map {
-    position: absolute;
-    bottom: 0;
-    top: 0;
+.map {
+    height: 100vh;
     width: 100%;
-    height: 100%
 }
 
 .container {
+    display: flex;
     border: 1px solid rgba(0,0,0,0.15);
     box-shadow: 0 2px 3px rgba(0,0,0,0.06);
     border-radius: 3px;
     background: white;
 }
 
-.search {
+.query-search-input {
     position: absolute;
-    top: 20px;
-    left: 20px;
-    width: 400px;
+    top: 10px;
+    left: 10px;
+    width: 450px;
+    transition: all 0.25s cubic-bezier(.65,.05,.36,1);
+}
+
+.query-search-input.open {
+    left: 60px;
+    width: 390px;
+}
+
+.query-search-input.second {
+    top: 60px;
+}
+
+.query-search-input-placeholder {
+    height: 60px;
+    line-height: 60px;
+    background-color: #409EFF;
+    transition: all 0.25s cubic-bezier(.65,.05,.36,1);
+}
+
+.query-search-input-placeholder.second {
+    height: 110px;
+}
+
+.query-search-result-container {
+    overflow: auto;
+    background: white;
+    padding-top: 10px;
+    flex-basis: 0;
+    transition: all 0.25s cubic-bezier(.65,.05,.36,1);
+}
+
+.query-search-result-container.open {
+    flex-basis: 100%;
+}
+
+.query-search-result-item {
+    cursor: pointer;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    padding: 5px 10px;
+}
+
+.query-search-result-item:hover {
+    background: #E7E7E7;
 }
 
 .search-input {
     width: 100%;
+}
+
+.side-panel {
+    display: flex;
+    flex-direction: column;
+    color: #333;
+    transition: all 0.25s cubic-bezier(.65,.05,.36,1);
+    width: 0;
+    height: 100vh;
+    overflow: hidden;
+}
+
+.side-panel.open {
+    width: 700px;
+}
+
+.side-panel-toggle-button {
+    position: fixed;
+    left: 5px;
+    top: 50vh;
+    transition: all 0.25s cubic-bezier(.65,.05,.36,1);
+}
+
+.side-panel-toggle-button.open {
+    left: 475px;
+}
+
+.search-result-marker {
+    background-image: url('pin.svg');
+    background-size: cover;
+    width: 80px;
+    height: 80px;
+    cursor: pointer;
 }

+ 24 - 23
index.html

@@ -5,6 +5,8 @@
   <title>Cloudron Map</title>
   <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
+  <link rel="icon" type="image/png" href="logo.png"/>
+
   <script src="/3rdparty/vue.js"></script>
   <script src="/3rdparty/axios.min.js"></script>
   <script src="/3rdparty/mapbox/mapbox-gl.js"></script>
@@ -18,30 +20,29 @@
 </head>
 <body>
 
-<div id='map'></div>
-
-<div id="app">
-  <el-container class="search">
-    <!-- <el-input placeholder="Search ..." v-model="search" clearable @keyup.enter.native="searchNow()">
-        <el-button type="primary" slot="append" icon="el-icon-search" @click="searchNow()"></el-button>
-    </el-input> -->
-
-    <el-autocomplete class="search-input" v-model="search" placeholder="Search ..." :trigger-on-focus="false" :fetch-suggestions="searchNow" @select="searchSelectItem" clearable>
-      <template slot-scope="{ item }">
-        <div class="value">{{ item.display_name }}</div>
-      </template>
-    </el-autocomplete>
-  </el-container>
-
-  <!-- <div class="search container">
-    <input type="text" id="search" v-model="search" placeholder="Search..." @keyup.enter="searchNow" @focus="searchFocus()" @keyup.escape="showResults = false">
-  </div> -->
-  <!-- <div id="results"class="container" v-show="showResults">
-    <div v-for="result in searchResults" class="search-result" @click="searchFocus(result)">
-      {{ result.display_name }}
+<el-container id="app">
+  <div class="side-panel" :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>
+      </el-tooltip>
+    </div>
+    <div :class="{ 'open': !markerDetailsOpen }" class="query-search-result-container">
+      <div v-for="item in querySearchResults" class="query-search-result-item" @click="searchSelectItem(item)">{{ item.display_name }}</div>
+    </div>
+    <div :class="{ 'open': markerDetailsOpen }" class="query-search-result-container">
+      <el-button icon="el-icon-close" circle @click="markerDetailsOpen = false;"></el-button>
+      <div>
+          <h2>Details</h2>
+          <p>{{ markerDetails.display_name }}</p>
+      </div>
     </div>
-  </div> -->
-</div>
+  </div>
+  <div id="map" class="map"></div>
+  <el-input placeholder="Search ..." v-model="querySearchString" 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-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>
 
 <script src='index.js'></script>
 

+ 34 - 7
index.js

@@ -19,7 +19,7 @@ function setupMap() {
 
         const locationControl = new mapboxgl.GeolocateControl({
             positionOptions: {
-            enableHighAccuracy: true
+                enableHighAccuracy: true
             },
             trackUserLocation: true
         });
@@ -73,9 +73,15 @@ function findResults(queryString, position, callback) {
 app = new Vue({
     el: '#app',
     data: {
+        sidePanelOpen: false,
+        directionsOpen: false,
         position: null,
-        search: '',
-        searchPositionMarker: null
+        querySearchString: '',
+        querySearchStringTo: '',
+        querySearchResults: [],
+        searchPositionMarker: null,
+        markerDetailsOpen: false,
+        markerDetails: {}
     },
     methods: {
         getPositionDetails: function () {
@@ -103,21 +109,42 @@ app = new Vue({
                 });
             });
         },
+        searchMarkerClicked: function (item) {
+            this.markerDetailsOpen = true;
+            this.markerDetails = item;
+        },
         setSearchPositionMarker: function (item) {
+            var that = this;
+
             if (this.searchPositionMarker) this.searchPositionMarker.remove();
 
-            this.searchPositionMarker = new mapboxgl.Marker();
+            var el = document.createElement('div');
+            el.addEventListener('click', function (e) {
+                console.log('marker clicked');
+                that.searchMarkerClicked(item);
+            });
+            el.className = 'search-result-marker';
+
+            this.searchPositionMarker = new mapboxgl.Marker(el);
             this.searchPositionMarker.setLngLat([ item.lon, item.lat ]);
             this.searchPositionMarker.addTo(map);
 
             map.flyTo({ center: [ item.lon, item.lat ], zoom: 16 });
         },
         searchSelectItem: function (item) {
-            this.search = item.display_name;
+            this.querySearchString = item.display_name;
             this.setSearchPositionMarker(item);
         },
-        searchNow: function (queryString, callback) {
-            findResults(queryString, this.position, callback);
+        doQuerySearch: function () {
+            var that = this;
+
+            this.querySearchResults = [];
+            this.markerDetailsOpen = false;
+
+            findResults(this.querySearchString, this.position, function (results) {
+                that.querySearchResults = results;
+                that.sidePanelOpen = true;
+            });
         },
         searchFocus: function () {
         }

+ 51 - 0
pin.svg

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   style="enable-background:new 0 0 48 48;"
+   version="1.1"
+   viewBox="0 0 48 48"
+   xml:space="preserve"
+   id="svg17"
+   sodipodi:docname="pin.svg"
+   inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
+     id="metadata23"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
+     id="defs21" /><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2880"
+     inkscape:window-height="1566"
+     id="namedview19"
+     showgrid="false"
+     inkscape:zoom="19.666667"
+     inkscape:cx="8.0610602"
+     inkscape:cy="23.223712"
+     inkscape:window-x="0"
+     inkscape:window-y="54"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g14" /><g
+     id="Icons"
+     transform="matrix(1.5101758,0,0,1.5101758,-12.244227,-12.244093)"><g
+       id="g14"><g
+         id="g833"
+         transform="matrix(0.64305236,0,0,0.64305236,8.5667452,0.79381313)"><g
+           transform="matrix(0.66217456,0,0,0.66217456,16.45795,-666.17227)"
+           id="g818"><path
+             style="fill:#ff0029;fill-opacity:0.65098039;stroke-width:1.55508471"
+             inkscape:connector-curvature="0"
+             d="m 11.38983,1023.2136 c -6.8708315,0 -12.4406785,5.5698 -12.4406785,12.4406 0,2.2098 0.59342034,4.2765 1.60360344,6.0742 0.1677936,0.2986 0.3436737,0.5925 0.53463806,0.8755 l 10.302437,17.9317 10.302437,-17.9317 c 0.158618,-0.2348 0.295466,-0.4836 0.436978,-0.7293 l 0.09797,-0.1462 c 1.00925,-1.7977 1.603292,-3.8644 1.603292,-6.0742 0,-6.8708 -5.570313,-12.4406 -12.440678,-12.4406 z m -0.158144,15.1554 c 3.435182,0 6.378483,-6.1501 6.378483,-2.7148 0,3.4352 -2.86423,7.0901 -6.299412,7.0901 -3.4353371,0 -6.6947713,-3.4177 -6.6947713,-6.8529 0,-3.4353 3.1803622,2.4776 6.6157003,2.4776 z"
+             id="path814"
+             sodipodi:nodetypes="ssccccccsssssss" /></g></g></g></g></svg>

+ 51 - 0
pinsmile.svg

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   style="enable-background:new 0 0 48 48;"
+   version="1.1"
+   viewBox="0 0 48 48"
+   xml:space="preserve"
+   id="svg17"
+   sodipodi:docname="pinsmile.svg"
+   inkscape:version="0.92.2 2405546, 2018-03-11"><metadata
+     id="metadata23"><rdf:RDF><cc:Work
+         rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+     id="defs21" /><sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2880"
+     inkscape:window-height="1566"
+     id="namedview19"
+     showgrid="false"
+     inkscape:zoom="19.666667"
+     inkscape:cx="23.900043"
+     inkscape:cy="23.325407"
+     inkscape:window-x="0"
+     inkscape:window-y="54"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g833" /><g
+     id="Icons"
+     transform="matrix(1.5101758,0,0,1.5101758,-12.244227,-12.244093)"><g
+       id="g14"><g
+         id="g833"
+         transform="translate(0,0.26935914)"><g
+           transform="matrix(0.66217456,0,0,0.66217456,16.45795,-666.17227)"
+           id="g818"><path
+             style="fill:#ff0029;fill-opacity:0.65098039;stroke-width:1.55508471"
+             inkscape:connector-curvature="0"
+             d="m 11.38983,1023.2136 c -6.8708315,0 -12.4406785,5.5698 -12.4406785,12.4406 0,2.2098 0.59342034,4.2765 1.60360344,6.0742 0.1677936,0.2986 0.3436737,0.5925 0.53463806,0.8755 l 10.302437,17.9317 10.302437,-17.9317 c 0.158618,-0.2348 0.295466,-0.4836 0.436978,-0.7293 l 0.09797,-0.1462 c 1.00925,-1.7977 1.603292,-3.8644 1.603292,-6.0742 0,-6.8708 -5.570313,-12.4406 -12.440678,-12.4406 z m 1.113042,6.7655 c 38.358365,-19.4764 1.24289,-0.4042 2.920856,2.4209 1.754224,2.9535 3.467763,1.1813 3.361605,3.5307 -0.09461,2.0939 -3.461219,4.0147 -6.682297,4.0388 -3.34689,0.025 -6.5488074,-1.9208 -6.4192537,-3.6713 0.2535512,-3.426 3.7559824,-4.7638 6.8190897,-6.3191 z"
+             id="path814"
+             sodipodi:nodetypes="ssccccccsssssssss" /></g></g></g></g></svg>