草庐IT

CLLocation2DCoordinates

全部标签

ios - 单点触控 : How to serialize a type (like CLLocation) not marked as Serializable?

我正在使用MonoTouch处理一个iPhone项目,我需要序列化并保存一个属于C#类的简单对象,并将CLLocation类型作为数据成员:[Serializable]publicclassMyClass{publicMyClass(CLLocationgps_location,stringlocation_name){this.gps_location=gps_location;this.location_name=location_name;}publicstringlocation_name;publicCLLocationgps_location;}这是我的二进制序列化方法:s

iphone - 如何在应用程序启动之间保留 CLLocation?

我想在应用程序启动之间保留2个CLLocation。这是我希望在两次启动之间存储在内存中的唯一数据。我该怎么做呢?CLLocation是否有writetofile或将其存储在coredata或NSUserDefaults中?我想存储整个CLLocation对象,不想只存储纬度/经度然后进行更多计算等。谢谢 最佳答案 查看文档,我看到CLLocation实现了NSCoding协议(protocol)。这意味着您可以使用NSKeyedArchiver和archive和unarchiveCLLocation实例NSKeyedUnarchi

ios - CLLocation 没有给出实际速度

这是我的位置管理器委托(delegate)代码。当我们使用汽车移动时,它不会给出速度,所以至少速度值应该改变。它总是给出常量值-1.00。-(void)locationManager:(CLLocationManager*)managerdidUpdateLocations:(NSArray*)locations{CLLocation*crnLoc=[locationslastObject];self.speedometerCurrentValue=crnLoc.speed;self.lblSpeed.text=[NSStringstringWithFormat:@"%f",crnLo

ios - 未调用 CLLocation 管理器 didStartMonitoringForRegion 委托(delegate)方法

我正在尝试在我的应用程序中使用位置监控。我可以设置我的位置和reverseGeocode我想监控的位置。didUpdateToLocation委托(delegate)方法工作正常,并不断更新,但didStartMonitoingForRegion委托(delegate)永远不会被调用,didExitRegion和didEnterRegion.有什么建议吗?-(IBAction)setLocation:(UIButton*)sender{if(!self.locationManager)self.locationManager=[[CLLocationManageralloc]init]

objective-c - 将 CLLocation 保存到 plist

我正在努力将几个位置保存到一个plist文件中以备后用,经过一番谷歌搜索后,我发现CLLocation数组本身无法保存,所以我想知道一种方法。我正在考虑几个类来将单个CLLocation对象“序列化”/“反序列化”到NSDictionary中,然后将这些NSDictionaries的数组存储到plist文件中,但我想知道是否有更好的/实现这一目标的更智能/可靠的方式。提前致谢。编辑:这是我用来将数据保存在plist中的函数(c_propertyName从答案中获取代码)-(void)addLocation{NSArray*paths=NSSearchPathForDirectories

ios - 使用 CLLocation 计算距离 iOS MapKit

我正在尝试使用纬度和经度查找以英里为单位的距离。我有以下方法:-(void)locationManager:(CLLocationManager*)managerdidUpdateToLocation:(CLLocation*)newLocationfromLocation:(CLLocation*)oldLocation{if(!newLocation)return;if((oldLocation.coordinate.latitude!=newLocation.coordinate.latitude)&&(oldLocation.coordinate.longitude!=newL

iOS CLLocation - 获取 ViewDidLoad 上的位置

这可能是我遗漏的一些简单的东西,但我已经设置了位置服务(为清楚起见缩短):-(void)viewDidLoad{self.locationManager=[[[CLLocationManageralloc]init]autorelease];self.locationManager.delegate=self;[self.locationManagerstartUpdatingLocation];}-(void)locationManager:(CLLocationManager*)managerdidUpdateToLocation:(CLLocation*)newLocationf

ios - -distanceFromLocation : 中 CLLocation 对象的顺序

这是我第一次在这里发布问题,但我从其他人的问题中找到了很多帮助。我的问题是指CLLocation中的-distanceFromLocation:函数。我原以为找到A点和B点之间的距离与B点和A点之间的距离相同,但我发现事实并非如此。我已经在一个非常简单的案例中对此进行了测试:CLLocation*test1=[[CLLocationalloc]initWithLatitude:37.529530longitude:-122.259232];CLLocation*test2=[[CLLocationalloc]initWithLatitude:47.900002longitude:-10

ios - 在 objective-c 中创建 CLLocation 对象

我可以通过提供纬度和经度来初始化一个CLLocation对象,如下所示:CLLocation*location=[[CLLocationalloc]initWithLatitude:-43.242534longitude:-54.93662];如何初始化一个CLLocation对象,不仅有纬度和经度,还有精度值? 最佳答案 根据苹果docs您可以使用以下功能:doubledesired_horizontal_accuracy=200.0//inmetersdoubledesired_vertical_accuracy=200.0//

ios - 使用 CLLocation 计算两个坐标之间的距离

我正在使用CLLocationDistance获取两点之间的距离,但在其中传递我的当前位置时出现错误。CLLocation*current=[[CLLocationalloc]initWithLatitude:startLocation.coordinate.latitudelongitude:startLocation.coordinate.longitude];CLLocation*itemLoc=[[CLLocationalloc]initWithLatitude:[[[getNameobjectAtIndex:indexPath.row]objectForKey:@"lat"]