android - eclipse:使用gps获得的坐标显示谷歌地图

arm*_*398 2 eclipse gps android google-maps

我正在尝试创建一个应用程序,通过gps获取用户位置,在谷歌地图中显示用户位置,然后在一定的时间/移动后更新.

我现在有一个应用程序,将通过GPS获取用户的位置,并更新自己每10米/ 10,000毫秒,但目前它是所有显示什么坐标.我已将其设置为连接到谷歌地图,但此刻它只是将地图设置为我手动输入的一些坐标.

如何获取它以便地图将根据通过gps获得的坐标显示位置?

任何帮助将不胜感激,我对这一切都很新!

编辑:到目前为止我的代码!

package com.android.basicmap;

import com.google.android.maps.MapActivity;
import android.os.Bundle;
import com.google.android.maps.MapView;
import com.google.android.maps.MapController;
import com.google.android.maps.GeoPoint;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

public class BasicMapActivity extends MapActivity {

private MapView mapView;
private MapController mapController;

private LocationManager locationManager;
private LocationListener locationListener;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  

    locationListener = new GPSLocationListener();

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

    mapView = (MapView) findViewById(R.id.mapView);
    mapView.setStreetView(true);
    mapView.setBuiltInZoomControls(true);

    mapController = mapView.getController();
    mapController.setZoom(16);
}

@Override
protected boolean isRouteDisplayed() {
  return false;
}

private class GPSLocationListener implements LocationListener 
{
  @Override
  public void onLocationChanged(Location location) {
    if (location != null) {
      GeoPoint point = new GeoPoint(
          (int) (location.getLatitude() * 1E6), 
          (int) (location.getLongitude() * 1E6));

      Toast.makeText(getBaseContext(), 
          "Latitude: " + location.getLatitude() + 
          " Longitude: " + location.getLongitude(), 
          Toast.LENGTH_SHORT).show();

      mapController.animateTo(point);
      mapController.setZoom(16);
      mapView.invalidate();
    }
  }


}
Run Code Online (Sandbox Code Playgroud)

}

Iva*_*sov 7

这是一个完整的教程:http://www.codeproject.com/Articles/112044/GPSLocator-App-to-Find-Current-Nearest-Location-us

但是来吧,我发现通过输入"android如何在谷歌地图上显示gps位置",请更加彻底地谷歌并在发布这样简单的问题之前仔细阅读教程:)