forked from visgl/react-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): add getApiKey lib to every example
- Loading branch information
1 parent
bfa8316
commit ec40e11
Showing
8 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |