cllocation

reverseGeocodeLocation Only Executes Completion Block Once

隐身守侯 提交于 2021-01-28 13:38:14
问题 I have an array of coordinates that I step through with a for loop. I would like to place annotations on a map for each location and have the subtitle for the callout be the address of the coordinate, found by using reverseGeocodeLocation In the for loop, I call the reverseGeocodeLocation method, and inside the completion block I create the annotation and display it on the map. However, when I run the app, only one annotation shows up. I went in the debugger, and the completion block is only

How can I return a CLLocation value in swift? [duplicate]

佐手、 提交于 2020-05-14 14:13:05
问题 This question already has answers here : Returning data from async call in Swift function (12 answers) Closed 2 days ago . I am trying to create function which can return CLLocation value? As this is asynch method it gives value after some time and return get called before that. is there any way to return after getting lat, lon? func setLocation(location: String) -> [String]{ var lat: CLLocationDegrees? var lon: CLLocationDegrees? geocoder.geocodeAddressString(location) { placemarks, error in

How to get Current Location with SwiftUI?

﹥>﹥吖頭↗ 提交于 2020-01-22 19:37:10
问题 Trying to get current location with using swiftUI. Below code, couldn't initialize with didUpdateLocations delegate. class GetLocation : BindableObject { var didChange = PassthroughSubject<GetLocation,Never>() var location : CLLocation { didSet { didChange.send(self) } } init() {} } 回答1: This code below works (Not production ready). Implementing the CLLocationManagerDelegate works fine and the lastKnownLocation is updated accordingly. Don't forget to set the

Set annotation's title as current address

一曲冷凌霜 提交于 2020-01-21 18:08:42
问题 I want to get the current location's address and set it to the annotation's title. But it didn't work. I think it's because of the block, but I don't know how to fix it. Any help will be appreciated. The most related code is as following: WhereAmIAnnotation.h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface WhereAmIAnnotation : NSObject <MKAnnotation> { CLLocation *myLocation; NSString *addr; } @property (nonatomic, retain) CLLocation *myLocation; @property (nonatomic,

Create MKPolyline with only recent CLLocations

匆匆过客 提交于 2020-01-15 19:18:26
问题 My app loads the user's past polylines and displays them on the map. Then the app starts tracking and a straight line is drawn from the last updated coordinate to the first, thereby connecting the two separate lines when they should be separate (shown here I want to remove this straight line, so I'm thinking the easiest way would be to discard coordinates that are outside a set time frame (e.g 1 minute), so polylines on the map remain separate. I'm not sure how to do this though... I'm a

Create MKPolyline with only recent CLLocations

依然范特西╮ 提交于 2020-01-15 19:17:54
问题 My app loads the user's past polylines and displays them on the map. Then the app starts tracking and a straight line is drawn from the last updated coordinate to the first, thereby connecting the two separate lines when they should be separate (shown here I want to remove this straight line, so I'm thinking the easiest way would be to discard coordinates that are outside a set time frame (e.g 1 minute), so polylines on the map remain separate. I'm not sure how to do this though... I'm a

UITableView doesn't populate when waiting for CLLocationManagerDelegate 's didUpdateToLocation method on iPhone SDK

房东的猫 提交于 2020-01-15 14:09:25
问题 I'm trying to populate a UITableview with an array of cells. I usually do this from the viewDidLoad method but this time I want to populate the array based on location. Below is the first line of my interface: @interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource, CLLocationManagerDelegate> { In the implementation file the viewDidLoad method looks like this: - (void)viewDidLoad { // for location self.locationManager = [[CLLocationManager alloc] init

Order of CLLocation objects in -distanceFromLocation:

半城伤御伤魂 提交于 2020-01-03 11:49:00
问题 This is my first time posting a question here, but I have found a lot of help from other people's questions. My question refers to the -distanceFromLocation: function in CLLocation . I had assumed that finding the distance between point A and point B would be the same as that between point B and point A, but I have found that it is not. I have tested this in a very simple case: CLLocation *test1 = [[CLLocation alloc] initWithLatitude:37.529530 longitude:-122.259232]; CLLocation *test2 = [