공부를 위해 포스팅 된 글이므로, 부정확한 정보를 포함하고 있음을 감안하고 읽어주시기 바랍니다.
오늘은 구글 맵에서 기본적으로 제공되는 UI 버튼들을 커스텀 해서 사용하고, 활성화, 비활성화
하는 작업을 했다.
https://developers.google.com/maps/documentation/android-sdk/controls
Controls and Gestures | Maps SDK for Android | Google Developers
Using the Maps SDK for Android, you can customize the way in which users can interact with your map, by determining which of the built in UI components appear on the map and which gestures are allowed. Code samples The ApiDemos repository on GitHub include
developers.google.com
기본적으로 GoogleMap 객체에서 GetUISettings() 를 호출해서 버튼들을 얻어 올 수 있으나,
위치를 설정하기가 너무 불편해서 직접 레이아웃에 버튼을 생성하여 이벤트를 걸어줬다.
btn_myLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(mCurrentLocatiion.getLatitude(),mCurrentLocatiion.getLongitude())));
}});
btn_zoomIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { mGoogleMap.animateCamera(CameraUpdateFactory.zoomIn());}});
btn_zoomOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { mGoogleMap.animateCamera(CameraUpdateFactory.zoomOut()); }});
@Override
public void onLocationChanged(Location location) {
currentPosition
= new LatLng( location.getLatitude(), location.getLongitude());
// Log.d(TAG, "onLocationChanged : ");
String markerTitle = getCurrentAddress(currentPosition);
String markerSnippet = "위도:" + location.getLatitude()
+ " 경도:" + location.getLongitude();
//현재 위치에 마커 생성하고 이동
setCurrentLocation(location, markerTitle, markerSnippet);
mCurrentLocatiion = location;
}
'Android' 카테고리의 다른 글
[Android Studio] 안드로이드 스튜디오 테마 변경, 외부 테마 적용 (1) | 2021.04.25 |
---|---|
[안드로이드 스튜디오] 소프트키보드가 레이아웃에 영향을 줄 때 해결방법 (0) | 2020.08.31 |
[안드로이드 스튜디오] 앱 종료 후 재시작 시에 튕김, 비정상 종료 될 때 (0) | 2020.07.15 |
[안드로이드 스튜디오] Glide에서 가져온 이미지가 안 보일때 (0) | 2020.03.19 |
[안드로이드 스튜디오] 구글 맵 API DB에서 얻은 값으로 마커 찍기 (0) | 2020.02.05 |