InfoWindow content!
Some arbitrary html to be rendered into the InfoWindow.
)}
>
);
};
```
### Props
#### Required Props
No props are strictly required, but either `position` or `anchor` must be provided to display the InfoWindow.
#### General Props
- **`position`** (google.maps.LatLngLiteral): The geographical coordinates where the InfoWindow will be displayed. This prop is ignored if an `anchor` is specified.
- **`anchor`** (google.maps.Marker | google.maps.marker.AdvancedMarkerElement): A Marker or AdvancedMarker instance to anchor the InfoWindow to. The InfoWindow will be positioned at the top-center of this anchor. References can be obtained using the `ref` property of `Marker` and `AdvancedMarker` components.
- **`zIndex`** (number): Controls the display order of InfoWindows, with higher values appearing in front. By default, InfoWindows are ordered by latitude, and they always appear in front of markers.
- **`pixelOffset`** ([number, number]): An offset in pixels from the tip of the InfoWindow to the anchor point on the map. If an InfoWindow is anchored, the offset is calculated from the anchor's top/center.
```
--------------------------------
### Setting Up Development Environment
Source: https://visgl.github.io/react-google-maps/docs/contributing
Installs dependencies and builds the project locally. Run these commands after cloning the repository.
```bash
git checkout main
npm install
npm run test
```
--------------------------------
### Install React Google Maps via npm
Source: https://visgl.github.io/react-google-maps/docs/get-started
Install the library using npm. This command adds the package to your project's dependencies.
```bash
npm install @vis.gl/react-google-maps
```
--------------------------------
### Install React Google Maps via yarn
Source: https://visgl.github.io/react-google-maps/docs/get-started
Install the library using yarn. This command adds the package to your project's dependencies.
```bash
yarn add @vis.gl/react-google-maps
```
--------------------------------
### InfoWindow Attached to Marker Example
Source: https://visgl.github.io/react-google-maps/docs/api-reference/components/info-window
Demonstrates a common use case where an InfoWindow is shown on click for a marker. This example includes handling marker clicks to toggle the InfoWindow and synchronizing state when the InfoWindow is closed by the map or user.
```jsx
const MarkerWithInfoWindow = ({position}) => {
const [markerRef, marker] = useAdvancedMarkerRef();
const [infoWindowShown, setInfoWindowShown] = useState(false);
const handleMarkerClick = useCallback(
() => setInfoWindowShown(isShown => !isShown),
[]
);
const handleClose = useCallback(() => setInfoWindowShown(false), []);
return (
<>