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
I had the same issue, but you can achieve what you want without conflicting with Google's Terms and Conditions. The main thing is to put your mapView in a Frame layout, such as this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout android:id="@+id/map_frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7" >
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="mySecretMapsApiKey"/>
</FrameLayout>
<ws.mentis.android.guardian.ui.MapNavBar
android:id="@+id/map_nav"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_gravity="bottom"
android:layout_weight="0.3" />
</LinearLayout>
I had a number of buttons to included, so I created them in a custom widget (MapNavBar). As you can see from the screen shot, the Google logo is still visible and in its normal place, within the new window.
This is working in Android 2.2 It also has the benefit that the standard zoom control also moves up so it doesn't interfere with your own buttons.
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.
From the documentation :
protected final void onDraw(android.graphics.Canvas canvas)
onDraw is final method. This can't be overridden at all.
You can alternatively, show your buttons below mapview in layout aligned to parent bottom. This way you can have buttons at the position where you like and it will not obscure your google logo.
Google Maps SDK v2 for Android adds this functionality.
Use GoogleMap.setPadding()
to add padding to the "active" area (including the Google logo and copyright notices) while still filling the full container.
https://developers.google.com/maps/documentation/android/map#map_padding
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.