我正在尝试通过 UI 自动化自动化用户的路径。理想情况下,an 中的用户位置MKMapView
会根据我在自动化脚本中说明的航点列表进行更新:
var target = UIATarget.localTarget();
var waypoints = [
{location: {latitude: 37.33170, longitude: -122.03020}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03022}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03025}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03027}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03030}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03032}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03035}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03037}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03040}, options: {course: 180}}
];
for (var waypointIndex = 0; waypointIndex < waypoints.length; waypointIndex++)
{
if (waypointIndex == 0)
target.delay(5);
var waypoint = waypoints[waypointIndex];
target.setLocationWithOptions(waypoint.location, waypoint.options);
target.delay(1);
if (waypointIndex == (waypoints.length - 1))
waypointIndex = 0;
}
位置部分毫无问题地应用,并且用户的指示器沿着路径移动。但是,课程选项似乎没有做任何事情。我试过90
, 180
, -90
, 3.14
, 和1.57
作为选项的值,但无济于事。
我也尝试将speed: 8
参数添加到options
,没有任何变化。
看到这似乎是模拟标题的唯一方法,并且该course
选项完全有效并记录在案,令人沮丧的是它不起作用。
恼人的 hacky 解决方法:如果您在物理设备上模拟位置(通过 GPX 文件),设备的旋转工作。这样您就可以模拟路线并获得旋转。