react-leaflet-geosearch
Version:
Adds support for address lookup (a.k.a. geocoding / geoseaching) to React-Leaflet.
21 lines (16 loc) • 455 B
JavaScript
import { useEffect } from 'react'
import { useMap } from 'react-leaflet'
import { GeoSearchControl } from 'leaflet-geosearch'
const SearchControl = (props) => {
const map = useMap()
useEffect(() => {
const searchControl = new GeoSearchControl({
provider: props.provider,
...props,
})
map.addControl(searchControl)
return () => map.removeControl(searchControl)
}, [props])
return null
}
export default SearchControl