From d3972d4244d7a98be4e11291dcb4dd57f38373da Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 23 Apr 2022 14:52:31 +0530 Subject: [PATCH] add a map Closes #1 --- _config.yml | 4 +- _data/business.yml | 92 +++++++++++++++++++++++++++++++++++++++ _includes/address.html | 1 + _includes/head.html | 2 + _includes/icon.html | 16 +++++++ _includes/location.html | 8 +--- _layouts/home.html | 10 ++++- assets/favicon.png | Bin 0 -> 7853 bytes assets/style.css | 94 +++++++++++++++++++++++++++++++++++----- map.geojson | 34 +++++++++++++++ map.js | 86 ++++++++++++++++++++++++++++++++++++ marker.svg | 7 +++ 12 files changed, 333 insertions(+), 21 deletions(-) create mode 100644 _data/business.yml create mode 100644 _includes/address.html create mode 100644 _includes/icon.html create mode 100644 assets/favicon.png create mode 100644 map.geojson create mode 100644 map.js create mode 100644 marker.svg diff --git a/_config.yml b/_config.yml index 1152e55..441dd9e 100644 --- a/_config.yml +++ b/_config.yml @@ -5,4 +5,6 @@ description: > theme: minima baseurl: /plugo/ url: https://captnemo.in -timezone: Asia/Kolkata \ No newline at end of file +timezone: Asia/Kolkata +# mapboxtoken: pk.eyJ1IjoiY2FwdG4zbTAiLCJhIjoiY2wyYmdvNmcxMGYyMDNic2MyY3Rvd28yNiJ9.4IiMK807T05VEE2loTN1Jg +mapboxtoken: pk.eyJ1IjoiY2FwdG4zbTAiLCJhIjoiY2pmanVvdWNkMHNmOTJ3bzNnYXIwcnpwZSJ9.C1N7hcYotH63uQjx5sk7Xg \ No newline at end of file diff --git a/_data/business.yml b/_data/business.yml new file mode 100644 index 0000000..479d7c9 --- /dev/null +++ b/_data/business.yml @@ -0,0 +1,92 @@ +--- +' pg': lodging +aero: airport +amusement: amusement-park +apartment: lodging +backpacker: lodging +bakery: bakery +bar: bar +brew: beer +business: suitcase +cafe: cafe +casino: star +cell phone: shop +clinic: hospital +club: music +co-working space: suitcase +co-working: suitcase +cocktail: bar +cofee: cafe +coffee: cafe +college: college +company: suitcase +convention: information +corporate: suitcase +coworking space: suitcase +cultural: theatre +dealer: shop +delivery: triangle +dhaba: fast-food +diabetologist: hospital +fast food: fast-food +fertility: hospital +food: restaurant +footwear: shop +furniture: shop +games: amusement-park +gaming: amusement-park +gents pg: lodging +geocery: grocery +grocery: grocery +grocery: grocery +gym: bicycle-share +home stay: lodging +hookah: marker +hospital: hospital +hostel: lodging +hotal: restaurant +hotel: restaurant +ice cream: ice-cream +institute: college +juice: cafe +kitchen: restaurant +lodging: lodging +logistics: triangle +lounge: restaurant +management: suitcase +materinity: hospital +maternity: hospital +medical: hospital +metro: rail-metro +music: music +office: suitcase +oyo: lodging +pharmaceutical: pharmacy +printing: shop +pub: bar +resort: lodging +restaraunt: restaurant +restaruant: restaurant +restaurant: restaurant +restaurant: restaurant +resturent: restaurant +retail: shop +sales: shop +school: school +shop: shop +shopping: shop +showroom: shop +sports: playground +start-up: suitcase +startup: suitcase +stay: lodging +store: shop +subway: entrance +super market: shop +supermarket: shop +sweets shop: shop +textile: clothing-store +toqri: suitcase +training centre: college +ware house: triangle +warehouse: triangle \ No newline at end of file diff --git a/_includes/address.html b/_includes/address.html new file mode 100644 index 0000000..48396f7 --- /dev/null +++ b/_includes/address.html @@ -0,0 +1 @@ +{% assign address = include.address %}{% for mapping in site.include.data.city %}{% assign old=mapping[0] %}{% assign new=mapping[1] %}{% assign address = address|replace:old,new %}{% endfor %}{{address | strip}} \ No newline at end of file diff --git a/_includes/head.html b/_includes/head.html index 9965661..68301a1 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -5,4 +5,6 @@ {%- seo -%} + + \ No newline at end of file diff --git a/_includes/icon.html b/_includes/icon.html new file mode 100644 index 0000000..f5b5fcb --- /dev/null +++ b/_includes/icon.html @@ -0,0 +1,16 @@ +{% assign icon_found=false%} +{% assign location_name = include.data.name | downcase %} +{% assign location_type = include.data.business | downcase %} +{% for icon in site.data.business %} +{% assign match=icon[0] | downcase%} + {% if location_name contains match %} + {{icon[1]}}-15 + {%assign icon_found=true%} + {%break%} + {% elsif location_type contains match %} + {{icon[1]}}-15 + {%assign icon_found=true%} + {%break%} + {%endif%} +{%endfor%} +{%unless icon_found%}marker-15{%endunless%} \ No newline at end of file diff --git a/_includes/location.html b/_includes/location.html index 1b9ff5e..37cb42c 100644 --- a/_includes/location.html +++ b/_includes/location.html @@ -1,13 +1,7 @@ {% assign city_lower_case = include.data.city|downcase %} {{include.data.name}}
{% if include.data.floor!="NA"%}{{include.data.floor}}, {%endif %} -{% assign address = include.data.address %} -{% for mapping in site.include.data.city %} -{% assign old=mapping[0] %} -{% assign new=mapping[1] %} -{% assign address = address|replace:old,new %} -{% endfor %} - {{address}} + {% include address.html address=include.data.address %}
{% assign w=include.data.website|strip %} {% if w!="" %}
🔗{%endif%} diff --git a/_layouts/home.html b/_layouts/home.html index e7bbbcd..1797db4 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -1,6 +1,10 @@ --- layout: default --- +
+ Show Map +
+
{{content}} @@ -46,6 +50,7 @@ layout: default
  • {{zeroPowerBankLocations}} locations with zero powerbanks
  • Last Updated: {{site.time | date: "%Y-%m-%d %H:%M" }} IST
  • This page is automatically updated 5 times a day, at roughly 0930, 1230, 1530, 1830, 2130 IST
  • +
  • The map is also available in GeoJSON Format. You can also view the underlying data directly at geojson.io. @@ -58,4 +63,7 @@ layout: default }); - \ No newline at end of file + + + + \ No newline at end of file diff --git a/assets/favicon.png b/assets/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..1d6f6142ec20b98a2b25bf5bf978d4e0619032e7 GIT binary patch literal 7853 zcmbVR30zah*1t&rA%Kcpki~^XFcCqJ;9iJg0trEqfLp39M#Tiw7PanZ(4un1vW3N{ zC1zn!sa1mu7U~wQ3kqRT!M%zCTD1x)3Vdf0tgY|+z4yHjy-DuO+_~p}mYH+@({rQe z9@d}B=CCmm3ByS659?{dLNPmQn|?M_yMBH9*$=S8okzGj4;<(mILv#q!4rcf zj1P^76@-R~!pBdDPK*)Fk4spbz~ryoutJg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HcmV?d00001 diff --git a/assets/style.css b/assets/style.css index 4202c8e..a9dcecb 100644 --- a/assets/style.css +++ b/assets/style.css @@ -94,7 +94,7 @@ table.dataTable tr.dt-hasChild td.dt-control:before { content: "-"; background-color: #d33333; } - + /* * Table styles */ @@ -159,7 +159,8 @@ table.dataTable tbody th, table.dataTable tbody td { padding: 8px 10px; } -table.dataTable.nowrap th, table.dataTable.nowrap td { +table.dataTable.nowrap th, +table.dataTable.nowrap td { white-space: nowrap; } table.dataTable.compact thead th, @@ -174,12 +175,12 @@ table.dataTable.compact tbody th, table.dataTable.compact tbody td { padding: 4px; } - + table.dataTable th, table.dataTable td { box-sizing: content-box; } - + /* * Control feature layout */ @@ -250,12 +251,68 @@ table.dataTable td { *margin-top: -1px; -webkit-overflow-scrolling: touch; } -.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > thead > tr > th, .dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > thead > tr > td, .dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > tbody > tr > th, .dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > tbody > tr > td { +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > thead + > tr + > th, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > thead + > tr + > td, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > tbody + > tr + > th, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > tbody + > tr + > td { vertical-align: middle; } -.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > thead > tr > th > div.dataTables_sizing, -.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > thead > tr > td > div.dataTables_sizing, .dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > tbody > tr > th > div.dataTables_sizing, -.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody > table > tbody > tr > td > div.dataTables_sizing { +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > thead + > tr + > th + > div.dataTables_sizing, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > thead + > tr + > td + > div.dataTables_sizing, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > tbody + > tr + > th + > div.dataTables_sizing, +.dataTables_wrapper + .dataTables_scroll + div.dataTables_scrollBody + > table + > tbody + > tr + > td + > div.dataTables_sizing { height: 0; overflow: hidden; margin: 0 !important; @@ -275,10 +332,10 @@ table.dataTable td { clear: both; height: 0; } - + @media screen and (max-width: 767px) { .dataTables_wrapper .dataTables_info, -.dataTables_wrapper .dataTables_paginate { + .dataTables_wrapper .dataTables_paginate { float: none; text-align: center; } @@ -288,11 +345,24 @@ table.dataTable td { } @media screen and (max-width: 640px) { .dataTables_wrapper .dataTables_length, -.dataTables_wrapper .dataTables_filter { + .dataTables_wrapper .dataTables_filter { float: none; text-align: center; } .dataTables_wrapper .dataTables_filter { margin-top: 0.5em; } -} \ No newline at end of file +} +#map { + top: 0; + bottom: 0; + width: 740px; + height: 400px; +} +.mapboxgl-canvas-container { + height: 100vh; +} +.mapboxgl-popup { + max-width: 400px; + font: 12px/20px "Helvetica Neue", Arial, Helvetica, sans-serif; +} diff --git a/map.geojson b/map.geojson new file mode 100644 index 0000000..e54efc4 --- /dev/null +++ b/map.geojson @@ -0,0 +1,34 @@ +--- +--- +{ + "type": "FeatureCollection", + "features": [{% for location in site.data.plugo %} + {% if location.totalAvailablePowerbanks > 0 %} + { + "type": "Feature", + "properties": { + "shorttitle": {{location.name | truncate:20| jsonify}}, + "title": {{location.name|jsonify}},{% assign w=location.website|strip %}{% if w!="" %} + "url": "{% if w contains 'http' %}{%else%}http://{%endif%}{{w}}",{%endif%} + "geourl": "geo:{{location.lat}},{{location.lng}}", + {%capture ADDRESS %}{% include address.html address=location.address%}{%endcapture%} + "address": {{ADDRESS |jsonify}}, + "count": {{location.totalAvailablePowerbanks}}, + {% if location.mobile %}{%unless location.mobile contains '8047112182' %} + "tel": "tel:{{location.mobile| strip}}", + {%endunless%}{%endif%} + {%capture html%}{% include location.html data=location %}{%endcapture%} + "description": {{html|strip|jsonify}}, + "type": {{location.business|jsonify}}, + {%capture icon %}{%include icon.html data=location%}{%endcapture%} + "icon": "{{icon| strip}}", + "id": "{{location.id}}" + }, + "geometry": { + "type": "Point", + "coordinates": [{{location.lng}},{{location.lat}}] + } + }{% endif %} + {% if forloop.rindex > 1 %}{%if location.totalAvailablePowerbanks>0 %},{%endif%}{% endif%}{% endfor %} + ] +} \ No newline at end of file diff --git a/map.js b/map.js new file mode 100644 index 0000000..b48de1f --- /dev/null +++ b/map.js @@ -0,0 +1,86 @@ +--- +--- +mapboxgl.accessToken = "{{site.mapboxtoken}}"; +const map = new mapboxgl.Map({ + container: "map", + style: "mapbox://styles/mapbox/light-v10", + zoom: 7, + center: [77.61588870000003, 12.9346911], +}); +map.on("idle", function () { + map.resize(); +}); +map.on("load", (e) => { + map.resize(); + map.loadImage("/plugo/map-marker-icon.png", (error, image) => { + if (error) throw error; + map.addImage("custom-marker", image); + }); + map.addSource("plugo", { + type: "geojson", + data: "map.geojson", + data: "/plugo/map.geojson", + }); + + + map.addLayer({ + id: "markers", + type: "symbol", + source: "plugo", + layout: { + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "text-allow-overlap": true, + "icon-size": 1.3, + "icon-image": ["get", "icon"], + "text-variable-anchor": ["bottom", "right"], + "text-radial-offset": 0.7, + "text-field": ["get", "shorttitle"], + "text-size": {"stops": [ + [0, 0], + [12, 0], + [12.99999999, 0], + [13.0000001, 10], + [15, 12], + [20, 15] + ]}, + }, + paint:{ + "icon-color": "#00ff00", + "text-color": "#202", + "text-halo-color": "#ebff32", + "text-halo-blur": 1, + "text-halo-width": 2 + }, + }); + + map.on("mouseenter", "markers", () => { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change it back to a pointer when it leaves. + map.on("mouseleave", "markers", () => { + map.getCanvas().style.cursor = ""; + }); + + function onclick(e) { + // Copy coordinates array. + const coordinates = e.features[0].geometry.coordinates.slice(); + const P = e.features[0].properties; + + // Ensure that if the map is zoomed out such that multiple + // copies of the feature are visible, the popup appears + // over the copy being pointed to. + while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) { + coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360; + } + + new mapboxgl.Popup() + .setLngLat(coordinates) + .setHTML(`${P.description}
    ${P.count} powerbanks available
    Location Type: ${P.type}`) + .addTo(map); + } + + map.on('click', 'markers', onclick); +}); +map.addControl(new mapboxgl.FullscreenControl()); diff --git a/marker.svg b/marker.svg new file mode 100644 index 0000000..57a288b --- /dev/null +++ b/marker.svg @@ -0,0 +1,7 @@ + + + + + + +