我正在尝试通过UI自动化来自动化用户的路径。理想情况下,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;
}
位置部分毫无问题地适用,并且用户指示符沿路径移动。但是,类(class)选项似乎没有任何作用。我尝试将
90
,180
,-90
,3.14
和1.57
作为选项的值,但没有用。我也尝试将
speed: 8
参数添加到options
中,没有任何变化。看起来好像是only way to simulate headings at all和
course
option is totally valid and documented,令人沮丧的是它不起作用。烦人的hacky解决方法:如果您在物理设备上模拟位置(通过GPX文件),则设备的旋转可以工作。这样,您可以模拟路线并获得旋转。
最佳答案
像这样的坐标在仪器中为我工作:
{location:{longitude:2.105528,latitude:41.414359}, options:{speed:20, course: 290, altitude:200, horizontalAccuracy:10, verticalAccuracy:15}}
尝试水平和垂直精度,甚至海拔高度。
祝你好运!