네이버맵에 제가 입력한 주소가 마커로 표시되게 하고싶습니다.
조회수 3199회
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="주소"
android:id="@+id/etmapname"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="상세주소"
android:id="@+id/etadress"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="위치조회하기"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/mapmap"
android:orientation="vertical"/>
이런식으로 xml에 주소입력창이랑 버튼을 만들었습니다. 주소랑 상세주소에 입력을 하고 조회하기 버튼을 누르면 밑에 네이버맵에 그 위치가 마커로 표시되게 하고싶습니다. 자바에는
mMapView = new NMapView(this);
mMapView.setBuiltInZoomControls(true, null);
mMapView.setClickable(true);
mMapView.setApiKey(API_KEY);
mLinearLayout = (LinearLayout)findViewById(R.id.mapmap);
mLinearLayout.addView(mMapView);
이렇게 입력해서 지도만 출력됩니다. 위에 질문드린것처럼 하려면 어떻게 코드를 작서해야 할까요? 부탁드리겠습니다.
1 답변
-
아래 링크를 보면 주소를 좌표로 반환하는 API가 있습니다.
에디트텍스트에 입력 된 주소를 이용해 위 API 호출 후 위도, 경도 좌표를 얻는 것이 첫번째입니다. 그런 후 위도, 경도를 이용해서 마커를 생성하고, 마커를 지도에 표시하면 원하는 부분을 구현할 수 있습니다.
댓글 입력