简体   繁体   English

如何跟踪Facebook当前用户的位置IOS / Android

[英]How to track facebook current user's location IOS/Android

Is there any way I can track a facebook's user's location in real time who is logged in my mobile app and has location services enabled and also has granted access to my app so as to make use of its location? 有什么方法可以实时跟踪已登录我的移动应用程序并启用了位置服务并且还授予对我的应用程序的访问权限以利用其位置的Facebook用户的位置?

  1. Assuming a user X, and 3 linear points in space: A,B,C. 假设用户X,并且在空间中有3个线性点:A,B,C。 X is traveling from A to C. X从A到C。

  2. Is there an SDK that would enable me to check X's real time location ( latitude + longitude ) at any given time while X is moving from A to C so as to create a dotted map(by dropping a pin on the map) with the user's location at every 10ms? 是否有一个SDK,可以让我在X从A移到C的任何给定时间检查X的实时位置(纬度+经度),从而创建一个点状地图(通过在地图上放置图钉)与用户每10毫秒定位一次?

  3. Is this feasible given the fact that my device has a 4G internet connection? 考虑到我的设备具有4G互联网连接,这是否可行?

I think you can use CLLocationManager to update user location after traveling a number of meters. 我认为您可以在行驶多米后使用CLLocationManager更新用户位置。 I presume you are already having a CLLocationManager to update your location? 我想您已经有了一个CLLocationManager来更新您的位置? you can save the dots in an array (starting with the location of A, ending with location of C). 您可以将点保存在数组中(从A的位置开始,以C的位置结束)。 You can then draw a line using the dots. 然后,您可以使用点画一条线。 I believe Google Map API has a method for drawing line. 我相信Google Map API有画线的方法。 There's an answer for that here: 这里有一个答案:

Here is a link from SO 这是SO的链接

But for the sake of providing code, I will provide it for you in Swift 3.0 (the code in the link is in ObjC): 但是为了提供代码,我将在Swift 3.0中为您提供(链接中的代码在ObjC中):

override func viewDidLoad() {
    super.viewDidLoad()
    //This is a dummy location, you'd add locations to it using the 
    //  func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
    let location:CLLocation = CLLocation(latitude: 200, longitude: 100)
    let locationArray:Array<CLLocation> = [location]
    let camera:GMSCameraPosition = GMSCameraPosition.camera(withLatitude: (locationArray.first?.coordinate.latitude)!, longitude: (locationArray.first?.coordinate.longitude)!, zoom: 2)
    //You can obtain the Lat and Long for above from the list of arrays of locations you saved
    //You can use the .first or .last on the array (I used first)

    let mapview:GMSMapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)

    let path:GMSMutablePath = GMSMutablePath()
    for nextLocation in locationArray {
        if locationArray.index(of: nextLocation) != 0 {
            //You dont want to use the first one as you've already done it
            //so you start with 1
            path.addLatitude(nextLocation.coordinate.latitude, longitude: nextLocation.coordinate.longitude)
        }
    }

    let polyline:GMSPolyline = GMSPolyline(path: path)
    polyline.strokeColor = UIColor.red
    polyline.strokeWidth = 2
    polyline.map = mapview
    self.view = mapview

    //I personally prefer view.addSubview(mapview)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何跟踪android应用程序用户的位置 - How to track the android application user's location 如何在地图上跟踪和显示用户的位置 - How to track and display user's location on a map Android Maps-如何将地图自动居中到用户的当前位置? - Android Maps - how to automatically center the map to the user's current location? 如何在android / ios下使用delphi应用程序全时跟踪用户位置 - How to track the user location at full time with a delphi app under android/ios 如何使用新的架构组件在android中跟踪当前位置? - How to track current location in android with new architecture components? Android 如何跟踪其他用户的当前位置 Parse.com - Android How to track other users' current location Parse.com 无论用户位置设置如何,如何确定Android设备的当前国家/地区位置? - How to determine an Android device's current country location regardless of user location settings? 如何使用Phonegap跟踪设备位置(iOS和Android)设备 - How to track the device location (iOS and Android) device using Phonegap 如何在Android的IntentService中获取用户的当前位置? - how to get current location of user in IntentService in Android? 在Android中使用GPS获取用户的当前位置 - getting user's current location using GPS in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM