androidlocationlistenerosmdroid

How to display the current position pointer in osmdroid?


I would like to display the current position pointer using osmdroid.

getController().setCenter(new GeoPoint(location));

This code does not display the pointer. So is there anything built in for osmdroid as it is for google maps?


Solution

  • You need to add a MyLocationOverlay somthing like the following.

            mMyLocationOverlay = new MyLocationOverlay(this, mOsmv,
                    mResourceProxy);
            mMyLocationOverlay.disableMyLocation(); // not on by default
            mMyLocationOverlay.disableCompass();
            mMyLocationOverlay.disableFollowLocation();
            mMyLocationOverlay.setDrawAccuracyEnabled(true);
            mMyLocationOverlay.runOnFirstFix(new Runnable() {
                public void run() {
                    mOsmvController.animateTo(mMyLocationOverlay
                            .getMyLocation());
                }
            });
            mOsmOverlays.add(mMyLocationOverlay);