知っているlocation1.distanceTo(location2)
計算する必要があります
distanceX
と
distanceY
2つの場所から。それを行う方法はありますか?
njzk2の回答に基づく正解
private Point getDistanceXY(Location location1, Location location2) {
int angle = (int) location1.bearingTo(location2);
Location interm = new Location(location1);
interm.setLongitude(location2.getLongitude());
int distanceX = (int) location1.distanceTo(interm);
int distanceY = (int) location2.distanceTo(interm);
if (angle<=-90) distanceX=-distanceX;
else if (angle>-90 && angle<0) {
distanceX=-distanceX;
distanceY=-distanceY;
}
Log.e("distXY "+name, distanceX+" "+distanceY+" "+angle);
return new Point(distanceX, distanceY);
}