Relocate Google logo in MapView

后端 未结 8 1577
迷失自我
迷失自我 2020-11-30 06:00

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

相关标签:
8条回答
  • 2020-11-30 06:08

    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.

    Screenshot of MapView

    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.

    0 讨论(0)
  • 2020-11-30 06:10

    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.

    0 讨论(0)
  • 2020-11-30 06:15

    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.

    0 讨论(0)
  • 2020-11-30 06:16

    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

    0 讨论(0)
  • 2020-11-30 06:21

    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.

    0 讨论(0)
  • 2020-11-30 06:23

    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.

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