Skip to content

Commit 25b1646

Browse files
* Revert "Fix heatmapLibrary" This reverts commit 8e67c08. * Revert "Update API.md" This reverts commit 2d55ced. * Revert "Added all google maps api libraries to api loader (google-map-react#921)" This reverts commit 1718a4a.
1 parent 9e06d20 commit 25b1646

File tree

3 files changed

+12
-51
lines changed

3 files changed

+12
-51
lines changed

API.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Example:
1616
key: API_KEY,
1717
language: 'ru',
1818
region: 'ru',
19-
libraries:['places'],
2019
...otherUrlParams,
2120
}}
2221
>
@@ -351,7 +350,7 @@ For more details see the [google documentation](https://developers.google.com/ma
351350

352351
### Heatmap Layer
353352

354-
To use the heatmap layer, add `visualization` to the libraries property array on `bootstrapURLKeys` and provide the data & configuration for the heatmap in `heatmap` as props.
353+
To use the heatmap layer, add `heatmapLibrary={true}` to add the visualizations library, and provide the data&configuration for the heatmap in `heatmap` as props.
355354

356355
The typescript interface for the heatmap prop is as follows:
357356
```typescript
@@ -373,38 +372,20 @@ interface heatmapProp {
373372

374373
```javascript
375374
<GoogleMapReact
376-
bootstrapURLKeys={{
377-
key: [YOUR_KEY],
378-
libraries:['visualization']
379-
}}
380-
zoom={zoom}
381-
center={center}
382-
heatmap={{data}}
383-
>
384-
{markers}
385-
</GoogleMapReact>
375+
bootstrapURLKeys={{ key: [YOUR_KEY] }}
376+
zoom={zoom}
377+
center={center}
378+
heatmapLibrary={true}
379+
heatmap={{data}}
380+
>
381+
{markers}
382+
</GoogleMapReact>
386383
```
387384

388385
#### Important Note
389386

390-
If you have multiple `GoogleMapReact` components in project and you want to use heatmap layer provide `libraries:['visualization']` to `bootstrapURLKeys` so that the visualization library will be loaded with the google map api.
387+
If you have multiple `GoogleMapReact` components in project and you want to use heatmap layer so provide `heatmapLibrary={true}` for all `GoogleMapReact` components so component will load heatmap library at the beginning with google map api.
391388

392389
### Localizing the Map
393390

394391
This is done by setting bootstrapURLKeys.[language](https://developers.google.com/maps/documentation/javascript/localization#Language) and bootstrapURLKeys.[region](https://developers.google.com/maps/documentation/javascript/localization#Region). Also notice that setting region to 'cn' is required when using the map from within China, see [google documentation](https://developers.google.com/maps/documentation/javascript/localization#GoogleMapsChina) for more info. Setting 'cn' will result in use of the specific API URL for China.
395-
396-
397-
### Libraries
398-
399-
If you want to include additional libraries to load with the maps api, indicate them in the libraries property of the `bootstrapURLKeys` object.
400-
401-
Example:
402-
```JSX
403-
<GoogleMapReact
404-
bootstrapURLKeys={{
405-
key: [YOUR_KEY],
406-
libraries:['places', 'geometry', 'drawing', 'visualization']
407-
}}
408-
{markers}
409-
</GoogleMapReact>
410-
```

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## [2.1.0] - 2020-08-31
22

33
- #921 Add support to libraries: places, visualization, places, and geomerty.
4-
And keeps support for previous heatmapLibrary prop to avoid breaking older usage.
4+
And keeps support for previous heatMapLibrary prop to avoid breaking older usage.
55

66
## [2.0.4] - 2020-07-30
77

src/loaders/google_map_loader.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,12 @@ export default (bootstrapURLKeys, heatmapLibrary) => {
5858
}
5959
}
6060

61-
// Support for older version using heatmapLibrary option
62-
if (heatmapLibrary) {
63-
bootstrapURLKeys.libraries
64-
? bootstrapURLKeys.libraries.append('visualization')
65-
: (bootstrapURLKeys.libraries = ['visualization']);
66-
console.warn(
67-
"heatmapLibrary will be deprecated in the future. Please use bootstrapURLKeys.libraries property instead (libraries=['visualization'])."
68-
);
69-
}
70-
71-
// clean unknown and remove duplicates
72-
const googleMapsLibs = ['places', 'drawing', 'geometry', 'visualization'];
73-
if (bootstrapURLKeys.libraries) {
74-
bootstrapURLKeys.libraries = bootstrapURLKeys.libraries.filter(
75-
(lib, i) =>
76-
bootstrapURLKeys.libraries.indexOf(lib) === i &&
77-
googleMapsLibs.includes(lib)
78-
);
79-
}
80-
8161
const params = Object.keys(bootstrapURLKeys).reduce(
8262
(r, key) => `${r}&${key}=${bootstrapURLKeys[key]}`,
8363
''
8464
);
8565

86-
const { libraries } = bootstrapURLKeys;
66+
const libraries = heatmapLibrary ? '&libraries=visualization' : '';
8767

8868
$script_(
8969
`${DEFAULT_URL}${API_PATH}${params}${libraries}`,

0 commit comments

Comments
 (0)