地図を表示する

はじめに

AndroidGoogle Map V2を使用して、地図を表示します。

 

前提

  • AndroidStudioをインストールしておきます。
  • Google Map V2 APIキーを取得しておきます。

Get Started  |  Maps SDK for Android  |  Google Developers

 

プロジェクト作成

  • AndroidStudioを起動します。
  • 「ファイル」「新規」「新規プロジェクト」を選択します。

 

プロジェクトの選択

f:id:wanouri:20190815210744p:plain

 

プロジェクトの構成

f:id:wanouri:20190815211405p:plain

  • 「名前」「パッケージ名」「保存ロケーション」を入力します。
  • 言語は、「Java」を選択します。

 

google_map_api.xml

Google Map V2 APIキーを記述します。YOUR_KEY_HEREの箇所を書き換えします。

google_maps_api.xml

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR_KEY_HERE</string>

 

デバッグ

f:id:wanouri:20190815232506p:plain

  •  このように地図が表示されます。

f:id:wanouri:20190816154520p:plain