使用MyLocationOverlay绘制

使用MyLocationOverlay绘制

我正在开发一个android应用程序,它可以显示用户所在位置的地图,到目前为止,我可以在线和离线显示地图。现在我想知道如何使用MylocationOverlay绘制一个精确的圆,这个圆与osmdroid中的标记一起出现?
这是我的代码:

public class AhmedActivity extends Activity
{
    /** Called when the activity is first created. */
    private MapView mapView;
    private MapController mapController;
    private ScaleBarOverlay mScaleBarOverlay;
    MyLocationOverlay myLocationOverlay = null;
    private LocationManager locationManager;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Initialize the location:
        locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

        initializemap();

        /* My location overlay */
        /* Create a static Overlay showing a the current location and a compass */
        myLocationOverlay = new MyLocationOverlay(this, mapView);
        mapView.getOverlays().add(myLocationOverlay);
        myLocationOverlay.runOnFirstFix( new Runnable() {
            public void run() {
                mapController.animateTo( myLocationOverlay
                                 .getMyLocation());
            }
        });

        //Add Scale Bar
        mScaleBarOverlay = new ScaleBarOverlay(this);
        ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
        mScaleBarOverlay.setLineWidth(50);
        mapView.getOverlays().add(myScaleBarOverlay);
    }

    /** (re-)enable location and compass updates */
    @Override
    public void onResume() {
        super.onResume();
        myLocationOverlay.enableCompass();
        myLocationOverlay.enableMyLocation();
        //myLocationOverlay.followLocation(true);
        //myLocationOverlay.setDrawAccuracyEnabled(true);
        //myLocationOverlay.isDrawAccuracyEnabled();
    }

    /** disable compass and location updates */
    @Override
    public void onPause() {
        super.onPause();
        myLocationOverlay.disableMyLocation();
        myLocationOverlay.disableCompass();
    }

    public void initializemap()
    {
        mapView = (MapView) this.findViewById(R.id.mapView);
        mapView.setTileSource(TileSourceFactory.MAPNIK);
        mapView.setBuiltInZoomControls(true);
        mapView.setMultiTouchControls(true);
        mapController = this.mapView.getController();
        mapController.setZoom(12);
        mapController.setCenter(new GeoPoint(15.610762,32.540345));
    }
}

最佳答案

ABO 7英里,
例如,您需要扩展覆盖

public class AccuracyCircleOverlay extends Overlay {
    public AccuracyCircleOverlay() {}
    public void draw(Canvas canvas, MapView mapv, boolean shadow){
       super.draw(canvas, mapv, shadow);
       // your drawing code here
    }
}

您可以这样将覆盖添加到视图中:
mapView.getOverlays().add(new AccuracyCircleOverlay());

10-06 04:57