MSDKV5的key怎样使用,该怎样显示飞机的位置

Completed

Comments

3 comments

  • DJI Developer Support
    KeyManager.getInstance().listen(KeyTools.createKey(FlightControllerKey.KeyAircraftLocation3D),this) 您的代码中并没有传入listener参数,需要传入这个参数才可以从回调中拿到数据。 ![](https://djisdksupport.zendesk.com/attachments/token/B1VF9xstCnqfP3LbjkI36usNQ/?name=image.png)
    0
    Comment actions Permalink
  • 123

    是这样的吗,显示的一直是0

    btn_click.setOnClickListener{
    KeyManager.getInstance().listen(KeyTools.createKey(KeyAircraftLocation3D),this,object: CommonCallbacks.KeyListener<LocationCoordinate3D>{
    override fun onValueChange(
    oldValue: LocationCoordinate3D?,
    newValue: LocationCoordinate3D?
    ) {
    }
    })
    tv_text.text = LocationCoordinate3D().toString()
    }
    0
    Comment actions Permalink
  • DJI Developer Support
    大致是正确的,你是想要将获取到的值赋值给tv_text吧,这样就需要使用回调给到的newValue。我们也不建议你直接newValue.toString(),最好是经纬度单独读取出来,例如newVaule.getAltitude()获取高度。 参考代码: dji.v5.manager.KeyManager.getInstance().listen(KeyTools.createKey(FlightControllerKey.KeyAircraftLocation3D), this){ _, newVaule -> tv_text.text = newVaule.toString()}
    0
    Comment actions Permalink

Please sign in to leave a comment.