gpt4 book ai didi

ios - AR for iOS : show where is location (lat, 长)在屏幕上

转载 作者:行者123 更新时间:2023-11-28 20:44:29 26 4
gpt4 key购买 nike

我想制作一个在屏幕上显示位置的应用。

我将在相机图像上显示一个文本,指示用户是否在看它。例如,如果用户正在寻找位于他所在位置以北的城镇,当他向北看时,将会看到指示该城镇的文本。

我还想显示用户和位置之间的距离。

知道用户位置后,我必须向其展示用户正在寻找另一个位置。例如,我在纽约,我想知道自由女神像在哪里。我必须知道它的纬度和经度才能在用户查看时在屏幕上显示它。

有SDK吗?

您需要更多详细信息吗?对不起,我的英语说得不太好。

最佳答案

步骤应该是:

  1. 获取经纬度并设置为两个标签self.label1和self.label2

  2. 创建一个具有透明颜色背景的空 View 。

  3. 使用 addSubview: 添加您的标签到第 2 步中的 View 。

  4. 将 cameraOverlayView 设置为第 2 步中创建的 View 。

  5. 出示您的选择器。

在代码中:

在你的.h中定义:CLLocationManager *locationManager并实现委托(delegate):<CLLocationManagerDelegate>

- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; //How often do you want to update your location, this sets every small change should fire an update.
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}

然后实现:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

NSString *lat = [NSString stringWithFormat:@"%d", newLocation.coordinate.latitude];
self.label1.text = lat;

NSString *long = [NSString stringWithFormat:@"%d", newLocation.coordinate.longitude];
self.label2.text = long;
}

然后在任何你想用坐标展示你的相机的地方:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.delegate = self;

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen...

emptyView.backgroundColor = [UIColor transparentColor];
[emptyView setAlpha:1.0]; //I think it is not necessary, but it wont hurt to add this line.

self.label1.frame = CGRectMake(100, 100, self.label1.frame.size.width, self.label1.frame.size.height); //Here you can specify the position in this case 100x 100y of your label1 preserving the width and height.
[emptyView addSubview:self.label1];
//Repeat for self.label2

self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more..
[emptyView release];
[self presentModalViewController:self.picker animated:YES];
[self.picker release];

希望它足够清晰并且没有遗漏任何东西,因为我还没有对此进行测试。

关于ios - AR for iOS : show where is location (lat, 长)在屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6973214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com