Alex Rivera | Logout

Disable center button in MyLocation at Google Map API V2

Asked 2013-01-17T09:56:35.090
32

I searched a lot on the web, but I haven't found anything which answered my question. When I enable MyLocation with

gmap.setMyLocationEnabled(true)

I automatically get a button to center the map on my current location. I want to remove it and so I'm asking you how to do this. I hope somebody of you can help me!

Edit
Report

2 Answers

10

It's very simple answer ;

gmap.setMyLocationEnabled(true); ==> means "to center the map on my current location"
gmap.setMyLocationEnabled(false); ==> means "NOT to center the map on my current location"

[update]

If you want to remove your Location Button on your map, search this below in your code and delete it;

public void setMyLocationButtonEnabled(View v) {
    if (!checkReady()) {
        return;
    }
    // Enables/disables the my location button (this DOES NOT enable/disable the my location
    // dot/chevron on the map). The my location button will never appear if the my location
    // layer is not enabled.
    mUiSettings.setMyLocationButtonEnabled(((CheckBox) v).isChecked());
}

public void setMyLocationLayerEnabled(View v) {
    if (!checkReady()) {
        return;
    }
    // Enables/disables the my location layer (i.e., the dot/chevron on the map). If enabled, it
    // will also cause the my location button to show (if it is enabled); if disabled, the my
    // location button will never show.
    mMap.setMyLocationEnabled(((CheckBox) v).isChecked());
}
answered 2013-01-17T10:25:52.267
2

Have you tried something like this?

<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/backgroundMap"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        map:uiZoomControls="false"
        map:uiCompass="false"
        class="com.google.android.gms.maps.SupportMapFragment"/>

It effectively removes all the default UI off my maps except for the UI related to markers. Check this link for more info.

EDIT

Replying to OP's comment, id advise using a custom location algorithm instead of letting the google maps API take over. I've done it before and its not overly painful, i just put a marker on the map to let the user know where he is, and make the marker draggable so the user can refine his position manually.

Check this link.

answered 2013-01-17T09:59:48.500

Your Answer