我是 Apple Watch 开发的新手,想在 Apple Watch 中集成苹果 map ,它只想显示我的当前位置,但每次我在模拟器中加载界面时,我都会得到如下所示的屏幕。任何帮助都将不胜感激。
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation* loc = [locations lastObject];
CLLocationCoordinate2D myLocationCoordinate2D = loc.coordinate;
[self.demoMap setRegion:MKCoordinateRegionMake(myLocationCoordinate2D, MKCoordinateSpanMake(0.0,0.0))];//set map region
[self.demoMap addAnnotation:myLocationCoordinate2D withPinColor:WKInterfaceMapPinColorGreen];// set pin on map
[locationManager stopUpdatingLocation];
}
#pragma mark - CLLocation Manager
-(void)startTrackingCurrentLcoation:(BOOL)forTrip
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager requestAlwaysAuthorization];
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse)
{
NSLog(@"%@ Start tracking current location", self);
[locationManager startUpdatingLocation];
}
}
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusDenied)
{
NSString *message = @"To use background location you must turn on 'Always' in the Location Services Settings";
NSLog(@"%@",message);
}
else if (status == kCLAuthorizationStatusNotDetermined)
{
[locationManager requestAlwaysAuthorization];
}
else
{
[locationManager startUpdatingLocation];
}
}
最佳答案
点击此链接 https://trymakedo.wordpress.com/tag/wkinterfacemap/ .
检查您获取传递给区域的当前位置坐标的天气。通过提供预定义坐标进行测试..
关于ios - 如何在 Apple Watch 中集成苹果 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29431370/