基本谷歌地图api - 添加重叠问题(GeoPoint上的标签)

时间:2011-03-21 05:26:07

标签: android google-maps

我有以下代码......

这里变量点是Geopoint对象。

我需要Android的当前GPS位置,在这一点上进行更新...

我该怎么称呼?在POINT上定义当前位置?!

// create a map view  
RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout);  
    mapView = (MapView) findViewById(R.id.mapview);  
    mapView.setBuiltInZoomControls(true);  
    mapView.setStreetView(true);  
    mapController = mapView.getController();  
    mapController.setZoom(14); // Zoom 1 is world view  
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,0, new   GeoUpdateHandler());  

    List<Overlay> mapOverlays = mapView.getOverlays();  
    Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

    OverlayItem overlayitem = new OverlayItem(point, "Hola, people!", "I am on Earth");
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
}

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

public class GeoUpdateHandler implements LocationListener {

    @Override
    public void onLocationChanged(Location location) {
        int lat = (int) (location.getLatitude() * 1E6);
        int lng = (int) (location.getLongitude() * 1E6);
        GeoPoint point = new GeoPoint(lat, lng);
        mapController.animateTo(point); 

        //mapController.setCenter(point);



    }

1 个答案:

答案 0 :(得分:2)

看看下面的课程

http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MyLocationOverlay.html

您可以使用此类在地图上显示用户的当前位置。