Marker
<Marker hit={object} // Optional parameters onClick={function} onDoubleClick={function} onMouseDown={function} onMouseOut={function} onMouseOver={function} onMouseUp={function} />
About this widget
We released React InstantSearch Hooks, a new InstantSearch library for React. We recommend using React InstantSearch Hooks in new projects or upgrading from React InstantSearch.
This widget is a wrapper around google.maps.Marker
, all the options available on the Marker
can be provided as props. This component can’t render any children components. You can take a look at <CustomMarker />
for this behavior.
The component currently doesn’t support options updates. Once the component is rendered, changing the props won’t update the marker options. You have to unmount then mount the widget back.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {
GoogleMapsLoader,
GeoSearch,
Marker,
} from 'react-instantsearch-dom-maps';
<div style={{ height: 500 }}>
<GoogleMapsLoader apiKey="GOOGLE_MAPS_API_KEY">
{google => (
<GeoSearch google={google}>
{({ hits }) => (
<div>
{hits.map(hit => (
<Marker key={hit.objectID} hit={hit} />
))}
</div>
)}
</GeoSearch>
)}
</GoogleMapsLoader>
</div>
Props
hit
|
type: object
Required
The hit to attach on the marker. |
||
Copy
|
|||
onClick
|
type: function
Optional
The event that is fired when the marker icon is clicked. See the Google Maps documentation for more information. |
||
Copy
|
|||
onDoubleClick
|
type: function
Optional
The event that is fired when the marker icon is double-clicked. See the Google Maps documentation for more information. |
||
Copy
|
|||
onMouseDown
|
type: function
Optional
The event that is fired on mousedown on the marker. See the Google Maps documentation for more information. |
||
Copy
|
|||
onMouseOut
|
type: function
Optional
The event that is fired when the mouse leaves the area of the marker icon. See the Google Maps documentation for more information. |
||
Copy
|
|||
onMouseOver
|
type: function
Optional
The event that is fired when the mouse enters the area of the marker icon. See the Google Maps documentation for more information. |
||
Copy
|
|||
onMouseUp
|
type: function
Optional
The event that is fired on mouseup on the marker. See the Google Maps documentation for more information. |
||
Copy
|