本文整理汇总了Java中com.amap.api.location.AMapLocation.getSpeed方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getSpeed方法的具体用法?Java AMapLocation.getSpeed怎么用?Java AMapLocation.getSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getSpeed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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: getLocationDelay
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
private int getLocationDelay(AMapLocation location){
int interval;
if(location.getProvider().equals("lbs"))
interval = MAX_LOCATION_DELAY;
else{
float speed = location.getSpeed();
interval = (int) (MAX_LOCATION_DELAY - speed * (MAX_LOCATION_DELAY - MIN_LOCATION_DELAY) / 10);
if(interval < MIN_LOCATION_DELAY)
interval = MIN_LOCATION_DELAY;
}
return interval;
}
示例4: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aLocation) {
if (mListener != null && aLocation != null
&& aLocation.getAMapException().getErrorCode() == 0) {
latitude = aLocation.getLatitude();
longitude = aLocation.getLongitude();
if (aLocation.getProvider().equals("gps")) {
speed = aLocation.getSpeed();
provider = "gps";
} else if (aLocation.getProvider().equals("lbs")) {
provider = "lbs";
}
mListener.onLocationChanged(aLocation);
}
}