使用Estimote室内导航IOS

时间:2015-10-19 09:52:12

标签: ios iphone ios8 estimote indoor-positioning-system

我已经集成了Estimate室内定位系统,但我无法将用户路由到特定位置。任何帮助表示赞赏。

#import "DirectMeViewController.h"
#import "ESTIndoorLocationManager.h"
#import "ESTLocationBuilder.h"
#import "ESTIndoorLocationView.h"
#import "ESTPositionView.h"
#import "ESTConfig.h"


@interface DirectMeViewController ()<ESTIndoorLocationManagerDelegate>
@property (nonatomic, strong) ESTIndoorLocationManager *manager;
@property (nonatomic, strong) ESTLocation *location;
@property (nonatomic, strong) ESTPositionView *positionView;
- (IBAction)closeBtnAction:(id)sender;

@end

@implementation DirectMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *path = [[NSBundle mainBundle] pathForResource:@"location" ofType:@"json"];
    NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

    // location.json file got from estimote indoor location app

    ESTLocation *location = [ESTLocationBuilder parseFromJSON:content];

    self.manager = [[ESTIndoorLocationManager alloc] init];
    self.manager.delegate = self;

    self.location = location;


}
-(void)viewWillAppear:(BOOL)animated
{
    self.locationView.backgroundColor = [UIColor clearColor];

    self.locationView.showTrace               = NO;
    self.locationView.rotateOnPositionUpdate  = NO;

    self.locationView.showWallLengthLabels    = YES;

    self.locationView.locationBorderColor     = [UIColor blackColor];
    self.locationView.locationBorderThickness = 6;
    self.locationView.doorColor               = [UIColor brownColor];
    self.locationView.doorThickness           = 5;
    self.locationView.traceColor              = [UIColor blackColor];
    self.locationView.traceThickness          = 2;
    self.locationView.wallLengthLabelsColor   = [UIColor yellowColor];


    [self.locationView drawLocation:self.location];


    // You can use positionView with set avatar to visualize accuracy circle.
    self.positionView = [[ESTPositionView alloc] initWithImage:[UIImage imageNamed:@"navigation_guy"] location:self.location forViewWithBounds:self.locationView.bounds];
    self.positionView.hidden = YES;
    self.locationView.positionView = self.positionView;

    self.positionLabel.hidden = NO;


    self.locationView.positionImage = [UIImage imageNamed:@"navigation_guy.png"];

    [self.manager startIndoorLocation:self.location];

}
- (void)viewWillDisappear:(BOOL)animated
{
    [self.manager stopIndoorLocation];
    [super viewWillDisappear:animated];
}

- (void)indoorLocationManager:(ESTIndoorLocationManager *)manager
            didUpdatePosition:(ESTOrientedPoint *)position
                 withAccuracy:(ESTPositionAccuracy)positionAccuracy
                   inLocation:(ESTLocation *)location
{
    self.positionLabel.text = [NSString stringWithFormat:@"x: %.2f  y: %.2f   α: %.2f ",
                               position.x,
                               position.y,
                               position.orientation];
    [self.positionView updateAccuracy:positionAccuracy];
    [self.locationView updatePosition:position];
}

- (void)indoorLocationManager:(ESTIndoorLocationManager *)manager didFailToUpdatePositionWithError:(NSError *)error
{
    if (error.code == ESTIndoorPositionOutsideLocationError)
    {
        self.positionLabel.text = @"It seems you are not in this location.";
    }
    else if (error.code == ESTIndoorMagnetometerInitializationError)
    {
        self.positionLabel.text = @"It seems your magnetometer is not working.";
    }
    NSLog(@"%@", error.localizedDescription);
}

上面的代码显示了如何使用信标跟踪用户位置。但我不知道如何将用户路由到特定的POI。

0 个答案:

没有答案