如何绘制路径并计算移动距离。下面的代码不计算onLocationChanged方法的距离??
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
String text = String.format("Lat:\t %f\nLong:\t %f\nAlt:\t %f\nBearing:\t %f\nDistance:\t %f",
location.getLatitude() *1E6, location.getLongitude() *1E6,
location.getAltitude() *1E6, location.getBearing() *1E6, location.distanceTo(location));
textOut.setText(text);
lat = (int) (location.getLatitude() *1E6);
longi = (int) (location.getLongitude() *1E6);
GeoPoint myLocation = new GeoPoint(lat, longi);
OverlayItem overlayItem = new OverlayItem(myLocation, "WHATZ UP", "2nd String");
StagePoint custom = new StagePoint(d, Start.this);
custom.insertPinpoint(overlayItem);
overlayList.add(custom);
}
答案 0 :(得分:0)
private class MyLocationOverlay1 extends MyLocationOverlay {
@Override
public void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when)
super.drawMyLocation(canvas,mapView,lastFix,myLocation,when);
Location bLocation = new Location("reverseGeocoded");
bLocation.setLatitude(FindList.gpslat);
bLocation.setLongitude(FindList.gpslong);
Location aLocation = new Location("reverseGeocoded");
aLocation.setLatitude(myLocation.getLatitudeE6() / 1e6);
aLocation.setLongitude(myLocation.getLongitudeE6() / 1e6);
int distance = (int)aLocation.distanceTo(bLocation);
String str = " (" + String.valueOf(distance) + " meters)";
}
}