Disable center button in MyLocation at Google Map API V2

后端 未结 3 1735
忘掉有多难
忘掉有多难 2020-12-14 01:05

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

相关标签:
3条回答
  • 2020-12-14 01:31

    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());
    }
    
    0 讨论(0)
  • 2020-12-14 01:32

    After calling the following methods on your GoogleMap object:

    map.setMyLocationEnabled(true);
    map.getUiSettings().setMyLocationButtonEnabled(false);
    

    you should see the current location indicator (the blue circle), but no control to center the map on that location.

    0 讨论(0)
  • 2020-12-14 01:33

    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.

    0 讨论(0)
提交回复
热议问题