本文整理汇总了Java中com.amap.api.location.AMapLocation.getAoiName方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getAoiName方法的具体用法?Java AMapLocation.getAoiName怎么用?Java AMapLocation.getAoiName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getAoiName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
//可在其中解析amapLocation获取相应内容。
// aMapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
double latitude = aMapLocation.getLatitude();//获取纬度
double longitude = aMapLocation.getLongitude();//获取经度
aMapLocation.getAccuracy();//获取精度信息
aMapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
aMapLocation.getCountry();//国家信息
String province = aMapLocation.getProvince();//省信息
String city = aMapLocation.getCity();//城市信息
String district = aMapLocation.getDistrict();//城区信息
aMapLocation.getStreet();//街道信息
aMapLocation.getStreetNum();//街道门牌号信息
aMapLocation.getCityCode();//城市编码
aMapLocation.getAdCode();//地区编码
aMapLocation.getAoiName();//获取当前定位点的AOI信息
aMapLocation.getBuildingId();//获取当前室内定位的建筑物Id
aMapLocation.getFloor();//获取当前室内定位的楼层
Log.d("map", "onLocationChanged: " + aMapLocation.toString());
//获取定位时间
@SuppressLint("SimpleDateFormat") SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
df.format(date);
LocationEntity locationEntity = new LocationEntity();
locationEntity.setProvince(province);
locationEntity.setPosLng(String.valueOf(longitude));
locationEntity.setPosLat(String.valueOf(latitude));
locationEntity.setCity(city);
locationEntity.setDistrict(district);
mSendLocation.sendLocation(locationEntity);
} else {
mSendLocation.sendLocation(null);
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
}
} else {
mSendLocation.sendLocation(null);
}
if (mLocationClient.isStarted()){
mLocationClient.stopLocation();
}
}
示例2: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mDataSave == null) {
mDataSave = new LocationDataSave();
}
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
// 定位成功回调信息,设置相关消息
amapLocation.getLocationType();// 获取当前定位结果来源,如网络定位结果,详见定位类型表
double lat = amapLocation.getLatitude();// 获取纬度
double lng = amapLocation.getLongitude();// 获取经度
amapLocation.getAccuracy();// 获取精度信息
SimpleDateFormat df = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
Date date = new Date(amapLocation.getTime());
df.format(date);// 定位时间
StringTool.DateToString1(new Date(amapLocation.getTime()));
String address = amapLocation.getAddress();// 地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
amapLocation.getCountry();// 国家信息
amapLocation.getProvince();// 省信息
amapLocation.getCity();// 城市信息
amapLocation.getDistrict();// 城区信息
amapLocation.getStreet();// 街道信息
amapLocation.getStreetNum();// 街道门牌号信息
amapLocation.getCityCode();// 城市编码
amapLocation.getAdCode();// 地区编码
String mLocationAOI = amapLocation.getAoiName();// 获取当前定位点的AOI信息
if (!isFirst) {
mDataSave.setAddress(address);
mDataSave.setLat(lat);
mDataSave.setLng(lng);
mDataSave.setLocationAOI(mLocationAOI);
if (mLocationAOI != null && !mLocationAOI.equals("")) {
storeName.setText(mLocationAOI);
} else {
storeName.setText(amapLocation.getCity()
+ amapLocation.getDistrict()
+ amapLocation.getStreet()
+ amapLocation.getStreetNum());
}
addressName.setText(address);
getView().initLatLng(lat, lng);
isFirst = true;
}
} else {
// 显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}