Skip to content

Commit 571bcc7

Browse files
committed
Merge branch 'develop' into feat/update-properties-readme
2 parents 9ce5144 + 0c97f36 commit 571bcc7

29 files changed

+8813
-29
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules
22
dist
33
.vscode
4+
.env
5+
.parcel-cache
6+
public

.pretiierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"jsxBracketSameLine": true,
10+
"arrowParens": "avoid",
11+
"parser": "typescript"
12+
}

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## [1.5.1](https://github.com/ubilabs/google-maps-react-hooks/compare/v1.4.7...v1.5.1) (2021-11-22)
1+
## [1.5.3](https://github.com/ubilabs/google-maps-react-hooks/compare/v1.4.7...v1.5.3) (2022-10-17)
2+
3+
4+
### Bug Fixes
5+
6+
* **package:** adjust module ([#56](https://github.com/ubilabs/google-maps-react-hooks/issues/56)) ([106311e](https://github.com/ubilabs/google-maps-react-hooks/commit/106311e1d3160fc2639338a1191c9a78872d413c))
27

38

49

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Google Maps React Hooks
2+
[![npm version](https://img.shields.io/npm/v/@ubilabs/google-maps-react-hooks)](https://www.npmjs.com/package/@ubilabs/google-maps-react-hooks) [![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ubilabs/google-maps-react-hooks/blob/develop/LICENSE)
23

34
## Description
45

@@ -108,6 +109,7 @@ interface GoogleMapProviderProps {
108109
language?: string;
109110
region?: string;
110111
version?: string;
112+
authReferrerPolicy?: string;
111113
onLoad?: (map: google.maps.Map) => void;
112114
}
113115
```
@@ -255,6 +257,18 @@ See: [Versions](https://developers.google.com/maps/documentation/javascript/vers
255257

256258
- - - -
257259

260+
__authReferrerPolicy__ (_optional property_)
261+
262+
Use this parameter to set auth_referrer_policy=origin when an URL on the same origin uses the API Key, to limit the amount of data sent when authorizing requests.
263+
264+
```Typescript
265+
authReferrerPolicy?: string;
266+
```
267+
268+
See: [auth_referrer_policy](https://developers.google.com/maps/documentation/javascript/url-params)
269+
270+
- - - -
271+
258272
__onLoad__ (_optional property_)
259273

260274
A callback function that is called, when the map is loaded.
@@ -276,18 +290,6 @@ _Example:_
276290

277291
- - - -
278292

279-
__authReferrerPolicy__ (_optional property_)
280-
281-
Use this parameter to set auth_referrer_policy=origin when an URL on the same origin uses the API Key, to limit the amount of data sent when authorizing requests.
282-
283-
```Typescript
284-
authReferrerPolicy?: string;
285-
```
286-
287-
See: [auth_referrer_policy](https://developers.google.com/maps/documentation/javascript/url-params)
288-
289-
- - - -
290-
291293
## Hooks
292294

293295
### useGoogleMap

examples/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GOOGLE_MAPS_API_KEY="..."
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Basic Google Maps Setup Example
2+
3+
This is an example setup to show a **basic Google Map** with the Google Maps React Hooks library.
4+
5+
## Instructions
6+
7+
To run this project, clone the Google Maps React Hooks repository locally.
8+
9+
At the root of the repository, run:
10+
11+
```shell
12+
npm run start:sample-map
13+
```
14+
15+
**NOTE**:
16+
To see the examples it is needed to add an `.env` file with a [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.) in the following format:
17+
18+
`GOOGLE_MAPS_API_KEY="<YOUR API KEY HERE>"`
19+
20+
An example can be found in `.env.example`.
21+
22+
## Output
23+
24+
The project will start at [localhost:1234](http://localhost:1234) and show a basic Google Map.
25+
26+
![image](https://user-images.githubusercontent.com/39244966/194873046-3e731074-c7f5-4ff7-8b7d-69f7895ce50a.png)

examples/basic-google-map/app.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, {FunctionComponent, useState, useCallback} from 'react';
2+
import {GoogleMapProvider} from '@ubilabs/google-maps-react-hooks';
3+
4+
import MapCanvas from './components/map-canvas/map-canvas';
5+
6+
import {GOOGLE_MAPS_API_KEY} from '../constants';
7+
8+
import './main.module.css';
9+
10+
const mapOptions = {
11+
center: {lat: 53.5582447, lng: 9.647645},
12+
zoom: 6,
13+
disableDefaultUI: true,
14+
zoomControl: true,
15+
zoomControlOptions: {
16+
position: 3 // Right top
17+
}
18+
};
19+
20+
const App: FunctionComponent<Record<string, unknown>> = () => {
21+
const [mapContainer, setMapContainer] = useState<HTMLDivElement | null>(null);
22+
23+
const mapRef = useCallback(
24+
(node: React.SetStateAction<HTMLDivElement | null>) => {
25+
node && setMapContainer(node);
26+
},
27+
[]
28+
);
29+
30+
return (
31+
<React.StrictMode>
32+
<GoogleMapProvider
33+
googleMapsAPIKey={GOOGLE_MAPS_API_KEY}
34+
mapContainer={mapContainer}
35+
options={mapOptions}
36+
>
37+
<div id="container">
38+
<MapCanvas ref={mapRef} />
39+
</div>
40+
</GoogleMapProvider>
41+
</React.StrictMode>
42+
);
43+
};
44+
45+
export default App;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.map {
2+
width: 100%;
3+
height: 100%;
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React, {forwardRef} from 'react';
2+
3+
import styles from './map-canvas.module.css';
4+
5+
const MapCanvas = forwardRef<HTMLDivElement, Record<string, unknown>>(
6+
(_, ref) => <div ref={ref} className={styles.map} />
7+
);
8+
9+
export default MapCanvas;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="de-DE">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1.0, user-scalable=no"
8+
/>
9+
<title>Basic Google Maps setup with the Google Maps React Hooks.</title>
10+
<meta
11+
name="description"
12+
content="Basic Google Maps setup with the Google Maps React Hooks."
13+
/>
14+
</head>
15+
<body>
16+
<div id="app"></div>
17+
<script type="module" src="./index.tsx"></script>
18+
</body>
19+
</html>

0 commit comments

Comments
 (0)