Skip to content

Commit

Permalink
(Examples) Add with-google-maps-embed example (#57365)
Browse files Browse the repository at this point in the history
Adds `with-google-maps-embed` example in `examples/` directory to show
how to use the `<GoogleMapsEmbed />` component from
_@next/third-parties_.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
  • Loading branch information
housseindjirdeh authored Oct 27, 2023
1 parent aaf668a commit 307bdcd
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/with-google-maps-embed/.env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_GOOGLE_API_KEY=
36 changes: 36 additions & 0 deletions examples/with-google-maps-embed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
35 changes: 35 additions & 0 deletions examples/with-google-maps-embed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Example app using Google Maps Embed

This example shows how to embed a Google Maps Embed using `@next/third-parties`.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-google-maps-embed&project-name=with-google-maps-embed&repository-name=with-google-maps-embed)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example with-google-maps-embed with-google-maps-embed-app
```

```bash
yarn create next-app --example with-google-maps-embed with-google-maps-embed-app
```

```bash
pnpm create next-app --example with-google-maps-embed with-google-maps-embed-app
```

Next, copy the `.env.local.example` file in this directory to `.env.local` (which will be ignored by Git):

```bash
cp .env.local.example .env.local
```

Set the `NEXT_PUBLIC_GOOGLE_API_KEY` variable in `.env.local` to match your Google Maps API Key.

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
7 changes: 7 additions & 0 deletions examples/with-google-maps-embed/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
17 changes: 17 additions & 0 deletions examples/with-google-maps-embed/app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { GoogleMapsEmbed } from '@next/third-parties/google'

const API_KEY = process.env.NEXT_PUBLIC_GOOGLE_API_KEY

export default function Page() {
return (
<div>
<GoogleMapsEmbed
apiKey={API_KEY}
height={400}
width={700}
mode="place"
q="Brooklyn+Bridge,New+York,NY"
/>
</div>
)
}
14 changes: 14 additions & 0 deletions examples/with-google-maps-embed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"@next/third-parties": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

0 comments on commit 307bdcd

Please sign in to comment.