프로그래밍

코린이 질문좀...

코틀린에서 구글맵 가져다 쓰려고 하는데

 

xml에서 누구는 Fragment 쓰고 누구는 MapView 가져다 쓰고 또 누구는 FragmentContainerView를 가져다 쓰는데...

MapView를 가져다 쓰면 화면이 안 나오고

Fragment를 가져다 쓰면 해당 뷰를 찾을 수가 없다고 나와서 계속 안 된다...

 

예를들어 

<Fragment 

````android:id="@+id/GoogleMap"

````~~/>

해놓고 비하인드 코드 가서

binding.GoogleMap 하거나 R.id.GoogleMap 하면 선언되지 않은거라며 찾지를 못 하는데 어떻게 함?

 

---- UI ----

 

 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:background="@color/TermicaGrey"
    >
 
    <LinearLayout
        android:id="@+id/llHeader"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/GoogleMaps"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp">
 
        <ImageButton
            android:id="@+id/ibMenu"
            android:layout_width="35dp"
            android:layout_height="30dp"
            android:src="@drawable/ic_button_menu"
            android:background="@android:color/transparent"
            android:padding="2dp"
            android:scaleType="center"
            android:transitionName="slide_right_enter"
            />
 
    </LinearLayout>
 
    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/GoogleMaps"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@id/llHeader"
        app:layout_constraintBottom_toTopOf="@id/llFooter"
        />
 
    <LinearLayout
        android:id="@+id/llFooter"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="10dp"
        android:gravity="center"
        >
 
        <Button
            android:id="@+id/btnSend"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:background="@drawable/ic_button_square_corner"
            android:text="테스트 버튼"
            android:textSize="50dp"
            android:textColor="@color/black"
            android:textAlignment="textStart"
            android:fontFamily="@font/gmarket_sans_ttf_medium"
            />
    </LinearLayout>
 
</androidx.constraintlayout.widget.ConstraintLayout>
cs

23개의 댓글

2023.12.15

Fragment 쓸거면 FragmentContainerView를 권장하고

걍 맵뷰만 써도 상관은 없음

 

MapVIew써서 화면이 안나오는건 사용법 맞게 못쓴 것 같고

밑에껀 <Fragment /> 말고 <fragment /> 해보기

0
2023.12.15
@닉네임대충짓

아.. 저건 내가 잘 못쓴거야 소문자로 fragment 했음.

mapview 같은 경우는

val mapView = binding.GoogleMaps

mapView?.getMapAsync{googleMap ->

googleMap.mapType = GoogleMap.MAP_TYPE_NORMAL

 

val seoul = LatLng(37.5519, 126.9918)

googleMap.addMarker(

MarkerOptions().position(seoul).title("Marker in Seoul")

)

 

googleMap.moveCamera(CameraUpdateFactory.newLatLng(seoul))

}

 

이렇게 썻는데 그냥 아무 화면도 안 나오더라고..

0
2023.12.15
@집에가게해줘

api키 넣었믐?

0
2023.12.15
@닉네임대충짓

ㅇㅇ Manifest에

<meta-data

````android:name="com.google.android.maps.v2.API_KEY"

````android:value="~~~"/>

하고 넣었어

그런데 인터넷에 찾오빈까 다른 사람들은 키를 안 넣었을 때 좌측 하단에 Google 마크는 나오는데 화면이 안 나오고

나는 Google마크 조차도 안 나오더라고..

0
2023.12.15
@집에가게해줘

음.. 그럼 ui 풀코드좀

0
2023.12.15
@닉네임대충짓

아니면 맵뷰말고 그 자리를 그대로 이미지뷰, background red 같은걸로 해서 맞는위치에 들어갔는지 봐도될듯 ui이상한거같은데

0
2023.12.15
@닉네임대충짓

아 본문에 추가한건 FragmentContainerView 사용 버전이야!

0
2023.12.15
@닉네임대충짓

ImageView로 background black 해봤지만 화면에서는 잘 나옴

0
2023.12.15
@닉네임대충짓

본문에 추가했어

0
2023.12.15
@집에가게해줘

저긴 문제 없어보이네...

git이라도 있으면 공유해주면 전체코드 한번 보면 좋겠는데

0
2023.12.15
@닉네임대충짓

이거 공유하면 API_KEY도 공유 되는데 빼면 당연히 동작을 안 하고... 이럴 땐 어떻게 함?

그냥 나중에 API_KEY를 수정해버리면 되려나??

0
2023.12.15
@집에가게해줘

뺴고공유해주면 전체코드라도 볼 수 있을듯?

0
2023.12.15
@닉네임대충짓

https://github.com/Lee-IDLE/NotYet

그냥 나중에 삭제해버리고 다시 만들어서 쓰지 뭐...

