如何将Apple Map整合到Apple Watch中?

希拉格·莎(Chirag Shah)

我是Apple Watch开发的新手,想将Apple Map集成到Apple Watch中,只是想显示我的当前位置,但是每次我在模拟器中加载界面时,都会得到如下所示的屏幕。任何帮助都将不胜感激。

在此处输入图片说明

   -(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/

检查天气,获取传递到区域的当前位置坐标。通过提供预定义的坐标进行测试。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章