2010년 4월 27일 화요일

안드로이드에서 구글맵 사용하기

Using Google Maps in Android (영문 소개 기사 위치)

 http://mobiforge.com/developing/story/using-google-maps-android#comment-6387

 

  1. 프로젝트 생성

     

  2. 구글 Maps API Key 얻기

    http://code.google.com/android/add-ons/google-apis/mapkey.html
    한글로 자세히 설명해준 사이트
    http://appleandroidjunhulove.tistory.com/entry/안드로이드Android-MAP-API-KEY

     

  3.  AndroidManifest.xml 화일 수정하기 (초록색 바탕 글씨)

    1.  <?xml version="1.0" encoding="utf-8"?>
      <manifest xmlns:android="
      http://schemas.android.com/apk/res/android"
      package="net.learn2develop.GoogleMaps"
      android:versionCode="1"
      android:versionName="1.0.0">
      <application android:icon="@drawable/icon" android:label="@string/app_name">
      <uses-library android:name="com.google.android.maps" />
      <activity android:name=".MapsActivity"
      android:label="@string/app_name">
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      </activity>
      </application>
      <uses-permission android:name="android.permission.INTERNET" />
      </manifest>
     
    

  4. 맵이 보이도록 main.xml 수정하기 (apiKey는 2번에 얻은 값을 입력)

    1.  <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="
      http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

      <com.google.android.maps.MapView
      android:id="@+id/mapView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:enabled="true"
      android:clickable="true"
      android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"
      />


      </RelativeLayout>
     
    
      
    

  5.  .java화일 수정하기

    1.  package net.learn2develop.GoogleMaps;

      import com.google.android.maps.MapActivity;
      import com.google.android.maps.MapView;
      import android.os.Bundle;

      public class MapsActivity extends MapActivity
      {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      }

      @Override
      protected boolean isRouteDisplayed() {
      return false;
      }

      }

     

     

 

이 글은 스프링노트에서 작성되었습니다.

0 개의 댓글:

댓글 쓰기