如何创建位置对象

时间:2018-07-31 04:50:06

标签: android kotlin location

我正在尝试建立一个新位置并按如下所示设置其纬度/经度:

var targetlocation = Location("")
//this example code doesn't work below
targetlocation.setLatitude(55.555555)
targetlocation.setLongitude(55.555555)

如何在Kotlin中正确执行此操作?谢谢。

1 个答案:

答案 0 :(得分:1)

我没有尝试过,但是尝试做。

var targetlocation = Location(LocationManager.GPS_PROVIDER)
targetlocation.latitude = 55.555555
targetlocation.longitude = 55.555555