目前,我无法在我正在开发的应用中找到我的位置。
基本上,在Google Maps iOS SDK的文档中,Google提到您可以:
通过设置启用蓝色“我的位置”点和指南针方向 GMSMapView上的myLocationEnabled https://developers.google.com/maps/documentation/ios/map#my_location
然而,当我这样做时,我的视图中不会出现点。
这是我的设置,我有一个包含视图的视图控制器。此视图包含三个内容,两个按钮和一个地图视图:
我已将mapView与GMSMapView相关联,我可以毫无问题地查看地图。
现在,我想要的是找到它。
我尝试了两件事。首先,使用自定义草稿按钮(i获取信息),我尝试手动将位置设置为mapView,但即使locationServicesEnabled方法返回YES,这也无效。
然后,我尝试使用GoogleMaps的点,但这也不起作用。
这是我的代码:
StudyDisplayViewController.h :
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "GoogleMaps/GoogleMaps.h"
@interface StudyDisplayViewController : UIViewController <CLLocationManagerDelegate> {
}
@property (strong, readwrite) CLLocationManager *locationManager;
@property (weak, nonatomic) IBOutlet GMSMapView *mapView;
@end
StudyDisplayViewController.m
#import "StudyDisplayViewController.h"
@interface StudyDisplayViewController ()
- (IBAction)closeStudyDisplay:(id)sender;
- (IBAction)locateMe:(id)sender;
@end
@implementation StudyDisplayViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
NSLog(@"Starting the location service");
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager startMonitoringSignificantLocationChanges];
if([CLLocationManager locationServicesEnabled]) {
NSLog(@"all good");
}
else {
NSLog(@"Damn son");
}
}
self.mapView.settings.compassButton = YES;
self.mapView.myLocationEnabled = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
}
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
NSLog(@"Getting Location");
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)closeStudyDisplay:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)locateMe:(id)sender {
NSLog(@"User's location: %@", self.mapView.myLocation);
}
我正在使用Xcode 6.3.2和iOS 8.3。
答案 0 :(得分:4)
首先检查以下内容是否存在。
https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN
如果Everything在那里,如果你在Simulator上进行测试,那么尝试从调试选项卡中更改模拟器中的位置,例如将它改为任何一辆车的自由车。
另外,请检查您是否在PLIST中为 locationManager = [[CLLocationManager alloc]init];
locationManager.delegate= self;
if([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){
[locationManager requestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];
_mapView.myLocationEnabled = YES;
_mapView.settings.myLocationButton = YES;
添加了说明。