[英]using google maps api, how to get country, state, and city from lat and long?
I my react app, i am using the libraries @react-google-maps/api
and react-places-autocomplete
.我是我的 React 应用程序,我正在使用库
@react-google-maps/api
和react-places-autocomplete
。
How do I get the country, state, city given lat and long coordinates?我如何获得国家,state,给定纬度和经度坐标的城市?
How to get the formatted address, place, give lat and long?如何获取格式化的地址、地点、经纬度?
npm install --save react-native-geocoding
npm 安装 --save react-native-geocoding
import Geocoder from 'react-native-geocoding';
从“react-native-geocoding”导入地理编码器;
Geocoder.from(41.89, 12.49).then(json => { var addressComponent = >json.results[0].address_components[0];
Geocoder.from(41.89, 12.49).then(json => { var addressComponent =>json.results[0].address_components[0];
console.log(addressComponent);
控制台日志(地址组件); }).catch(error => console.warn(error));
}).catch(error => console.warn(error)); // location object Geocoder.from({ latitude: 41.89, longitude: 12.49 });
// 位置 object Geocoder.from({ latitude: 41.89, longitude: 12.49 });
// latlng object Geocoder.from({ lat: 41.89, lng: 12.49 }); // array Geocoder.from([41.89, 12.49]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.