leaflet-geosearch
leaflet-geosearch copied to clipboard
Getting Longitude & Latitude from GeoSearchControl
Hi,
I have developed below code for GeoSearchControl, but not getting Long & Lat after search is completed
const searchControl = new GeoSearchControl({ //geosearch object provider: new OpenStreetMapProvider({ params: { 'accept-language': 'en', // render results in English // countrycodes: '', // limit search results to Canada & United States }, }), style: 'button', showMarker: true, autoComplete: true, showPopup: true, autoClose: true, retainZoomLevel: false, animateZoom: true, keepResult: true, searchLabel: 'Enter Address' });
Below code is added in Class component
componentDidMount() { //Defining the offline layer for the map const map = L.map('map-id'); const offlineLayer = L.tileLayer.offline('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', localforage, { attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>', subdomains: 'abc', minZoom: 13, maxZoom: 19, crossOrigin: true }); offlineLayer.addTo(map);//add the offline layer map.zoomControl.remove(); map.addControl(searchControl); }
How can I get Longitude & Latitude when we clicked on Search Result, below is the screenshot of Search Result
@mhatreD Please, can you provide your example as JSFiddle, or something like that? It would be very helpful. Thank you :)
The question is are there any callbacks that can be added to the controller which can allow getting marker position like onResult(result, query): void
and onDrag(x, y, query): void
?
Just any example works they're asking for a way of getting marker position. While NOT using the providers directly and managing the state.
The question is are there any callbacks that can be added to the controller which can allow getting marker position like
onResult(result, query): void
andonDrag(x, y, query): void
?Just any example works they're asking for a way of getting marker position. While NOT using the providers directly and managing the state.
Could you solve this?