diff options
author | JeremyJamesL <jeremyluscombe@gmail.com> | 2024-12-17 20:02:52 +0000 |
---|---|---|
committer | JeremyJamesL <jeremyluscombe@gmail.com> | 2024-12-17 20:02:52 +0000 |
commit | 9aecf3a523bcd379a5afc66bb26d181361154264 (patch) | |
tree | 6b89873fbce489957ea1068efe04118a1abc2931 /src | |
parent | 8e5214809d79d2df726ddddf4f31508f937e959a (diff) |
readme
Diffstat (limited to 'src')
-rw-r--r-- | src/main.js | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/src/main.js b/src/main.js index 1466b3f..ac19077 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,7 @@ import { algoliasearch } from 'algoliasearch'; -const ALGOLIA_KEY = '9fb3db0222f7b5aef0e2b30791ee6201'; +import slugify from '@sindresorhus/slugify'; const INDEX_NAME = 'pubfinder'; -const client = algoliasearch('YSWWVAX5RB', ALGOLIA_KEY); +const client = algoliasearch('YSWWVAX5RB', '4203de3b08b981c149883b0af830db30'); const $ = document.querySelector.bind(document); const dataController = (function () { @@ -41,14 +41,9 @@ const dataController = (function () { geoParam = { insideBoundingBox: [bounds], }; - } else if (shape === 'polygon') { - geoParam = { - insidePolygon: [bounds], - }; } else { geoParam = { - aroundLatLng: bounds, - // aroundRadius: 1000, + insidePolygon: [bounds], }; } @@ -76,8 +71,6 @@ const interfaceController = (function () { const DOMStrings = { selectRect: '.select--rectangle', selectPoly: '.select--polygon', - ip: '.select--ip', - ipLoader: '.ip-loader', hits: '#hits', searchBar: '#searchbar', pubCount: '.pub-count', @@ -141,7 +134,13 @@ const interfaceController = (function () { }); const window = new InfoWindow({ - content: hit.name, + content: ` + <h2 class="text-black font-semibold text-md mb-2">${hit.name}</h2> + <h3 class="text-zinc-600 text-xs">${hit.address}</h3> + <a href="https://www.google.co.uk/maps/search/${slugify( + hit.address + )}" class="absolute top-2 left-2" target="_blank"><span class="text-xl">📍</span></a> + `, }); marker.addListener('click', function () { @@ -164,7 +163,9 @@ const interfaceController = (function () { html += `<li class="relative bg-[#373737] rounded-lg p-4"> <h3 class="font-medium mb-2">${pub.name}</h3> <h4 class="text-sm">${pub.address}, ${pub.postcode}</h4> - <a href="https://www.google.co.uk/maps/place/Ye+Old+White+Horse/" class="absolute block top-4 right-4" target="_blank"> + <a href="https://www.google.co.uk/maps/search/${slugify( + pub.address + )}" class="absolute block top-4 right-4" target="_blank"> <svg width="20px" height="20px" viewBox="0 0 24 24" fill="none" > <path d="M5 12V6C5 5.44772 5.44772 5 6 5H18C18.5523 5 19 5.44772 19 6V18C19 18.5523 18.5523 19 18 19H12M8.11111 12H12M12 12V15.8889M12 12L5 19" stroke="#D97706" stroke-linecap="round" stroke-linejoin="round" /> </svg> @@ -310,22 +311,6 @@ const controller = (function (dataCTRL, uiCTRL) { await setupMapListeners(); }); - // $(DOM.ip).addEventListener('click', async () => { - // $(DOM.ipLoader).classList.replace('hidden', 'inline-flex'); - // navigator.geolocation.getCurrentPosition(async (pos) => { - // const position = { lat: pos.coords.latitude, lng: pos.coords.longitude }; - // await uiCTRL.initMap('', centralPoint, position, '', 'ip', 8); - // const searchResults = await dataCTRL.getSearchResults( - // dataCTRL.getCurrentQuery(), - // 'ip', - // `${pos.coords.latitude}, ${pos.coords.longitude}`, - // 20 - // ); - // await uiCTRL.embedSearchResults(searchResults.hits); - // uiCTRL.updateHitsList(searchResults.hits); - // $(DOM.ipLoader).classList.replace('inline-flex', 'hidden'); - // }); - // }), $(DOM.searchBar).addEventListener('input', async (e) => { const q = dataCTRL.getCurrentQuery(); if (q > 0 && q < 3) return; |