leaflet-geosearch icon indicating copy to clipboard operation
leaflet-geosearch copied to clipboard

Getting Longitude & Latitude from GeoSearchControl

Open mhatreD opened this issue 3 years ago • 3 comments

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: '&copy; <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 image

mhatreD avatar Sep 14 '20 08:09 mhatreD

@mhatreD Please, can you provide your example as JSFiddle, or something like that? It would be very helpful. Thank you :)

yznts avatar Oct 01 '20 07:10 yznts

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.

phanirithvij avatar Dec 05 '20 14:12 phanirithvij

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.

Could you solve this?

SalahAdDin avatar Jun 17 '22 18:06 SalahAdDin