I am trying to make a form that a user can search their location or pin his location. I am using react-leaflet
for loading a map and react-leaflet-search
for adding the search functionality.
The search functionality is working fine. Below you can see the code.
<Map center={position} zoom={zoom} onDragEnd = {function(e){ console.log(e);}} >
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='https://{s}.tile.osm.org/{z}/{x}/{y}.png'/>
<Search
position="topright"
showPopup={false}
provider="OpenStreetMap"
showMarker={true}
openSearchOnLoad={true}
closeResultsOnClick={true}
providerOptions={{ region: "np" }}/>
</Map>
What I want to do is to access user's entered location or latitude longitude of the marker that is displayed after user selects the location. I tried to search for event listeners, but could not find any. Currently I am trying to use onDragEnd
event but I have not succeeded yet. Could anyone tell me how to achieve what I am trying to do?