Relocate Google logo in MapView

后端 未结 8 1578
迷失自我
迷失自我 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:26

    Really old question, but maybe someone will make use of it. I made it to appear in right upper corner:

    Rect rect = new Rect()
    mMapView.getLocalVisibleRect(rect)
    googleMap.setPadding(rect.width() - 100, 0, 0, rect.height() - 50)
    

    If you want to place it somewhere else, you will need to have fun with setPadding

    Also don't forget to hide UI buttons of google maps:

    googleMap.getUiSettings().setMapToolbarEnabled(false)
    googleMap.getUiSettings().setZoomControlsEnabled(false)
    googleMap.getUiSettings().setMyLocationButtonEnabled(false)
    

    There is one (at least) problem. When using camera to center map on given point will not work properly. If camera movement is needed it will be better to just set padding to visible map fragment and it should work properly. Use rect to know what dimensions to put into setPadding

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

    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.

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