How to display the current position pointer in osmdroid?

Jan-Terje Sørensen picture Jan-Terje Sørensen · Jan 10, 2012 · Viewed 8.8k times · Source

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?

Answer

Ifor picture Ifor · Jan 13, 2012

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);