位置情報サービスから現在のユーザーの位置を取得するアプリがあります。位置オブジェクトから経度と緯度を取得すると、次のようになります
lat = 53.653770446777344
lon = -1.520833969116211
.
次に、これらを GeoPoint オブジェクトに保存し、Google サーバーのクエリ文字列に渡します。これにより、現在の場所と目的地の間のポリラインが最終的にプロットされます。
すべて正常に動作し、ポリラインが描画されますが、現在の場所が約 100 マイル離れているため、正しく描画されません。いくつかの値をログアウトしましたが、経度と緯度がジオポイントに渡されると精度が失われます。
どうすればこれを回避できますか。
@Override
public void onLocationChanged(Location location) {
lati = (location.getLatitude());
lngi = (location.getLongitude());
startAddr = new GeoPoint((int)lati, (int)lngi);
Log.e(TAG, "lat = " + lati);
Log.e(TAG, "lon = " + lngi);
Log.e(TAG, "lat after cast = " + (int)(lati * 1000000));
Log.e(TAG, "lon after cast = " + (int)(lngi * 1000000));
locationManager.removeUpdates(this);
StringBuilder sb = new StringBuilder();
sb.append("http://maps.google.com/maps/api/directions/json?origin=");
sb.append(startAddr);
sb.append("&destination=");
sb.append(endAddr);
sb.append("&sensor=false");
stringUrl = sb.toString();
Log.e(TAG, "url = " + stringUrl);
AsyncGetRoute agr = new AsyncGetRoute();
agr.execute();
.
11-15 12:45:17.280: E/GetClientDirections(23220): lat = 53.653770446777344
11-15 12:45:17.280: E/GetClientDirections(23220): lon = -1.520833969116211
11-15 12:45:17.280: E/GetClientDirections(23220): lat after cast = 53653770
11-15 12:45:17.280: E/GetClientDirections(23220): lon after cast = -1520833
11-15 12:45:17.290: E/GetClientDirections(23220): url = http://maps.google.com/maps/api/directions/json?origin=53,-1&destination=AL73EZ&sensor=false