Always show map marker title in Android

前端 未结 6 2285
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 04:18

I\'m adding default Marker to GoogleMap the following way:

GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.editMapMap)).getMap();

         


        
6条回答
  •  暖寄归人
    2020-12-06 04:38

    There are two methods for showing and hiding the markers. The boolean return value simply prevents the default behaviour from taking place (false) or allows it to happen (true). In other words, it informs the system whether you consumed the event or not. See Google API Reference.

    private GoogleMap.OnMarkerClickListener onMarkerClickedListener = new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            if (marker.isInfoWindowShown()) {
                marker.hideInfoWindow();
            } else {
                marker.showInfoWindow();
            }
            return true;
        }
    };
    
    mGoogleMap.setOnMarkerClickListener(onMarkerClickedListener);
    

提交回复
热议问题