You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Code Style and Code Quality](#code-style-and-code-quality)
16
+
-[Adding An Example](#adding-an-example)
17
+
-[Run examples](#run-examples)
18
+
-[Develop examples](#develop-examples)
19
+
-[Publish library on npm](#publish-library-on-npm)
20
+
21
+
---
22
+
9
23
## Setting Up Dev Environment
10
24
11
25
We will work on the `develop` branch.
@@ -87,27 +101,45 @@ Then open [`localhost:1234`](http://localhost:1234) in a browser.
87
101
88
102
-**IMPORTANT**: by submitting a patch, you agree to allow the project owners to license your work under this [LICENSE.md](LICENSE.md)
89
103
90
-
- please provide test cases for all features and bug fixes
104
+
- please provide test cases for all features and bug fixes
91
105
92
-
- provide documentation for all public API methods
106
+
- provide documentation for all public API methods
93
107
94
-
- commit messages should follow the format outlined in [CONVENTIONS.md](CONVENTIONS.md)
108
+
- commit messages should follow the format outlined in [CONVENTIONS.md](CONVENTIONS.md)
95
109
96
110
### Code Style and Code Quality
97
111
98
-
- Testing
112
+
-**Testing**
99
113
100
114
-[ESLint](https://eslint.org/) configuration files are provided
101
115
-[TypeScript](https://www.typescriptlang.org/) check for types and TypeScript setup
102
116
-[Prettier](https://prettier.io/) code formatter
103
117
104
-
- run`npm run test` before submitting a PR to ensure that your code uses correct style and passes all tests
118
+
Run`npm run test` before submitting a PR to ensure that your code uses correct style and passes all tests
105
119
106
120
---
107
121
108
122
## Adding An Example
109
123
110
-
Each hook should have an example in the examples folder. If you want to provide an example for a hook, please follow these steps:
124
+
Each hook should have an example in the examples folder.
125
+
126
+
### Run examples
127
+
128
+
To develop one of the examples, you have to create a `.env` file in the `/examples` directory first and add your [Google Maps API key](https://developers.google.com/maps/documentation/embed/get-api-key#:~:text=Go%20to%20the%20Google%20Maps%20Platform%20%3E%20Credentials%20page.&text=On%20the%20Credentials%20page%2C%20click,Click%20Close.) to it in the following format:
129
+
130
+
```
131
+
GOOGLE_MAPS_API_KEY="<YOUR API KEY HERE>"
132
+
```
133
+
134
+
An example can be found in `/examples/.env.example`.
135
+
136
+
Start the example locally with the appropriate task, e.g. `npm run start:map-example`. You can find the right task in the README of the example you want to start.
137
+
138
+
The example runs on [localhost:1234](http://localhost:1234).
139
+
140
+
### Develop examples
141
+
142
+
If you want to provide an example for a hook, please follow these steps:
111
143
112
144
1. Create a new folder in the [examples folder](./examples) with the new example's name.
113
145
@@ -132,3 +164,16 @@ Please compare to the other example start tasks.
132
164
5. Add a README to each example with an explanation of what the example does, a code snippet and an image of the example app in a ratio of 2:1.
133
165
134
166
6. Link the example in the [root README](./README.md) and the [README of the library workspace](./library/README.md) in the **Examples** overview of the **Table of contents** section.
167
+
168
+
---
169
+
170
+
## Publish library on npm
171
+
172
+
A new library version is automatically published by Github Actions as soon as a new version tag is available.
173
+
To trigger a new release, run:
174
+
175
+
```sh
176
+
npm version [<newversion>| major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] -w library
177
+
```
178
+
179
+
**NOTE**: Make sure to not forget setting the context to the library workspace with `-w library` when running the command from project root.
-[Street View Panorama With Element](./examples/street-view-panorama-with-element)
11
+
-[Requirements](#requirements)
12
+
-[Installation](#installation)
13
+
-[Library](#library)
14
+
-[Basic Google Map Setup](#basic-google-map-setup)
15
+
-[Hooks](#hooks)
16
+
-[Hooks Overview](#hooks-overview)
17
+
-[Hooks Example Setup](#hooks-example-setup)
18
+
-[Examples](#examples)
19
+
-[Examples Overview](#examples-overview)
27
20
-[Development](#development-only-for-maintainers)
28
-
-[Library](#library)
29
-
-[Examples](#examples)
30
-
-[Publish library on npm](#publish-library-on-npm)
21
+
-[Contribution](#contribution)
22
+
-[Quick Start](#quick-start)
31
23
32
-
## Development (only for Maintainers)
24
+
## Requirements
33
25
34
-
Clone the repository and run
26
+
You need to have React [16.8.0](https://reactjs.org/blog/2019/02/06/react-v16.8.0.html) or later installed to use the Hooks API.
27
+
28
+
## Installation
35
29
36
30
```sh
37
-
npm install
31
+
npm install @ubilabs/google-maps-react-hooks -D
38
32
```
39
33
40
-
in the project root to install all dependencies.
34
+
## Library
41
35
42
-
### Library
36
+
The full Google Maps React Hooks library can be found in the [library directory](./library).
43
37
44
-
To develop the Google Maps React Hooks library, start the project locally with
38
+
## Basic Google Map Setup
45
39
46
-
```sh
47
-
npm run start:library
40
+
Import the `GoogleMapsProvider` and wrap it around your components.
41
+
Make sure all components that should have access to the Google Maps map instance are nested inside the `GoogleMapsProvider`.
42
+
43
+
If you still can't see a map on your page, make sure that your map container has a `height` CSS property (by default it usually has no height) and that a `center` and `zoom` was set for your map.
To develop one of the examples, you have to create a `.env` file in the `/examples` directory first and add your [Google Maps API key](https://developers.google.com/maps/documentation/embed/get-api-key#:~:text=Go%20to%20the%20Google%20Maps%20Platform%20%3E%20Credentials%20page.&text=On%20the%20Credentials%20page%2C%20click,Click%20Close.) to it in the following format:
83
+
const MyComponent = () => {
84
+
const map =useGoogleMap();
53
85
86
+
// Do something with the Google Maps map instance
87
+
88
+
return (...);
89
+
};
54
90
```
55
-
GOOGLE_MAPS_API_KEY="<YOUR API KEY HERE>"
91
+
92
+
## Hooks
93
+
94
+
All hooks can be find [here](./library/src/hooks/). Please checkout the [documentation](./library/docs) for each hook and have a look at the [examples directory](./examples) to see how each hook can be implemented.
An example can be found in `/examples/.env.example`.
159
+
## Examples
160
+
161
+
Explore our [examples directory on GitHub](./examples) for full implementation examples.
59
162
60
-
Start the example locally with the appropriate task, e.g. `npm run start:map-example`. You can find the right task in the README of the example you want to start.
163
+
### Examples Overview
61
164
62
-
The example runs on [localhost:1234](http://localhost:1234).
165
+
-[Basic Google Map](./examples/basic-google-map)
166
+
-[Google Map with Markers](./examples/google-map-with-markers)
167
+
-[Multiple Google Maps](./examples/multiple-google-maps)
0 commit comments