Javascript 如何检索位置';当我知道latitude&;使用传单控制地理编码器在React传单中的经度?

Javascript 如何检索位置';当我知道latitude&;使用传单控制地理编码器在React传单中的经度?,javascript,reactjs,leaflet,reverse-geocoding,react-leaflet,Javascript,Reactjs,Leaflet,Reverse Geocoding,React Leaflet,我知道LatLng,但我想检索与以下链接中的库类似的地址:,但我不知道如何将此库用于react传单2.1.2 要使用传单控制地理编码器获取地址,您需要使用如下所示的reverse方法 在渲染方法中: const height = {height: '100vh' }; const center = { lat: 51.50, lng: 0.12 }; ... <Map style={height} center={center} zoom={18} re

我知道LatLng,但我想检索与以下链接中的库类似的地址:,但我不知道如何将此库用于react传单2.1.2

要使用传单控制地理编码器获取地址,您需要使用如下所示的
reverse
方法

在渲染方法中:

const height = {height: '100vh' };
const center = { lat: 51.50, lng: 0.12 };
...
<Map 
    style={height}
    center={center} 
    zoom={18}
    ref={m => { this.leafletMap = m; }}>
    <TileLayer           
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' />
</Map>
const height={height:'100vh'};
常数中心={lat:51.50,lng:0.12};
...
{this.map=m;}}>

我建议创建一个对您的“地图对象”的引用,该对象由
react传单创建,然后按照文档中的建议使用
geocoder
。如需更多帮助,请将您的代码张贴在您使用的
react传单
是否要在自定义控件中键入地址并获取地图上的位置?我要单击地图并获取当前位置的地址
const height = {height: '100vh' };
const center = { lat: 51.50, lng: 0.12 };
...
<Map 
    style={height}
    center={center} 
    zoom={18}
    ref={m => { this.leafletMap = m; }}>
    <TileLayer           
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' />
</Map>