cllocation

How to store CLLocation using Core Data (iPhone)?

北战南征 提交于 2019-12-03 00:47:52
问题 I'm trying to save a location and retrieve the location on a map afterward using Core Location, MapKit and Core Data frameworks. What I've done is I just made entity named POI and added properties such as latitude (double type), longitude (double type) with few others. Simply put, my app saves POI with two NSNumbers. (lat and long) but I feel like there must be a smarter way to store CLLocation than that. cheers. 回答1: What you're doing is fine. You should save the latitude and longitude as

CLLocationCoordinate2D without knowing how many will be in the array?

不问归期 提交于 2019-12-03 00:17:25
I need to build an array using something like the following: CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981); points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267); Problem is, I will never know how many items are going to be in the array, so I can specify the count. Is there a way to create a CLLocationCoordinate2D array, and just insert new coordinates without knowing what the final total will be? EDIT: My

String to CLLocation latitude and Longitude

泄露秘密 提交于 2019-12-02 17:36:33
I have two strings representing latitude and longitude like: "-56.6462520", and i want to assign then to a CLLocation object to compare to my current location.I tried the following code but i get errors only: CLLocation * LocationAtual = [[CLLocation alloc]init]; LocationAtual.coordinate.latitude = @"-56.6462520"; LocationAtual.coordinate.longitude = @"-36.6462520"; and then compare the object with my actual location latitude and longitude. Any suggestions? I think you need to: LocationAtual.coordinate.latitude = [@"-56.6462520" floatValue]; LocationAtual.coordinate.longitude = [@"-36.6462520"

How to store CLLocation using Core Data (iPhone)?

点点圈 提交于 2019-12-02 14:15:03
I'm trying to save a location and retrieve the location on a map afterward using Core Location, MapKit and Core Data frameworks. What I've done is I just made entity named POI and added properties such as latitude (double type), longitude (double type) with few others. Simply put, my app saves POI with two NSNumbers. (lat and long) but I feel like there must be a smarter way to store CLLocation than that. cheers. What you're doing is fine. You should save the latitude and longitude as doubles in Core Data. When you need to get the information again, get the doubles back from Core Data and

Save a CLLocationCooridnate2D array in Firestore

别来无恙 提交于 2019-12-02 13:29:30
I'm trying to save a CLLocationCoordinate2D array into Firestore, but I'm getting error: 'FIRInvalidArgumentException', reason: 'Unsupported type: NSConcreteValue' And I don't really know how I can perform this. In the top of the code I've this: var locations: [CLLocationCoordinate2D] = [] And down in the 'save' button. I've this code: //Document Reference properties var _: DocumentReference = self.db //Collection into Subcollection & Documents .collection("rastad").document(authentication!) .collection("promenad").addDocument(data: //Insert first values ["Dog": txtfield_dog.text!, "Person":

MapKit giving wrong lat & lang - iOS 8

旧街凉风 提交于 2019-12-02 13:01:22
When I try to use map in iOS 8, I get below error. Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first. For this I tried solution from here , but still no luck. Below is what I did. Step 1. Have entry in Info.plist NSLocationWhenInUseUsageDescription - This is test text Step 2. Updated -(CLLocationCoordinate2D) getLocation -(CLLocationCoordinate2D) getLocation{ CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease];

How To Call a func within a Closure

狂风中的少年 提交于 2019-12-02 09:58:43
In a model's class Location , I get the name of the current city: var currentLatitude: Double! var currentLongitude: Double! var currentLocation: String! var currentCity: String! func getLocationName() { let geoCoder = CLGeocoder() let location = CLLocation(latitude: currentLatitude, longitude: currentLongitude) geoCoder.reverseGeocodeLocation(location, completionHandler: { placemarks, error in guard let addressDict = placemarks?[0].addressDictionary else { return } if let city = addressDict["City"] as? String { self.currentCity = city print(city) } if let zip = addressDict["ZIP"] as? String {

Does the internal GPS antenas stop working immediately after calling CLLocationManager stopUpdatingLocation

半世苍凉 提交于 2019-12-02 09:45:19
Here is my scenario. In my app there is no need of continuously monitoring user location, but I need the location to be as accurate as possible. So I just call CLLocationManager startUpdatingLocation with kCLLocationAccuracyBestForNavigation set as desiredAccuracy, and after I get the location with my desired accuracy (by comparing newLocation.horizontalAccuracy with predefined value) I want to stop the location update and revoke update again after several seconds. But when I call stopUpdatingLocation the location icon from status bar disappears after about 10 seconds, does this mean that

Accessing Variables outside of a function in swift

与世无争的帅哥 提交于 2019-12-02 04:17:06
问题 Im getting coordinates from , but I'd like to be able to use them outside the Location Manager Function. Is it possible to make them instance variables? If so, could someone give me some example code for that? In the code below I print within the func and it works, but I'd like to be able to, for example print outside it, and otherwise use the coordinates. Perhaps as a global variable? How would i code that? I cant quite make it out from the documentation. import UIKit import CoreLocation

Accessing Variables outside of a function in swift

老子叫甜甜 提交于 2019-12-02 01:41:05
Im getting coordinates from , but I'd like to be able to use them outside the Location Manager Function. Is it possible to make them instance variables? If so, could someone give me some example code for that? In the code below I print within the func and it works, but I'd like to be able to, for example print outside it, and otherwise use the coordinates. Perhaps as a global variable? How would i code that? I cant quite make it out from the documentation. import UIKit import CoreLocation import MapKit class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate { var