我有一个从位置服务获取当前用户位置的应用程序。当我从位置对象中获取 lon 和 lat 时,它们如下所示
lat = 53.653770446777344
lon = -1.520833969116211
.
然后我将这些存储在一个 GeoPoint 对象中,该对象传递给 Google 服务器的查询字符串。这最终会在当前位置和目的地之间绘制一条折线。
一切正常,并且绘制了多段线,但是由于当前位置设置在大约 100 英里外,因此绘制不正确。我已经注销了一些值,当 lon 和 lat 传递到地理点时,精度会有所下降。
我该如何解决这个问题。
@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