和其他地图一样,都要先去官网注册成为开发者,然后获取Key。下面直接上代码。
效果图:

- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
-
- <com.amap.api.maps.MapView
- android:id="@+id/map"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- </com.amap.api.maps.MapView>
-
- <ToggleButton
- android:id="@+id/tb"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="top|right"
- android:textOff="普通地图"
- android:textOn="卫星地图"
- android:checked="false"
- android:background="@android:color/transparent"
- />
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:orientation="horizontal"
- >
- <Button
- android:id="@+id/near"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="附近"
- android:layout_weight="1"
- android:background="@android:color/transparent"
- />
- <Button
- android:id="@+id/route"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="路线"
- android:background="@android:color/transparent"
- android:layout_weight="1"
- />
- <Button
- android:id="@+id/my"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="我的"
- android:background="@android:color/transparent"
- android:layout_weight="1"
- />
- </LinearLayout>
- </FrameLayout>
转载:http://blog.csdn.net/chaoyu168/article/details/51375159