공부를 위해 포스팅 된 글이므로, 부정확한 정보를 포함하고 있음을 감안하고 읽어주시기 바랍니다.

 

오늘은 구글 맵에서 기본적으로 제공되는 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;
    }

 

 

+ Recent posts