我知道如何获得磁航向的坐标:heading.x,heading.y,heading.z 问题是我需要 trueHeading 的 (x, y, z) 向量。我怎样才能创建这个向量?
谢谢!
我正在尝试使用MKMapView. 我遇到了一项任务,我已经在墙上撞了很长一段时间了——当注释彼此重叠时,将它们分组到一个集群中。我可以获得两个注释之间的距离(以米为单位),但是如何获得相对于缩放级别(latitudeDelta)的距离?理想情况下,我想知道两个注释何时相互重叠,例如考虑到它们的宽度和高度为 40x40。
Apple拒绝了iBeacon应用,因为我在后台模式下检查了"位置更新".
我明确表示应用程序监控iBeacons,这也应该在后台运行.
Apple的回应:
"...您的应用程序声明支持Info.plist文件中UIBackgroundModes键的位置,但未声明任何需要持久位置的功能.声明支持Info.plist文件中UIBackgroundModes键位置的应用程序必须具有功能这需要持久的位置...."
我的印象是我需要打开"位置更新"作为后台模式,以便能够在后台监控CLBeaconRegions.是这样吗?
我正在创建一个需要用户当前时区的应用.如果正在使用的设备是iPhone并且用户将其时区设置为自动更改,我认为我可以相当确信localTimeZone或systemTimezone将为我提供用户位置的正确时区.
另一方面,如果设备是iPod Touch,则localTimeZone和systemTimeZone返回的时区似乎始终是"日期和时间"设置中设置的任何时区,无论用户的实际位置如何.我尝试使用位置服务,但是,正确提供lat/long时,我得到的timesStamp中的时区偏移量始终与用户为其时区设置设置的值相同.
有什么建议?
约翰
我收到此错误:
错误:在'CLLocation'之前预期')'
使用此代码:
@protocol MyCLControllerDelegate <NSObject>
@required
- (void)locationUpdate:(CLLocation *)location;
- (void)locationError:(NSError *)error;
@end
@interface MyCLController : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
id delegate;
}
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, assign) id <MyCLControllerDelegate> delegate;
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation;
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error;
@end
Run Code Online (Sandbox Code Playgroud)
代码,我认为很好,我认为问题是库,但我之前添加了框架但不起作用.
可能是什么问题?
我正在使用MonoTouch工作到一个iPhone项目,我需要序列化并保存一个属于ac#class的简单对象,其中CLLocation类型作为数据成员:
[Serializable]
public class MyClass
{
public MyClass (CLLocation gps_location, string location_name)
{
this.gps_location = gps_location;
this.location_name = location_name;
}
public string location_name;
public CLLocation gps_location;
}
Run Code Online (Sandbox Code Playgroud)
这是我的二进制序列化方法:
static void SaveAsBinaryFormat (object objGraph, string fileName)
{
BinaryFormatter binFormat = new BinaryFormatter ();
using (Stream fStream = new FileStream (fileName, FileMode.Create, FileAccess.Write, FileShare.None)) {
binFormat.Serialize (fStream, objGraph);
fStream.Close ();
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我执行这段代码时(myObject是上面类的一个实例):
try {
SaveAsBinaryFormat (myObject, filePath);
Console.WriteLine ("object Saved");
} catch (Exception ex) {
Console.WriteLine ("ERROR: " + ex.Message);
} …Run Code Online (Sandbox Code Playgroud) 我也陷入了困境,我正试图把一个NSString或一个NSNumber放进initWithLatitude去CLLocation.如果有人能提供帮助就会很棒.
继承人的代码
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:53.778702 longitude:-0.271887];
CLLocation *location2 = [[CLLocation alloc] initWithLatitude:53.683267 longitude:-0.011330];
label.text = [NSString stringWithFormat:@"Distance in miles: %4.1f", [location1 distanceFromLocation:location2]/1609.344];
[location1 release];
Run Code Online (Sandbox Code Playgroud)
我试图取代[[CLLocation alloc] initWithLatitude:53.778702 longitude:-0.271887]与[[CLLocation alloc] initWithLatitude:lat longitude:lon]
我正在尝试在应用程序Swift中显示我的位置,但这没有显示任何内容,地图全是蓝色..
我的代码是这个形式的互联网教程:
var latitude:CLLocationDegrees = location.location.coordinate.latitude
var longitude:CLLocationDegrees = location.location.coordinate.longitude
var homeLati: CLLocationDegrees = 40.01540192
var homeLong: CLLocationDegrees = 20.87901079
var latDelta:CLLocationDegrees = 0.01
var longDelta:CLLocationDegrees = 0.01
var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
var myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span)
self.mapKit.setRegion(region, animated: true)
self.mapKit.showsUserLocation = true
///Red Pin
var myHomePin = MKPointAnnotation()
myHomePin.coordinate = myHome
myHomePin.title = "Home"
myHomePin.subtitle = "Bogdan's home"
self.mapKit.addAnnotation(myHomePin)
Run Code Online (Sandbox Code Playgroud)
我在.split中导入了相应的配置..这段代码有什么不好的?
谢谢!
我在我的方法didUpdateLocations中获得用户的经度和经度.如果允许位置,我调用一个接受纬度,经度参数并调用webservice的方法,否则我会显示一个UIAlertView.
问题是:iOS随机调用我的locationManager委托方法.所以我的网络服务被多次调用......我该如何解决?
当我呼叫该位置时,验证是否允许...我在上一个屏幕中发出请求:
// GET LOCATION
self.initializeWaitingScreen()
if( CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse ||
CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedAlways){
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.startUpdatingLocation()
} else {
let loginFailAlert: UIAlertView = UIAlertView(title: "Localisation refusée", message: "Vos fonctionnalités sont restreintes, pour accéder à l'application complète, veuillez activer la localisation", delegate: self, cancelButtonTitle: "OK")
loginFailAlert.show()
self.initializeUIComponent()
self.initializeDataWithWebServiceWithoutLocation()
}
Run Code Online (Sandbox Code Playgroud)
我的locationManager方法:
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
var lon = manager.location.coordinate.longitude.description
var lat = manager.location.coordinate.latitude.description
self.locationManager.stopUpdatingLocation()
self.initializeDataWithWebServiceWithLocation(lon, _lat: lat)
self.initializeUIComponent()
}
Run Code Online (Sandbox Code Playgroud)
self.initializeDataWithWebServiceWithLocation(lon, _lat: lat)
取经度和纬度,并将其交给我调用webservices的方法.
这是我的代码
if loc.latitude != 0.0 && loc.longitude != 0.0 {
let loca = CLLocation(latitude: loc.latitude, longitude: loc.longitude)
geoCoder.reverseGeocodeLocation(loca) { (placemarks, error) in // this is the last line that is being called
var placemark : CLPlacemark!
placemark = placemarks?[0]
city = (placemark.addressDictionary?["City"] as! String)
}
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中执行此代码段是正确的,没有发生运行时错误.
但是,被调用的最后一行是
geoCoder.reverseGeocodeLocation(loca){(placemarks, error)
我也仔细检查过那loca不是零.
为什么没有调用完成处理程序?
cllocation ×10
ios ×7
iphone ×4
mapkit ×3
swift ×3
objective-c ×2
cocoa-touch ×1
coordinates ×1
heading ×1
serializable ×1
swift3 ×1
timezone ×1
vector ×1
xamarin.ios ×1
xcode ×1