本文整理匯總了Java中com.amap.api.location.AMapLocation.getStreetNum方法的典型用法代碼示例。如果您正苦於以下問題:Java AMapLocation.getStreetNum方法的具體用法?Java AMapLocation.getStreetNum怎麽用?Java AMapLocation.getStreetNum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getStreetNum方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //導入方法依賴的package包/類
/**
* 實現定位
* @param amapLocation
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null
&&amapLocation.getErrorCode() == 0) {
if(isFirstTime){//隻要第一次的數據,當然,也可以在這裏關閉定位
// mlocationClient.stopLocation();//停止定位
mListener.onLocationChanged(amapLocation);// 顯示係統小藍點
lvHolder.title = "[位置]";
lvHolder.address = amapLocation.getProvider()+amapLocation.getCity()+amapLocation.getStreet()+amapLocation.getStreetNum();
lvHolder.lp = new LatLonPoint(amapLocation.getLatitude(),amapLocation.getLongitude());
mEndMarker.setPosition(new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
data.add(0,lvHolder);
doSearchQuery();
}
} else {
String errText = "定位失敗," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
Log.e("AmapErr",errText);
}
}
}
示例2: 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();
}
}
}
示例3: 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();
}
}
示例4: 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();
}
}
}
示例5: 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());
}
}
}