2017-07-27 39 views
0

嗨,夥計們,室內地圖 - 如何使用iBeacons手動設置跟蹤用戶的位置和方向?

我正在創建一個演示項目來跟蹤用戶在室內區域的位置並使用Estimote Proximity Beacons顯示實時跟蹤。和SDK使用Estimote室內位置sdk。但我被困在一點。

SDK委託函數總是發送響應錯誤,並且錯誤是: 無法確定位置

在這裏,我代表我的代碼和功能以我在我的演示使用,所以請任何一個有想法突出位置在此請建議我在哪個點我可以犯錯,所以我會解決並實施正確的解決方案。請給我建議,並在此先感謝...

let beaconManager = ESTBeaconManager() 
let locationManager = EILIndoorLocationManager() 
var location = EILLocation() 
let locationBuilder = EILLocationBuilder() 
var positionView = EILPositionView() 
var position = EILOrientedPoint() 

override func viewDidLoad() { 
    super.viewDidLoad() 

    self.beaconManager.delegate = self 
    self.beaconManager.requestAlwaysAuthorization() 

    // TODO: put your App ID and App Token here 

    ESTConfig.setupAppID("Id i am use Registed Estimote Id", andAppToken: "Token also use provided by register app on Estimote") 
    ESTConfig.isAuthorized() 

    locationBuilder.setLocationName("DCX Retail Store") 
    locationBuilder.setLocationBoundaryPoints([ 
     EILPoint(x: 0.00, y: 0.00), 
     EILPoint(x: 0.00, y: 1.00), 
     EILPoint(x: 1.00, y: 1.00), 
     EILPoint(x: 1.00, y: 0.00)]) 

    locationBuilder.addBeacon(withIdentifier: "B9407F30-F5F8-466E-AFF9-255556B57FE6D", withPosition:EILOrientedPoint.init(x: 0.00, y: 0.00), andColor: ESTColor.blueberryPie) 
    locationBuilder.addBeacon(withIdentifier: "B9407F30-F5F8-466E-AFF9-255556B57FE6D", withPosition:EILOrientedPoint.init(x: 0.00, y: 1.00), andColor: ESTColor.mintCocktail) 
    locationBuilder.addBeacon(withIdentifier: "B9407F30-F5F8-466E-AFF9-255556B57FE6D", withPosition:EILOrientedPoint.init(x: 1.00, y: 1.00), andColor: ESTColor.icyMarshmallow) 
    locationBuilder.addBeacon(withIdentifier: "B9407F30-F5F8-466E-AFF9-255556B57FE6D", withPosition:EILOrientedPoint.init(x: 1.00, y: 0.00), andColor: ESTColor.blueberryPie) 

    // Add door in Indoor area... 

    locationBuilder.addDoors(withLength: 0.3, atBoundarySegmentIndex: 0, inDistance: 0.7, from: .rightSide) 

    locationBuilder.setLocationOrientation(0) 

    //set up location... 
    self.location.randomPointInside() 
    location = locationBuilder.build()! 

    // Set the location manager's delegate 

    self.locationManager.delegate = self 
    self.locationManager.start() 
    self.locationManager.state(for: self.location) 
    self.locationManager.mode = EILIndoorLocationManagerMode.light 

    self.locationView.showTrace = true 
    self.locationView.showWallLengthLabels = true 
    self.locationView.rotateOnPositionUpdate = true 

    self.locationView.locationBorderColor = UIColor.black 
    self.locationView.locationBorderThickness = 2 

    self.locationView.doorColor = UIColor.green 
    self.locationView.doorThickness = 2 
    self.locationView.traceColor = UIColor.yellow 
    self.locationView.traceThickness = 2 

    self.locationView.wallLengthLabelsColor = UIColor.blue 

    //Start Location Drawing.. 
    self.locationView.drawLocation(self.location) 
    self.locationManager.startPositionUpdates(for: self.location) 

} 

// EILIndoorLocationManager委託方法..

func indoorLocationManager(_ manager: EILIndoorLocationManager, didFailToUpdatePositionWithError error: Error) { 
    print("failed to update position: \(error)") 
} 

func indoorLocationManager(_ manager: EILIndoorLocationManager, didUpdatePosition position: EILOrientedPoint, with positionAccuracy: EILPositionAccuracy, in location: EILLocation) { 
    var accuracy: String! 
    switch positionAccuracy { 
     case .veryHigh: accuracy = "+/- 1.00m" 
     case .high:  accuracy = "+/- 1.62m" 
     case .medium: accuracy = "+/- 2.62m" 
     case .low:  accuracy = "+/- 4.24m" 
     case .veryLow: accuracy = "+/- ? :-(" 
     case .unknown: accuracy = "unknown" 
    } 
    print(String(format: "x: %5.2f, y: %5.2f, orientation: %3.0f, accuracy: %@", position.x, position.y, position.orientation, accuracy)) 

    self.locationManager.startPositionUpdates(for: self.location) 
    self.locationView.updatePosition(position) 
    lblCoordinate.text = "X:\(position.x),Y:\(position.y),accuracy:\(accuracy)" 

} 

謝謝你, 傢伙。

+0

你確定你必須從室內繪製準確的室內位置點嗎?因爲我已經在我的應用中使用了estimote室內位置sdk,並且它的作品很棒。 –

+0

您是否可以使用estimote室內位置應用程序設置您的位置?並將您的位置點存儲在estimote雲中? –

+0

是的,我必須將我的辦公室室內位置存放在室內的位置。 –

回答

0

你的代碼看起來沒問題,只是試着重新檢查你的室內位置點。 您使用室內位置應用程序設置您的位置。嘗試從Estimote Cloud下載信標位置(如果可能),並在您的應用程序中手動設置相同的值。