CustomMarker
<CustomMarker hit={object} // Optional parameters className={string} anchor={object} onClick={function} onDoubleClick={function} onMouseUp={function} onMouseDown={function} onMouseOut={function} onMouseOver={function} onMouseEnter={function} onMouseLeave={function} onMouseMove={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 component is an alternative to <Marker />
. In some cases, you may want to have the full control of the marker rendering. You can provide any React components to design your custom marker.
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
22
23
import {
GoogleMapsLoader,
GeoSearch,
CustomMarker,
} from 'react-instantsearch-dom-maps';
<div style={{ height: 500 }}>
<GoogleMapsLoader apiKey="GOOGLE_MAPS_API_KEY">
{google => (
<GeoSearch google={google}>
{({ hits }) => (
<div>
{hits.map(hit => (
<CustomMarker key={hit.objectID} hit={hit}>
{hit.name}
</CustomMarker>
))}
</div>
)}
</GeoSearch>
)}
</GoogleMapsLoader>
</div>
Props
hit
|
type: object
Required
The hit to attach on the marker. |
||
Copy
|
|||
className
|
type: string
default: ""
Optional
The |
||
Copy
|
|||
anchor
|
type: object
default: {x: 0, y: 0}
Optional
The offset for the marker element. |
||
Copy
|
|||
onClick
|
type: function
Optional
The standard |
||
Copy
|
|||
onDoubleClick
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseUp
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseDown
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseOut
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseOver
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseEnter
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseLeave
|
type: function
Optional
The standard |
||
Copy
|
|||
onMouseMove
|
type: function
Optional
The standard |
||
Copy
|