Android GoogleMaps的纬度和经度出错

时间:2012-08-29 00:19:34

标签: android google-maps emulation latitude-longitude

目前,我正在使用GoogleMaps,但我遇到了问题。例如,当我

lat:22.422006 lng:23.084095

模拟器像我一样敬酒:

lat:2.2422006E13 lng:2.3084095E7

我阅读了很多教程,并且完全相同,但我无法处理这个问题。

这是我的代码:

 public class MainActivity extends MapActivity {


 public static final String TAG = "GoogleMapsActivity";
    private MapView mapView;
    private LocationManager locationManager;
    Geocoder geocoder;
    Location location;
    LocationListener locationListener;
    CountDownTimer locationtimer;
    MapController mapController;
@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mapView = (MapView)findViewById(R.id.mapView);
    mapController = mapView.getController();
    mapController.setZoom(16);
    mapView.setBuiltInZoomControls(true);
    readFromGPS();
}
private void readFromGPS() {
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    // Define a listener that responds to location updates
    locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
    // Called when a new location is found by the network location provider.

    Toast.makeText(getApplicationContext(), location.getLatitude()*1E6+"-"+location.getLongitude(), Toast.LENGTH_SHORT).show(); 

    }

    public void onStatusChanged(String provider, int status, Bundle extras) {}

    public void onProviderEnabled(String provider) {

    Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show();
    }

    public void onProviderDisabled(String provider) {


    }
    };

    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000, 0, locationListener);

    }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}


}

0 个答案:

没有答案