Home » Android » How can I add button on MapView android

How can I add button on MapView android

Posted by: admin May 14, 2020 Leave a comment

Questions:

As you can see from the question I need to put some button on mapView, where the app will by presing the button by user, refresh the mapView with current location.
I know how to put the button above, under, but how to put on map???
If anyone has some sample code, or some guidance help is appreciated…

How to&Answers:

You’ll want to use a RelativeLayout and lay the button over top of the MapView. Just make sure not to place it over the Google logo. Here’s a sample XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <com.google.android.maps.MapView android:id="@+id/google_maps"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="@string/maps_key"/>
    <Button android:id="@+id/googlemaps_select_location"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:text="Select"/>
</RelativeLayout>

Answer:

Hi man search for overlay item is what you need 😀 here google link
http://developer.android.com/resources/tutorials/views/hello-mapview.html

and good sample 😀

https://github.com/jgilfelt/android-mapviewballoons