Skip to content

Commit

Permalink
Add functions to get Google Maps links/URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
shgysk8zer0 committed Jun 24, 2024
1 parent a5be709 commit 4237baa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.0.6] - 2024-06-23

### Added
- Add function to get Google Maps link from `schema.org/PostalAddress` JSON-LD data

## [v1.0.5] - 2024-04-25

### Added
Expand Down
22 changes: 22 additions & 0 deletions google/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ export const getPolicy = callOnce(() => createPolicy(policyName, {
}
}));

export function getGoogleMapsAddressURL({
name,
streetAddress,
addressLocality,
addressRegion,
postalCode,
addressCounty,
}) {
return getGoogleMapsURL(
[name, streetAddress, addressLocality, addressRegion, postalCode, addressCounty]
.filter(part => typeof part === 'string')
.join(' ')
);
}

export function getGoogleMapsURL(addressQuery) {
const url = new URL('https://www.google.com/maps/search/?api=1');
url.searchParams.set('query', addressQuery);

return url;
}

export function createGoogleMapsURL(id, { policy } = {}) {
const url = new URL(GMAPS_EMBED);
url.searchParams.set('pb', id);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shgysk8zer0/kazoo",
"version": "1.0.5",
"version": "1.0.6",
"private": false,
"type": "module",
"description": "A JavaScript monorepo for all the things!",
Expand Down

0 comments on commit 4237baa

Please sign in to comment.