本文整理汇总了Java中com.amap.api.location.AMapLocation.getLatitude方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getLatitude方法的具体用法?Java AMapLocation.getLatitude怎么用?Java AMapLocation.getLatitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getLatitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
mAMapLocation = aMapLocation;
mlocationClient.stopLocation();
mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点
lp = new LatLonPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude());
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 17));
doSearchQuery(aMapLocation.getPoiName().trim(), aMapLocation.getCityCode(), false);
} else {
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
ToastUtils.showToast(this, errText);
}
}
}
示例2: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
String lat = aMapLocation.getLatitude() + "";
String lng = aMapLocation.getLongitude() + "";
sharedPref.edit().putString("Latitude", lat).apply();
sharedPref.edit().putString("Longitude", lng).apply();
} else {
Toast.makeText(
MainActivity.this,
aMapLocation.getErrorInfo(),
Toast.LENGTH_LONG
).show();
}
}
}
示例3: 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);
}
}
}
示例4: accept
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public boolean accept(AMapLocation previous, AMapLocation current) {
if(previous == null){
return true;
}
LatLng pre = new LatLng(previous.getLatitude(), previous.getLongitude());
LatLng cur = new LatLng(current.getLatitude(), current.getLongitude());
float distance = AMapUtils.calculateLineDistance(pre, cur);
if(distance < RMConfiguration.DRAW_DISTANCE){
return false;
}
float speed = current.getSpeed();
double interval = (SystemClock.elapsedRealtime() - mPreviousUpdateTime)/1000.0;
float v = (float) (distance/interval);
if(v > RMConfiguration.MAX_SPEED || v > speed * 1.5){
return false;
}
mPreviousUpdateTime = SystemClock.elapsedRealtime();
return true;
}
示例5: initLocation
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 初始化百度地图
*/
private void initLocation() {
AMapLocation location = locationClient.getLastKnownLocation();
if (location != null) {
Log.d(TAG, "getLastKnownLocation success");
mLongitude = location.getLongitude();
mLatitude = location.getLatitude();
city = location.getCity();
country = location.getCountry();
Log.d("XLight", String.format("long:%s,latitude:%s,ciry:%s,country:%s", mLongitude, mLatitude, city, country));
//请求天气信息
updateLocationInfo();
} else {
// 启动定位
locationClient.startLocation();
}
}
示例6: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation loc) {
if (null != loc && loc.getErrorCode() == 0) {
//解析定位结果
mLongitude = loc.getLongitude();
mLatitude = loc.getLatitude();
city = loc.getCity();
country = loc.getCountry();
Log.i("XLight", String.format("long:%s,latitude:%s,city:%s,country:%s", mLongitude, mLatitude, city, country));
//请求天气信息
updateLocationInfo();
locationClient.stopLocation();
} else {
// 定位失败,显示提示
Log.e("XLight", "location Error, ErrCode:"
+ loc.getErrorCode() + ", errInfo:"
+ loc.getErrorInfo());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtil.showToast(getActivity(), R.string.open_gps);
}
});
}
}
示例7: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
mLocationClient.stopLocation();
if (aMapLocation != null) {
mLocation = aMapLocation;
// 更新当前经纬度
Location latLng = new Location(aMapLocation.getLatitude(), aMapLocation.getLongitude());
createPushpin(latLng);
queryPoi(latLng);
//移动地图
ViewOptions viewOptions = new ViewOptions();
viewOptions.setZoom(15);
viewOptions.setCenter(latLng);
mBingMap.updateViewOptions(viewOptions);
}
}
示例8: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null
&& aMapLocation.getErrorCode() == 0) {
LatLng location = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
if (!mFirstFix) {
mFirstFix = true;
addCircle(location, aMapLocation.getAccuracy());//添加定位精度圆
addMarker(location);//添加定位图标
mSensorHelper.setCurrentMarker(mLocMarker);//定位图标旋转
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 18));
} else {
mCircle.setCenter(location);
mCircle.setRadius(aMapLocation.getAccuracy());
mLocMarker.setPosition(location);
mAMap.moveCamera(CameraUpdateFactory.changeLatLng(location));
}
} else {
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
Log.e("AmapErr", errText);
}
}
}
示例9: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//可在其中解析amapLocation获取相应内容。
double locationType = amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
double latitude = amapLocation.getLatitude();//获取纬度
double longitude = amapLocation.getLongitude();//获取纬度
L.i("location", "locationType:" + locationType + ",latitude:" + latitude + ",longitude:" + longitude);
LatLng latLng = new LatLng(latitude, longitude);
getAddressByLatlng(latLng);
} else {
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
L.i("location", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
示例10: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null && aLocation != null && aLocation.getAMapException().getErrorCode() == 0) {
mListener.onLocationChanged(aLocation);// 显示系统小蓝点
marker.setPosition(new LatLng(aLocation.getLatitude(), aLocation
.getLongitude()));// 定位雷达小图标
float bearing = aMap.getCameraPosition().bearing;
aMap.setMyLocationRotateAngle(bearing);// 设置小蓝点旋转角度
aMap.getMinZoomLevel();
double a = aLocation.getLatitude();// 维度
double b = aLocation.getLongitude();// 精度
lp = new LatLonPoint(a, b);
doSearchQuery();
}
}
示例11: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null && aLocation != null) {
mALocation = aLocation;
/**
* 获取城市的编码
*/
cityCode = aLocation.getCityCode();
city = aLocation.getCity();
mListener.onLocationChanged(aLocation);// 显示系统小蓝点
//获取经纬度
BigDecimal latitude = new BigDecimal(aLocation.getLatitude());
x = latitude.setScale(8, BigDecimal.ROUND_DOWN).doubleValue();
BigDecimal longitude = new BigDecimal(aLocation.getLongitude());
y = longitude.setScale(8, BigDecimal.ROUND_DOWN).doubleValue();
//搜索框内容为空时执行周边搜索方法,有内容时执行关键词搜索方法
final String searchKey = mSearch.getText().toString().trim();
if (TextUtils.isEmpty(searchKey)) {
PoiCheckEnd(aLocation, "");
} else {
initListener();
}
}
}
示例12: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
mLatitude = amapLocation.getLatitude();//获取纬度
mLongitude = amapLocation.getLongitude();//获取经度
AppLog.info(TAG, "Latitude:" + mLatitude + " ,Longitude" + mLongitude);
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
AppLog.error("Amap Location Error"
+ ", ErrCode:" + amapLocation.getErrorCode()
+ ", ErrInfo:" + amapLocation.getErrorInfo());
}
}
}
示例13: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null && aLocation != null) {
mListener.onLocationChanged(aLocation);// 显示系统小蓝点
marker.setPosition(new LatLng(aLocation.getLatitude(), aLocation
.getLongitude()));// 定位雷达小图标
float bearing = aMap.getCameraPosition().bearing;
aMap.setMyLocationRotateAngle(bearing);// 设置小蓝点旋转角度
aMap.getMinZoomLevel();
if(this.aLocation == null || this.aLocation.getStreet() != aLocation.getStreet())
{
this.aLocation = aLocation;
LatLng latng = new LatLng(aLocation.getLatitude(),aLocation.getLongitude());
// marker = aMap.addMarker(new MarkerOptions().anchor(0.5f, 1)
// .icon(BitmapDescriptorFactory.fromResource(R.drawable.point))
// .position(latng).title("我的位置:"+this.aLocation.getCity()+this.aLocation.getDistrict()+this.aLocation.getRoad()));
marker.setPosition(latng);
marker.setTitle("我的位置:"+this.aLocation.getCity()+this.aLocation.getDistrict()+this.aLocation.getRoad());
marker.showInfoWindow();
}
}
}
示例14: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
//定位回调
// System.out.println(amapLocation.getAMapException().getErrorCode());
// System.out.println("-------------------"+amapLocation.toString());
// if()
// {
if(amapLocation != null && amapLocation.getAMapException().getErrorCode()==0)
{
// if( this.amapLocation.getLatitude() != amapLocation.getLatitude()&&this.amapLocation.getLongitude()!= amapLocation.getLongitude())
// {
this.amapLocation = amapLocation;
LatLng latlng = new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude());
list.add(latlng);
Log.e("-------------", amapLocation.toString());
mapView.getMap().setOnMapLoadedListener(this);
// }
}
// }
}
示例15: getDistance
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
private float getDistance(List<AMapLocation> list) {
float distance = 0;
if (list == null || list.size() == 0) {
return distance;
}
for (int i = 0; i < list.size() - 1; i++) {
AMapLocation firstpoint = list.get(i);
AMapLocation secondpoint = list.get(i + 1);
LatLng firstLatLng = new LatLng(firstpoint.getLatitude(),
firstpoint.getLongitude());
LatLng secondLatLng = new LatLng(secondpoint.getLatitude(),
secondpoint.getLongitude());
double betweenDis = AMapUtils.calculateLineDistance(firstLatLng,
secondLatLng);
distance = (float) (distance + betweenDis);
}
return distance;
}