-2

I am using Google Maps API in my android app and I want to change the appearance of my location button from the old one with square to the new round material design icon.

Current one:
old

I wanna change it to this one:

new

Also, how do I change its position from upper right corner to bottom right corner?

Below is my code for XML file:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bhoiwala.locationmocker.MapsActivity" >
  <fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/map"
  android:name="com.google.android.gms.maps.SupportMapFragment"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />
</FrameLayout>    

Below is the code on how I'm using it:

 private void updateLocationUI() {
    if (mMap == null) {
        return;
    }

    if (mLocationPermissionGranted) {
        mMap.setMyLocationEnabled(true);
        mMap.getUiSettings().setMyLocationButtonEnabled(true);
    }

Thank you :)

Parth Bhoiwala
  • 1,282
  • 3
  • 19
  • 44

2 Answers2

1

you can change to

 mMap.setMyLocationEnabled(false);

Create your own icon and change the location on click event

Bharatesh
  • 8,943
  • 3
  • 38
  • 67
Lovekesh
  • 125
  • 11
  • I'd like to point out that you can simply disable the button in UI after calling mMap.setMyLocationEnabled(false); so then: mMap.getUiSettings().setMyLocationButtonEnabled(false); This effectively hides the button while still allowing you to start/stop location updates in your own fab onclick – Zach Jan 08 '17 at 23:21
0

Add marker in your latLng points of map.Paste the custom image in drawable folder then call like this

Marker marker = mMap.addMarker(new MarkerOptions().position( latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.customicon)));
Maveňツ
  • 1
  • 12
  • 50
  • 89
sasikumar
  • 12,540
  • 3
  • 28
  • 48