返回

React native map在ios上出现问题

发布时间:2022-02-21 09:54:47 253
# edge# android# ios# git

我正在应用程序中使用react native expo。React native map在ios上没有移动、滚动等功能。其他一些组件工作不正常。它在安卓系统中运行得很好。这个问题只发生在IOS上。在Mapview中没有坐标和区域。为了使用世博会的位置,只需使用摄像头来显示位置并获取用户位置地点。getLastKnownPositionAsync()

这是ios屏幕

这是android屏幕

      const mapRef = useRef(null);
      useEffect(() => {
        if (!direction.source || !direction.destination) return;
        mapRef.current.fitToSuppliedMarkers([direction.source, direction.destination])
      }, [direction])

    useEffect(() => {
        (async () => {
          let { status } = await Location.requestForegroundPermissionsAsync()
          if (status !== 'granted') {
            setStatus('Permission to access location was denied')
            return
          } else {
            setStatus(status)
          }
          let userloc = await Location.getLastKnownPositionAsync({ accuracy: 6 })
          setLocation({ lat: userloc.coords.latitude, lng: userloc.coords.longitude })
          setCameraAngle({ center: { latitude: userloc.coords.latitude, longitude: userloc.coords.longitude }, pitch: 40, heading: 0, altitude: 10, zoom: 15 })
          // const token = await AsyncStorage.getItem('userToken')
          process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
          const token2 = await AsyncStorage.getItem('token')
          setToken(token2)
          console.log(roleId,)
          if (roleId === 1) {
            await axios({ method: "GET", url: server.getUserInformation, headers: { Authorization: `Bearer ${token2}` } })
              .then((res) => {
                const add = res.data.data.fulladdress
                setNameOfLocation(add)
              }).catch((err) => {
                console.log(err, "err in usersData")
              })
          }
)()
}, [])
         markerLoc(reg)}
                  onPress={() => { console.log("hi") }}
                >


                  {isRoute === true ? (
                     {
                        mapRef.current.fitToCoordinates(result.coordinates, {
                          edgePadding: {
                            right: (width / 20),
                            bottom: (height / 20),
                            left: (width / 20),
                            top: (height / 20),
                          }
                        })
                      }
                      }
                    />
                  ) : console.log('')}
    
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像