๐Ÿ“ฆ leonardomso / react-google-static

๐Ÿ“„ README.md ยท 133 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133<h1 align="center">
   ๐ŸŒ React Google Static Maps
</h1>

[![Actions Status](https://github.com/leonardomso/react-google-static/workflows/CI/badge.svg)](https://github.com/leonardomso/react-google-static/actions)
[![LICENSE MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/leonardomso/react-google-static)
[![npm version](https://badge.fury.io/js/react-google-static.svg)](https://badge.fury.io/js/react-google-static)

A React component wrapper to use the Google Static Maps API. Don't forget that to use this API you must have a billing account and an Static Maps API key. 

This library supports custom markers. To use a custom icon, you should provide a url link, for example: `https://img.icons8.com/dusk/64/000000/marker.png`.
  

## Installation

```
npm install react-google-static
```

```
yarn add react-google-static
```

## Usage

```jsx
import React from 'react';
import GoogleStaticMap from 'react-google-static';

const App = () => (
  <div>
    <h1>Google Static Maps API</h1>

    <GoogleStaticMap
      apiKey={API_KEY}
      latitude={32.064171}
      longitude={34.7748068}
      style={{ width: 200, height: 200 }}
      size={{ width: 200, height: 200 }}
      zoom={16}
    />
  </div>
);

export default App;
```

## Usage with Custom Icon

```jsx
import React from 'react';
import GoogleStaticMap from 'react-google-static';

const App = () => (
  <div>
    <h1>Google Static Maps API</h1>

    <GoogleStaticMap
      apiKey={API_KEY}
      latitude={32.064171}
      longitude={34.7748068}
      style={{ width: 200, height: 200 }}
      size={{ width: 200, height: 200 }}
      zoom={16}
      iconUrl="https://img.icons8.com/dusk/64/000000/marker.png"
    />
  </div>
);

export default App;
```


## Props

<table>
  <tr>
    <th>Name</th>
    <th>Type</th>
    <th>Required</th>
  </tr>
  <tr>
    <td><code>apiKey</code></td>
    <td><code>Boolean</code></td>
    <td><code>true</code></td>
  </tr>
  <tr>
    <td><code>latitude</code></td>
    <td><code>string | number</code></td>
    <td><code>true</code></td>
  </tr>
    <tr>
    <td><code>longitude</code></td>
    <td><code>string | number</code></td>
    <td><code>true</code></td>
  </tr>
   <tr>
    <td><code>size</code></td>
    <td><code>Object</code></td>
    <td><code>true</code></td>
  </tr>
   <tr>
    <td><code>zoom</code></td>
    <td><code>number</code></td>
    <td><code>true</code></td>
  </tr>
  <tr>
    <td><code>scale</code></td>
    <td><code>number</code></td>
    <td><code>false</code></td>
  </tr>
  <tr>
    <td><code>mapFormat</code></td>
    <td><code>'png'  |  'png32'  |  'gif'  |  'jpg'  |  'jpg-baseline'</code></td>
    <td><code>false</code></td>
  </tr>
   <tr>
    <td><code>mapType</code></td>
    <td><code>'roadmap'  |  'satellite'  |  'terrain'  |  'hybrid'</code></td>
    <td><code>false</code></td>
  </tr>
  <tr>
    <td><code>iconUrl</code></td>
    <td><code>string</code></td>
    <td><code>false</code></td>
  </tr>
  <tr>
    <td><code>style</code></td>
    <td><code>any</code></td>
    <td><code>false</code></td>
  </tr>
</table>