简体   繁体   中英

How to add click listener when user tap on marker(google map) and should show bottom sheet?

When user tap on marker a bottom sheet will appear.I'm not able to do it? Thanks in advance!

Create a bottom sheet fragment:

BottomDialogFragment bottomDialogFragment = BottomDialogFragment.getInstance();

then in your map add the following listener and launch the fragment on click:

yourMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker marker) {
                    bottomDialogFragment.show(getSupportFragmentManager(), “Bottom Sheet Fragment");

                    return true;
                }
            });

Check this if you don't know how to create the bottom dialog fragment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM