如何在Android版Google地图上快速更新用户的位置?

时间:2011-11-02 10:03:52

标签: android google-maps position

我最近正在开发一款应用,我需要在Google地图上显示用户的位置。

根据我在互联网上找到的材料和API的帮助。 现在我可以显示手机的位置并标记它。

目前我使用下面的代码获取位置

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000,0, this);
........
public void onLocationChanged(Location location) {
    if(location!=null){
        currentLocation = location;

        GeoPoint geo = new GeoPoint(((int)location.getLatitude()*1E6),
                 ((int)location.getLongitude()*1E6))
        System.err.println("onLocationChanged"+geo.toString());
        mapController.animateTo(geo);
 }

我想这种方法会每秒调用onLocationChanged(Location location)方法吗?

事实证明,每隔15秒检测一次该位置。但我需要尽快更新位置信息。

1 个答案:

答案 0 :(得分:1)

使用GPS_PROVIDER