ios - 室内地图 - 如何使用 iBeacons 手动设置跟踪用户位置和方向?

标签 ios iphone swift

大家好,

我正在创建一个演示项目来跟踪室内区域的用户位置并使用 Estimote Proximity Beacons 显示实时跟踪。而SDK使用Estimote室内定位sdk。但我卡在了这一点上。

SDK委托(delegate)函数总是发送响应错误,错误是: 无法确定位置外的位置

在这里,我代表我在演示中使用的代码和函数,所以请任何对此有想法的人告诉我我可能在哪一点上犯错,以便我解决并实现正确的解决方案。请建议我并提前致谢...

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 委托(delegate)方法..

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)"

}

谢谢你, 伙计们。

最佳答案

您的代码看起来没问题,只需尝试重新检查您的室内定位点。 您使用室内定位应用程序设置您的位置。尝试从 Estimote Cloud 下载信标位置(如果可能)并在您的应用中手动设置相同的值。

关于ios - 室内地图 - 如何使用 iBeacons 手动设置跟踪用户位置和方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45347756/

相关文章:

iphone - 如何在for循环中释放一个对象?

ios - SWIFT iOS 中未调用委托(delegate)

ios - 创建固定长度字符串函数(最初来自Java)

ios - "Allow Push Notifications"对话框被关闭一次后如何取回?

iphone - CALayer 动画边界

ios - 如何发送[字符串:Any] dictionary in multipart API?

ios - 想要两种方式到达 View Controller ,但只有一种方式返回

ios - Godot ios 模板构建 - 运行时错误 EXC_BAD_ACCESS

ios - 我不断收到有关我的 iOS 项目的 .png 文件的多个构建命令的警告

ios - 授权 'application-identifier' 具有配置文件不允许的值