Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- Menu
- Graphic
- OGNL
- layout
- 안드로이드
- Android
- paint
- 기본
- Java
- Eclips
- mybatis
- 전화걸기
- JavaScript
- 에러페이지
- 배열
- struts2
- 생성자
- 국제화
- 어노테이션
- 예외처리
- Spring
- 메소드
- 메서드
- AWT
- 이클립스
- oracle
- 오버로딩
- JSP
- 클래스
- HTML
Archives
- Today
- Total
note
구글맵 사용하기 본문
위치를 직접 지정할 수 있습니다 (위도 경도)
manifext.xml 에 Uses Library 셋팅을 해야합니다
Uses Library(manifext -> application)
apiKey는 자신의 apikey를 입력하면 됩니다
<?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" >
<com.google.android.maps.MapView
android:id="@+id/map"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="" />
</LinearLayout>
GeoPoint값을 자신이 직접 지정할 위치로 해도 됩니다 이전 게시물 참고
package kr.android.map;
import android.os.Bundle;
import android.widget.ImageView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;
public class GoogleMaps extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.map);
//위도, 경도 정보를 갖는 객체 생성
//위도, 경도는 실수 정보를 갖는데 연산 속도를 높이기 위해서 정수로 변환시켜 처리
GeoPoint gp = new GeoPoint((int) (27.173095 * 1000000.0),
(int) (78.04209 * 1000000.0));
//지도에 마커를 표시하기 위해서 LayoutParams 객체 생성
MapView.LayoutParams mapParams = new MapView.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, gp,
MapView.LayoutParams.CENTER);
//마커 정보를 갖는 ImageView 객체 생성
ImageView iv = new ImageView(getApplicationContext());
iv.setImageResource(R.drawable.marker);
//MapView에 마커 표시를 위해 ImageView와 LayoutParams객체 등록
mapView.addView(iv, mapParams);
//지정한 위도와 경도를 보여주는 지도를 화면에 출력
mapView.getController().animateTo(gp);
//줌레벨 지정(배율 1~ 21 )
mapView.getController().setZoom(16);
//줌 레벨을 조정할 수 있는 Control 사용 여부 셋팅
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// 사용하지 않음(추상 메소드)
//두 지점간의 거리 표시를 위한 메소드
return false;
}
}
'Android > 기본' 카테고리의 다른 글
| Intent 사용하여 화면 이동 (0) | 2012.01.17 |
|---|---|
| 구글맵에 마커 표시하기(위치 지정) (2) | 2012.01.17 |
| 이클립스 구글맵 api 설치하기 및 자신의 위치 알아내기(경도,위도) (0) | 2012.01.17 |
| SQLite (0) | 2012.01.13 |
| SD CARD (SD 카드에 저장하기) (0) | 2012.01.13 |