0
我正在尝试制作一个应用程序,每个人都可以在同一个地图上看到每个人的位置。我找不到关于如何在同一张地图上检索所有用户位置的教程。Swift GeoPoint获取所有用户的位置ios
我必须设法使一个脚本,这个脚本上传用户的位置成解析:
PFGeoPoint.geoPointForCurrentLocationInBackground {
(geoPoint: PFGeoPoint?, Error : NSError?) -> Void in
if let geoPoint = geoPoint{
PFUser.currentUser()? ["location"] = geoPoint
PFUser.currentUser()?.saveInBackground()
我也设法获取当前用户的位置。
任何人都知道我如何显示每个人的位置,不只是我的?
谢谢你的时间和帮助。我对Swift很陌生,所以让我知道我是否需要提供更多信息。
这是我的显示代码。
PFGeoPoint.geoPointForCurrentLocationInBackground {
(geoPoint: PFGeoPoint?, Error : NSError?) -> Void in
if let geoPoint = geoPoint{
PFUser.currentUser()? ["location"] = geoPoint
PFUser.currentUser()?.saveInBackground()
self.MapView?.showsUserLocation = true
self.MapView?.delegate = self
MapViewLocationManager.delegate = self
MapViewLocationManager.startUpdatingLocation()
self.MapView?.setUserTrackingMode(MKUserTrackingMode.Follow, animated: false)
self.locationManager.requestAlwaysAuthorization()
self.locationManager.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled(){
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocationManager]){
var locValue:CLLocationCoordinate2D = (manager.location?.coordinate)!
print("locations = \(locValue.latitude) \(locValue.longitude)")
外ViewWDidLoad
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1))
self.MapView?.setRegion(region, animated: true)
self.locationManager.stopUpdatingLocation()
}
谁是“大家”?你的应用的其他用户? – Moritz
是的。其他成员。 –
那么这不就是如何从Parse API获取所有用户的问题吗?这不是在他们的文档中的某处吗?我试图了解你的问题的实际性质。目前这个问题似乎对于SO非常广泛和模糊。 :) – Moritz