「
Googleマップを表示する」を参照し, Googleマップが表示できるようにする.
レイアウトXMLで, fragmentタグ内にmapから始まるプロパティを利用する.
- res/layout/activity_main.xml
注) XMLファイル内のroot elementで指定する.
- map:mapTypeプロパティに, "satellite" or "hybrid"を設定する. (デフォルト"normal")
normal | 道路, 建物や重要な自然の物, 川等が名称とともに表示される |
satellite | 衛星写真 |
hybrid | 衛星写真の上に、道路や建物等と名称が表示される |
terrain | 地形図. 全てではないが、いくつかの道路と名称が表示される |
none | なし |
注) mapプロパティを設定した場合, "Unexpected namespace prefix "map" found for tag fragment"が発生する場合がある.
そのときは, Project > Cleanを実行する.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraTargetLat="35.41"
map:cameraTargetLng="139.41"
map:cameraZoom="10"
map:mapType="hybrid"
/>
</RelativeLayout>
SHARP SH-03C / Android 2.2