0
現在の位置と3つのマーカーの間の距離を計算しようとしています。 すべてがうまくいきますが、自分の位置を変更した場合、その距離は距離と同じになります。新しい座標は表示されません。ここに私のコードは次のとおりです。常に最新の現在の座標を取得する方法
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Location current = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, true));
latng = String.valueOf(current.getLatitude());
lngon = String.valueOf(current.getLongitude());
Location club = new Location("clubloc");
club.setLatitude(Double.parseDouble(marker_data.get("lat")));
club.setLongitude(Double.parseDouble(marker_data.get("lng")));
double distance = current.distanceTo(club);
distance = distance/1000;
distance = Math.round(distance * 100);
distance = distance/100;
TextView dis = (TextView) findViewById(R.id.distance);
dis.setText(String.valueOf(distance) + "KM");
}
だから私の質問は、私は常に正しい距離を得るように、どのように私は私の座標を更新することができますか?
ありがとう、私はそれをonLocationChangedメソッドを使って解決しました –