本文整理汇总了Java中com.amap.api.location.AMapLocation.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getTime方法的具体用法?Java AMapLocation.getTime怎么用?Java AMapLocation.getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(final AMapLocation loc) {
if(loc == null){
return;
}
if(loc.getTime() == 0){
//网络定位,时间可能为0
loc.setTime(System.currentTimeMillis());
}
//纠偏,通知保存的都是gcj的经纬度
LocationUtil.wgsToGcj(loc, false);
if(mCurrentLocation == null || mLocationValider.isBetterLocation(loc, mCurrentLocation)){
//位置有效
mCurrentLocation = loc;
handler.removeMessages(WHAT_LOCATION_CHANGED);
Message msg = handler.obtainMessage();
msg.what = WHAT_LOCATION_CHANGED;
msg.obj = mCurrentLocation;
handler.sendMessage(msg);
}
}
示例2: 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());
}
}
示例3: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
df.format(date);//定位时间
mLocationInfo.put("locationType", aMapLocation.getLocationType()); //获取当前定位结果来源,如网络定位结果,详见定位类型表
mLocationInfo.put("provider", aMapLocation.getProvider());//提供方
mLocationInfo.put("latitude", aMapLocation.getLatitude());//纬度
mLocationInfo.put("longitude", aMapLocation.getLongitude());//经度
mLocationInfo.put("altitude", aMapLocation.getAltitude());//海拔
mLocationInfo.put("accuracy", aMapLocation.getAccuracy());//定位精度
mLocationInfo.put("gpsTime", df.format(date));//定位时间
mLocationInfo.put("satellites", aMapLocation.getSatellites());//卫星数
mLocationInfo.put("speed", aMapLocation.getSpeed());//速度
mLocationInfo.put("bearing", aMapLocation.getBearing());//航向
//屏蔽掉重复定位数据
if(aMapLocation.getLocationType() != AMapLocation.LOCATION_TYPE_SAME_REQ) {
//根据定位类型,更新速度
mLocationDelay = getLocationDelay(aMapLocation);
if (mLocationDelayCnt++ == 0) {
mLastInsertID = mLocalDatabase.addLocationPoint(mLocationInfo);//写入数据库
updateNotification();
}
if (mLocationDelayCnt >= mLocationDelay)
mLocationDelayCnt = 0;
}
mLocationStatus = true;
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError","location Error, ErrCode: "
+ aMapLocation.getErrorCode() + ", errInfo: "
+ aMapLocation.getErrorInfo());
mLocationStatus = false;
}
}
}
示例4: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
*获取到位置信息
*@author invinjun
*created at 2016/7/1 15:31
*/
//以下为后者的举例:
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
aMapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
aMapLocation.getLatitude();//获取纬度
aMapLocation.getLongitude();//获取经度
aMapLocation.getAccuracy();//获取精度信息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
df.format(date);//定位时间
aMapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
aMapLocation.getCountry();//国家信息
if (mCityName ==null|| mCityName.equals("")){
mCityName =aMapLocation.getProvince();//省信息
}
Log.e("AmapError","location success, CityCode:"
+ aMapLocation.getCityCode() + ", Province:"
+ aMapLocation.getProvince());
SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_CODE, aMapLocation.getCityCode());
SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_NAME, aMapLocation.getCity().substring(0,aMapLocation.getCity().length()-1));
} else {
SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_CODE, "010");
SPUtils.setParam(context, Constants.USER_INFO, Constants.USER_LOCATION_NAME, "北京");
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError","location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
}
}
}
示例5: showLocationInfor
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
public static void showLocationInfor(AMapLocation aMapLocation) {
LogMgr.i("定位成功回调信息,设置相关消息");
LogMgr.i("获取当前定位结果来源,如网络定位结果,详见定位类型表:" + aMapLocation.getLocationType());
LogMgr.i("获取经度:" + aMapLocation.getLatitude() + " 获取纬度:" + aMapLocation.getLongitude() + " 获取精度信息:" + aMapLocation.getAccuracy());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
LogMgr.i("定位时间:" + df.format(date));
LogMgr.i("地址:" + aMapLocation.getAddress());
LogMgr.i("国家信息:" + aMapLocation.getCountry() + " 省信息:" + aMapLocation.getProvince() + " 城市信息:" + aMapLocation.getCity());
}
示例6: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* ��λ�ص�����������λ��ɺ���ô˷���
* @param aMapLocation
*/
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if(listener!=null && aMapLocation!=null) {
listener.onLocationChanged(aMapLocation);// ��ʾϵͳС����
if (aMapLocation.getErrorCode() == 0) {
//��λ�ɹ��ص���Ϣ�����������Ϣ
aMapLocation.getLocationType();//��ȡ��ǰ��λ�����Դ�������綨λ����������λ���ͱ�
aMapLocation.getLatitude();//��ȡ����
aMapLocation.getLongitude();//��ȡγ��;
aMapLocation.getAccuracy();//��ȡ������Ϣ
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
df.format(date);//��λʱ��
aMapLocation.getAddress();//��ַ�����option������isNeedAddressΪfalse����û�д˽��
aMapLocation.getCountry();//������Ϣ
aMapLocation.getProvince();//ʡ��Ϣ
aMapLocation.getCity();//������Ϣ
aMapLocation.getDistrict();//������Ϣ
aMapLocation.getRoad();//�ֵ���Ϣ
aMapLocation.getCityCode();//�����
aMapLocation.getAdCode();//��������
} // ��������ñ�־λ����ʱ���϶���ͼʱ������Ͻ���ͼ�ƶ�����ǰ��λ��
if (isFirstLoc) {
//�������ż���
aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
//����ͼ�ƶ�����λ��
aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(
aMapLocation.getLatitude(), aMapLocation.getLongitude())));
//�����λ��ť �ܹ�����ͼ�������ƶ�����λ��
listener.onLocationChanged(aMapLocation);
//���ͼ��
//aMap.addMarker(getMarkerOptions(aMapLocation));
//��ȡ��λ��Ϣ
StringBuffer buffer = new StringBuffer();
buffer.append(aMapLocation.getCountry() + "," + aMapLocation.getProvince() + "," + aMapLocation.getCity() + "," + aMapLocation.getProvince() + "," + aMapLocation.getDistrict() + "," + aMapLocation.getStreet() + "," + aMapLocation.getStreetNum());
Messages = buffer.toString();
Toast.makeText(getActivity().getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
isFirstLoc = false;
}
} else {
//��ʾ������ϢErrCode�Ǵ����룬errInfo�Ǵ�����Ϣ������������
Log.e("AmapError", "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
Toast.makeText(getActivity().getApplicationContext(), "��λʧ��", Toast.LENGTH_LONG).show();
}
}
示例7: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
MyAmapLocation =amapLocation;
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见官方定位类型表
amapLocation.getLatitude();//获取纬度
amapLocation.getLongitude();//获取经度
amapLocation.getAccuracy();//获取精度信息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
Date date = new Date(amapLocation.getTime());
df.format(date);//定位时间
amapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
amapLocation.getCountry();//国家信息
amapLocation.getProvince();//省信息
amapLocation.getCity();//城市信息
amapLocation.getDistrict();//城区信息
amapLocation.getStreet();//街道信息
amapLocation.getStreetNum();//街道门牌号信息
amapLocation.getCityCode();//城市编码
amapLocation.getAdCode();//地区编码
// 如果不设置标志位,此时再拖动地图时,它会不断将地图移动到当前的位置
aMap.moveCamera(CameraUpdateFactory.zoomTo(17)); //设置缩放级别
aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude())));//将地图移动到定位点
mListener.onLocationChanged(amapLocation);//点击定位按钮 能够将地图的中心移动到定位点
//aMap.addMarker(getMarkerOptions(amapLocation));//添加图钉
StringBuffer buffer = new StringBuffer();//获取定位信息
buffer.append(amapLocation.getCountry() + "" + amapLocation.getProvince() + "" + amapLocation.getCity() + "" + amapLocation.getProvince() + "" + amapLocation.getDistrict() + "" + amapLocation.getStreet() + "" + amapLocation.getStreetNum());
Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
Toast.makeText(getApplicationContext(), "定位失败", Toast.LENGTH_LONG).show();
}
}
}
示例8: 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();
}
}
示例9: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见官方定位类型表
mLatitude = amapLocation.getLatitude();//获取纬度
mLongitude = amapLocation.getLongitude();//获取经度
amapLocation.getAccuracy();//获取精度信息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(amapLocation.getTime());
df.format(date);//定位时间
amapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
amapLocation.getCountry();//国家信息
amapLocation.getProvince();//省信息
mCity = amapLocation.getCity();//城市信息
amapLocation.getDistrict();//城区信息
amapLocation.getStreet();//街道信息
amapLocation.getStreetNum();//街道门牌号信息
amapLocation.getCityCode();//城市编码
amapLocation.getAdCode();//地区编码
titleCenterTv.setText(amapLocation.getCity());
lp = new LatLonPoint(mLongitude, mLatitude);
Log.i(LOG, ">>>>> " + mCity + ", " + mLongitude + ", " + mLatitude);
// 如果不设置标志位,此时再拖动地图时,它会不断将地图移动到当前的位置
if (isFirstLoc) {
//设置缩放级别
aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
//将地图移动到定位点
aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude())));
//点击定位按钮 能够将地图的中心移动到定位点
mListener.onLocationChanged(amapLocation);
//添加图钉
mMarker = aMap.addMarker(getMarkerOptions(amapLocation));
isFirstLoc = false;
}
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
Toast.makeText(FindMapAroundAty.this, "定位失败", Toast.LENGTH_LONG).show();
}
}
}
示例10: 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());
}
}
}