React Native 使用iOS模拟器在expo应用程序上使用gpx文件模拟位置

a6b3iqyw  于 2023-01-18  发布在  React
关注(0)|答案(3)|浏览(163)

我想在iOS模拟器中输入一个gpx文件来模拟一条路线沿着的驾驶。但是,为了做到这一点,我需要在我的xcode项目中添加一个gpx文件。我使用的项目是用expo创建的,所以我无法在xcode中打开它。有没有什么变通方案可以在不打开xcode的情况下模拟路线?

ibps3vxo

ibps3vxo1#

可以通过set-simulator-location等工具在模拟器级别完成模拟位置
只需使用brew install lyft/formulae/set-simulator-location安装即可
然后设置模拟器位置:set-simulator-location -q Expo 624 University Ave Palo Alto CA(设置为世博办公室)。

9bfwbjaz

9bfwbjaz2#

最后我用set-simulator-location-trip-simulator解决了我的问题,这是一个用set-simulator-location构建的工具,它允许你选择起点和终点,并模拟从起点到终点的旅程,但是它不允许使用gpx文件。

rta7y2nd

rta7y2nd3#

由于Xcode 14 simctl提供了设置模拟器位置的可能性:

$ xcrun simctl location
Control a device's simulated location
Usage: simctl location <device> <action> [arguments]

    list
        List available simulation scenarios.

    clear
        Stop any running scenario and clear any simulated location.

    set <lat1>,<lon1>
        Set the location to a specific latitude and longitude.

    run <scenario>
        Run a simulated location scenario (use the list action to get a list of scenarios).

    start [--speed=<meters/sec>] [--distance=<meters per second>|--interval=<seconds>] <lat1>,<lon1> <latN>,<lonN>...
        Set the location to a series of waypoints specified as 'lat,lon' pairs, interpolating between them over time.
        At least two waypoints are required. Use '-' to read waypoints from stdin, one waypoint per line.

        Speed specifies how quickly to move between waypoints in meters per second. If not specified 20m/s is used.

        The system will issue location updates along the path between each pair of waypoints. Use distance or interval to 
        control how often those updates are issued. Distance will issue an update every <meters> travelled without regard
        for the time between updates. Interval will issue updates at fixed times without regard for how much
        the location moves between updates.
        If neither are specified an interval of 1.0 seconds is used. If both are specified the system picks ones.

        Example simulating a direct line between San Francisco and New York City, with updates every km:
          set --distance=1000 --speed=260 37.629538,-122.395733 40.628083,-73.768254

Latitude and longitude pairs must be specified using '.' as the decimal separator and ',' as the field separator.

要在gpx文件中使用它,您需要某种 Package 器来生成如下所示的命令(注意可能有N个坐标):

xcrun simctl location "iPhone 14 Pro" start 37.629538,-122.395733 40.628083,-73.768254

从我的研究来看,这提供了比我发现的所有其他工具多得多的功能,并且上级lyft/formulae/set-simulator-location

相关问题