在 react-native-maps 中使用地址而不是经度和纬度
Using Address Instead Of Longitude And Latitude With react-native-maps
<MapView
region={latitude: 28.568806,
longitude: 173.765210,
latitudeDelta: 0.7,
longitudeDelta: 0.7}
provider={Platform.OS === 'ios' ? PROVIDER_DEFAULT : PROVIDER_GOOGLE }
>
我想提供区域地址而不是纬度和经度。
你应该使用一些东西将 lat, lng 解码为可读地址我正在使用这个库 react-native-geocoder
你可以这样 link http://maps.google.com/maps/api/geocode/json?address=
fetch('http://maps.google.com/maps/api/geocode/json?address=' + 'turkey').then(res => this.setState({region: res.result.geometry.location}));
也就是你发地址,它会return你json
<MapView
region={latitude: 28.568806,
longitude: 173.765210,
latitudeDelta: 0.7,
longitudeDelta: 0.7}
provider={Platform.OS === 'ios' ? PROVIDER_DEFAULT : PROVIDER_GOOGLE }
>
我想提供区域地址而不是纬度和经度。
你应该使用一些东西将 lat, lng 解码为可读地址我正在使用这个库 react-native-geocoder
你可以这样 link http://maps.google.com/maps/api/geocode/json?address=
fetch('http://maps.google.com/maps/api/geocode/json?address=' + 'turkey').then(res => this.setState({region: res.result.geometry.location}));
也就是你发地址,它会return你json