本文整理汇总了Java中com.amap.api.location.AMapLocation.getBearing方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getBearing方法的具体用法?Java AMapLocation.getBearing怎么用?Java AMapLocation.getBearing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getBearing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null && amapLocation.getErrorCode() == 0) {
Double latitude = amapLocation.getLatitude();
Double longitude = amapLocation.getLongitude();
boolean hasAccuracy = amapLocation.hasAccuracy();
float accuracy = amapLocation.getAccuracy();
String address = amapLocation.getAddress();
String province = amapLocation.getProvince();
String road = amapLocation.getRoad();
float speed = amapLocation.getSpeed();
float bearing = amapLocation.getBearing();
int satellites = amapLocation.getExtras().getInt("satellites", 0);
long time = amapLocation.getTime();
JSONObject jo = new JSONObject();
try {
jo.put("latitude", latitude);
jo.put("longitude", longitude);
jo.put("hasAccuracy", hasAccuracy);
jo.put("accuracy", accuracy);
jo.put("address", address);
jo.put("province", province);
jo.put("road", road);
jo.put("speed", speed);
jo.put("bearing", bearing);
jo.put("satellites", satellites);
jo.put("time", time);
} catch (JSONException e) {
jo = null;
e.printStackTrace();
}
callbackContext.success(jo);
} else {
callbackContext.error(amapLocation.getErrorInfo());
}
}