앱
[안드로이드] 구글 맵 API(Google Maps API) - 2
oraclian
2016. 9. 9. 18:52
오늘은 실제로 어플에 Google Map을 띄우는 프로그램을 작성해 보겠습니다.
이전 강의에서 구글 키를 발급받는 과정을 수행하고 키를 Manifest에 넣어 보았습니다.
이번 강의를 시작 하기전에 먼저 구글 라이브러리를 먼저 불러 온 뒤 구글 맵을 추가하여 보겠습니다.
1. 구글 맵을 불러오기 전에 왼쪽 상단의 File -> Project Structure 를 찾아 들어갑니다.
2. app -> Dependencies 이동하여 오른쪽에 플러스를 클릭하셔서 play-servieces 로 라이브러리를 검색합니다.
3.play-services로 검색하면 com.google.android.gms.play-services:9.4.0이 보입니다. 추가합시다.
4. 추가 되었습니다. OK를 눌러 창을 닫습니다.
이제 실제로 지도를 넣어 보겠습니다.
xml 파일에서 아래의 소스를 삽입합니다.
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
짜잔 실행됩니다!
여기까지가 지도를 띄워 보는 것이였습니다.
안되거나 잘못된게 있을경우 덧글남겨주세요!!