Skip to content

Commit

Permalink
better support world wide lookups (#19)
Browse files Browse the repository at this point in the history
diff
  • Loading branch information
pjaudiomv authored Jun 7, 2024
1 parent f530239 commit 54b6e5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/BMLTDetector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
{#if latitude !== undefined && longitude !== undefined}
<SearchShare {latitude} {longitude} />
{/if}
<button class="button is-fullwidth" on:click={handleSearchAgainClick}>Search for Another Location</button>
</div>
{/if}

Expand Down
16 changes: 10 additions & 6 deletions src/lib/LocationInputModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let onError: (error: Error) => void;
export let onCancel: () => void;
const yolo: string = 'QUl6YVN5QnoxdmRudWQwTGNrTjJlLUdiVW1HVGJyb3hJTDhNRkFF';
let modal: HTMLDivElement;
let value: string;
Expand All @@ -16,14 +17,17 @@
async function handleSearch() {
if (value) {
try {
let url = `https://api.geocod.io/v1.6/geocode?api_key=8a8ceea13e3cad86e8c64616d41d3333d488c66&q=${value}`;
let response = await fetch(url);
let results = await response.json();
let result = results.results[0];
let url = `https://maps.googleapis.com/maps/api/geocode/json?key=${atob(yolo)}&address=${value}&sensor=false`;
const response = await fetch(url);
const results = await response.json();
if (results.status !== 'OK') {
throw new Error(results.status);
}
const result = results.results[0];
onSearch({
coords: {
latitude: result.location.lat,
longitude: result.location.lng
latitude: result.geometry.location.lat,
longitude: result.geometry.location.lng
}
});
} catch (error) {
Expand Down

0 comments on commit 54b6e5a

Please sign in to comment.