Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add button on MapView android

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...

like image 938
Jovan Avatar asked Aug 25 '11 15:08

Jovan


2 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>
like image 186
hooked82 Avatar answered Sep 20 '22 08:09

hooked82


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

and good sample :D

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

like image 23
PedroAGSantos Avatar answered Sep 21 '22 08:09

PedroAGSantos