在世博会中,我使用的是GooglePlacesAutocomplete,我正在尝试添加当前的位置标签。这很有趣,因为在Android中,它可以使用react原生地理定位服务,但在iOS中却不这样做。
import { GooglePlacesAutocomplete } from "react-native-google-places-autocomplete";
navigator.geolocation = require("react-native-geolocation-service");
const chooseOrigin = () => {
return (
<View>
<GooglePlacesAutocomplete
placeholder="Choose origin"
fetchDetails={true}
autoFocus={true}
currentLocation={true}
currentLocationLabel="My location"
textInputProps={{
placeholderTextColor: "#ccc",
autoFocus: true,
}}
onPress={(data, details = null) => {
console.log(data, details);
}}
/>
export default chooseOrigin;添加这一行:
navigator.geolocation = require("react-native-geolocation-service");抛出此错误,但仅在iOS模拟器上:
[iOS Simulator Error][1]试着使用“@react原生社区/地理定位”(如文档说明),但在安卓和iOS模拟器上都出现了错误。更改行为:
navigator.geolocation = require('@react-native-community/geolocation');得到了一个错误:iOS和Android中的错误
还不明白我是不是遗漏了什么或者文档没有更新。请帮帮忙。
发布于 2022-08-05 19:50:02
navigator.geolocation =require(“世博地点”)为我工作过。
require('@react-native-community/geolocation') = navigator.geolocation = navigator.geolocation (“react本机地理定位-服务”)或navigator.geolocation=
需要IOS的吊舱配置。
https://stackoverflow.com/questions/70603778
复制相似问题