0
2023.12.15
@집에가게해줘

인터넷 퍼미션 선언이 안됐다 개붕아

0
2023.12.15
@닉네임대충짓

미안 밥 먹느라...

혹시 지금 됨?

0
2023.12.15
@집에가게해줘

엉? 인터넷 퍼미션 넣고도 안됨?

0
2023.12.15
@닉네임대충짓

아아 미안! 잘못봤어...

퍼미션 얘기보고 "어? 리포지토리 공개 아닌가??" 하고 들어가서 봤는데

다른 리포지토리 보고서 "아 비공개였네"하고 변경하고 말한거였어.. ㅜㅜ 해볼께

0
2023.12.15
@집에가게해줘

사실 안돌려봤음나도 ㅎㅎ 인터넷 퍼미션이 일단 있긴 해야됨

그리고 이제 돌려보려고 들어오는데 빌드도 안되는걸 올려놨네;; 빌드는 되게해서 올려줘

0
2023.12.15
@닉네임대충짓

그리고 R import 해놓은게 잘못됐네

import android.R 지워

0
2023.12.15
@닉네임대충짓

내가 고쳐서 맵 뜨는거 봤는데, 브랜치에 올려줌

0
2023.12.15
@닉네임대충짓

올리는건 권한이 없구나 ㅋㅋ

 

인터넷 퍼미션 추가

import android.R 제거

FragmentContainerView 사용

 

하면됨

0
2023.12.15
@닉네임대충짓

아 ㅅㅂ R 뭐야 하아....

내가 뭘 추가시키려고 하다가 실수로 R에서 멈췄나? R로 시작하는게 뭐가 있다고 하려고 한거지

아 ㅅㅂ ㅋㅋㅋ 너무 고맙다 ㅜㅜ

1
2023.12.15

안드로이드 손 뗀지 오래되서 가물가물한데 MapView 가 삽입이 안된거같은데.

니 기존코드 보면 MapView 만 만들고 그걸 부모가 될 뷰에 삽입하지 않음.

 

0
무분별한 사용은 차단될 수 있습니다.
번호 제목 글쓴이 추천 수 날짜 조회 수
5689 [프로그래밍] 엥 구글 플러터 유기각 재는거임?? 4 최수연 0 20 시간 전 189
5688 [프로그래밍] 반도체 장비 업계인 있음? 9 캡틴띠모 0 1 일 전 210
5687 [프로그래밍] 안드로이드 책 추천좀 6 집에가게해줘 0 2 일 전 127
5686 [프로그래밍] 폰 스크리닝 해 본 사람 있어? 3 무지개빛푸딩 0 2 일 전 358
5685 [프로그래밍] jsp 트리메뉴 만들고있는데 구상한게가능한지 의견좀물어볼께 11 평택국 0 3 일 전 142
5684 [프로그래밍] JPA 도와줘어억 ㅠ 10 모그리또 0 3 일 전 223
5683 [프로그래밍] 의사는 뽑는 인원 제한하는데 부캠은 왜 제한 안 할까 5 조강현 0 5 일 전 350
5682 [프로그래밍] 그 혹시 게임쪽 종사자 있음? 17 god79ii 0 9 일 전 616
5681 [프로그래밍] 코린이 ㅅㅂ 뭐가 문젠지 모르겠어요 9 집에가게해줘 0 9 일 전 436
5680 [프로그래밍] Dear Imgui 라고 아시나요? 2 년째모쏠 0 9 일 전 240
5679 [프로그래밍] 현업개발자분들 주말엔 편하게 쉴수있나요? 10 키로 0 10 일 전 845
5678 [프로그래밍] 무엇이든 물어보세요. 28 변현제 0 12 일 전 404
5677 [프로그래밍] 개발자보단 엔지니어가 취업이 잘됨 5 iillillill 2 13 일 전 713
5676 [프로그래밍] 프론트엔드 개발자 연봉 1억 넘는 사람 있어? 13 잠적자 0 13 일 전 622
5675 [프로그래밍] Exiftool 이거 일본어 못 읽는데 13 부터시작하는이세... 0 15 일 전 231
5674 [프로그래밍] 반응형 웹페이지가 내가상상한거랑 좀 다르네 4 평택국 0 16 일 전 442
5673 [프로그래밍] 고졸 FE개발자 연봉, 상황에 조언좀.. 19 쾅꿍꿍 0 16 일 전 596
5672 [프로그래밍] 물경력들 보면 책임을 이해못하는것같음 5 mils 1 17 일 전 407
5671 [프로그래밍] GPT가 코딩 다해주네 3 겜신병자 0 18 일 전 739
5670 [프로그래밍] 크로스플랫폼의 욕심은 끝이없다 4 ye 0 20 일 전 398