Relocate Google logo in MapView

Viewed 22815

I have two buttons at each bottom corners of the MapView, partly obscuring the google logo in the bottom-left corner.

In order to comply with the terms and conditions of the API, I need to relocate the google logo to somewhere more visible. i.e. above the button.

The google API doc states that the google logo is drawn in the onDraw() method of MapView but I have no idea how to override it properly since google maps is closed source.

I could do this in iPhone by finding the correct UIView in the MKMapView's children but I can't figure out how I could do this in Android.

8 Answers

You can move the google logo with the help of the Tag assigned to it GoogleWatermark. In the below code i have moved it to top right corner of the screen.

View googleLogo = binding.missionMap.findViewWithTag("GoogleWatermark");
RelativeLayout.LayoutParams glLayoutParams = (RelativeLayout.LayoutParams)googleLogo.getLayoutParams();
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_START, 0);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
glLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE);
googleLogo.setLayoutParams(glLayoutParams);

where missionMap is the framelayout to which the MapFragment has been added.

I achieved this by doing the following.

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginBottom="-30dp"
  android:layout_marginTop="-30dp">

   <fragment
      android:id="@+id/map_frag_main"
      android:name="com.google.android.gms.maps.SupportMapFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity" />

</RelativeLayout>

This will clip away the Google logo and no need for padding, just make sure you add a drawable or you will be violating TOS.

Kind of a hack, but you could try add a MapView it to a FrameLayout, setting the height of the MapView X dp larger than the FrameLayout so it gets clipped off, and adding a Logo Drawable wherever you wanted it to be.

You don't have anything to do but using padding on GoogleMap object as stated by google maps documentation Note: As per the Google Maps Platform Terms of Service, your application must not remove or obscure the Google logo or copyright notices. Map padding allows you to reposition these elements if necessary. If you display a custom UI at the bottom of the map, add padding to the bottom of the map so that the logo and legal notices will always be visible.

Related