林這段代碼用於獲取位置我的應用程序:如何在Android應用程序中獲得更準確的GPS讀數?使用
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 200.0f, this);
但是,當我在真正的Android手機嘗試應用它在actualy顯示該位置從位置IM約80公里。如何將我有這樣的代碼更準確。我希望得到的結果是什麼IM製作方法更準確..
即時通訊使用的onLocationChanged在地圖上顯示出來..這就是:
public void onLocationChanged(Location location) {
if (location != null) {
//Gets users longitude and latitude
lat = location.getLatitude();
lng = location.getLongitude();
//sets the GeoPoint usersLocation equal lat and lng
userLocation = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
OverlayItem usersLocationIcon = new OverlayItem(userLocation, null, null);
LocationPin myLocationPin = new LocationPin(userIcon, MainActivity.this);
//Removes the previous location
if(previousLocation != null)
mainMap.getOverlays().remove(previousLocation);
myLocationPin.getLocation(usersLocationIcon);
overlayList.add(myLocationPin);
//refresh the map
mainMap.invalidate();
//Making myLocationPin into the previousLocation just to be able to remove it later
previousLocation = myLocationPin;
}
天空的景色很明顯,我試圖將1000毫米降低到500毫米,將200米降低到50米..但它仍然顯示我距離真正的位置80公里。我還嘗試啓動Google地圖,顯示我的真實位置.. – Rakso
你是如何在你的應用中顯示位置的?如果您記錄緯度和經度值,並將它們輸入Google地圖,那麼它會將您放到哪裏? – Craigy
我使用谷歌地圖API來顯示這個經度和緯度。 – Rakso