Skip to content

Commit

Permalink
Add click event to GoogleMap component (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylpx authored Jul 25, 2023
1 parent 89d2d79 commit 40fa0a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Not released

- Add onClick event handler to GoogleMap component [#747](https://github.com/CartoDB/carto-react/pull/747)

## 2.2

### 2.2.1 (2023-07-21)
Expand Down
5 changes: 5 additions & 0 deletions packages/react-basemaps/src/basemaps/GoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { debounce } from '@carto/react-core';
* @param { Object } props.viewState - Viewstate, as defined by deck.gl. Just center and zoom level are supported
* @param { Layer[] } props.layers - deck.gl layers array
* @param { function } props.getTooltip - (Optional) Tooltip handler
* @param { function } props.onClick - (Optional) onClick handler
* @param { function } props.onResize - (Optional) onResize handler
* @param { function } props.onViewStateChange - (Optional) onViewStateChange handler
* @param { string } props.apiKey - Google Maps API Key
Expand All @@ -24,6 +25,7 @@ export function GoogleMap(props) {
viewState,
layers,
getTooltip,
onClick,
onResize,
onViewStateChange,
apiKey,
Expand Down Expand Up @@ -90,6 +92,9 @@ export function GoogleMap(props) {

const handleViewportChangeDebounced = debounce(handleViewportChange, 200);
map.addListener('bounds_changed', handleViewportChangeDebounced);
if (onClick) {
map.addListener('click', onClick);
}
map.addListener('resize', () => {
onResize &&
onResize({
Expand Down

0 comments on commit 40fa0a5

Please sign in to comment.