【发布时间】:2015-12-03 07:26:45
【问题描述】:
我正在尝试使用来自 json 服务器的坐标显示标记。
我正在使用此代码获取坐标:
let query = PFQuery(className:"locations")
query.findObjectsInBackgroundWithBlock {
(objects:[PFObject]?, error:NSError?) -> Void in
if error == nil {
for object in objects! {
self.long = object["longitude"] as! Double
self.lat = object["latitude"] as! Double
print(self.lat, self.long)
}
} else {
print(error)
}
}
我从 print(self.lat, self.long)
得到这个结果39.570355 2.679148
39.570364 2.687386
39.569988 2.691598
39.569756 2.695900
我用它在地图上显示它:
marker.position = CLLocationCoordinate2DMake(self.lat, self.long)
现在我想循环这个结果并首先在地图上显示第一行坐标,当我触摸一个按钮时,我希望它显示下一行。这在某种程度上可能吗?我不知道该怎么做。
【问题讨论】:
-
将坐标保存到数组中并为其设置索引,然后在按钮操作中,从数组中获取索引处的坐标并添加标记 - 哦并增加索引。
-
好吧,我会试试的。
标签: ios json xcode swift google-maps