1

I have a layout with an embedded map fragment that has a default address marked each time. When the user clicks on the marker, two buttons pop up by default to send the user out to the google maps app either as a static request or as a directions request. These buttons seem to be there by default on Maps SDK (right next to the zoom in/out keys). map with error message

The problem arises when I run my app on an Android Go device that has Maps Lite installed instead of the regular version of Google Maps. In that case, the button to send the user to the external app seems to be searching for the normal google apps package and upon not finding it, displays a toast with the following warning: “Google maps is not installed or is disabled”.

Is there a way to change that default behaviour and have the button open Maps Lite instead? I have already added my own click listener in order to manually send the user out to the appropriate app using the relevant package. If I can’t change the Maps’ behaviour, is there a way to prevent those two buttons from showing altogether and allow my own click listener to navigate the user accordingly?

Edit regarding strikethrough: I did find that I can prevent the buttons from showing with the following line:

 googleMap.getUiSettings().setMapToolbarEnabled(false);

The original question still stands though.

The layout of my activity is a simple Constraint layout that includes the map fragment:

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
<!-- Other textViews -->
        <fragment
            android:id="@+id/event_map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="0dp"
            android:layout_height="150dp"
            android:layout_marginTop="24dp"
            app:layout_constraintEnd_toEndOf="@id/event_title"
            app:layout_constraintStart_toStartOf="@id/details_header"
            app:layout_constraintTop_toBottomOf="@id/event_description" />

</androidx.constraintlayout.widget.ConstraintLayout>

My activity:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event);
        mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.event_map);
        if (mapFragment != null) {
            mapFragment.getMapAsync(this);
        }
//...
 @Override
public void onMapReady(GoogleMap googleMap) {

    googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    googleMap.getUiSettings().setZoomControlsEnabled(true);

    if (hasMap) {
        LatLng location;
        location = new LatLng(coordinates[0], coordinates[1]);

        if (location != null) {
            googleMap.addMarker(new MarkerOptions().position(location).title(eventsTitle));
            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 14.0f));
        }
    }
}
}
Nikos Hidalgo
  • 3,666
  • 9
  • 25
  • 39

1 Answers1

0

I have not tried this myself yet and I'm not in anyway familiar with maps lite but have you tried launching maps lite using an intent?

If you're not sure how to do this take a look at this question however it may be slightly different and it's also possible that as part of the lite version not possible at all.

if you are able to get it working using an intent then you could just create your own buttons and overlay those instead while hiding the toolbar

Here's the android documentation if you need some more information on how the intents work

  • My problem is not launching Maps lite using my code. As I mention I have a click listener that does exactly that. The problem is that the buttons that appear as part of the Map Tools (they're not created by me) have a predefined intent (as defined in the Maps SDK) that searches for Maps and not Maps lite. I'm wondering whether there's a way to access that intent and edit it accordingly, as I wouldn't have to create a functionality that's already provided. – Nikos Hidalgo Dec 17 '19 at 12:22