안드로이드 구글 맵 연동

안드로이드에서 구글 맵을 연동하는 것은 매우 쉽다.

안드로이드에서 구글 맵을 연동하기 위해서는 다음과 같이 몇 가지만 처리하면 된다.

따라하기 식으로 기술 하였으니 쉽게 적용 할 수 있을 것이다.

다음과 같이 프로젝트를 생성한다.

image

image

image

AndroidManifest.xml을 다음과 같이 생성한다.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.coolsharp"
    android:versionCode="1"
    android:versionName="1.0" > 
 
    <uses-sdk android:minSdkVersion="8" /> 
 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" /> 
 
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".Coolsharp_googleMAPActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" /> 
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity> 
 
        <uses-library android:name="com.google.android.maps" android:required="true" />
    </application> 
 
</manifest>

퍼미션과 라이브러리를 추가한다.

 



package com.coolsharp; 
 
import android.os.Bundle; 
 
import com.google.android.maps.MapActivity; 
 
public class Coolsharp_googleMAPActivity 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() {
        // TODO Auto-generated method stub
        return false;
    }
}
MapActivity에서 상속 받게 수정한다.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" > 
 
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
        <com.google.android.maps.MapView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="발급받은 키" /> 
 
</LinearLayout> 

구글 사이트에서 발급받은 키를 추가한다.

빌드하고 설치하면 다음과 같은 화면이 나온다.

image

댓글

이 블로그의 인기 게시물

ViewPager offscreenPageLimit 메모리 상태

eskimo esim 사용기 - 일본 / 오사카(23/08/06 ~ 23/08/08)

ASP에서 C# 언어로 만든 DLL 호출