Google Map InfoWindow上的多个按钮事件在Android上不起作用

时间:2019-03-27 13:36:30

标签: android google-maps google-maps-markers infowindow

我正在尝试实现链接中提供的功能,可以在其中添加自定义按钮到信息窗口。I have changed my code according to the link given above but its does not perform the action as its desire to. It keep clicking the whole window.

下面是我的代码

在地图上添加标记:

Marker marker =  mMap.addMarker(new MarkerOptions()
            .title("India")
            .snippet("New Delhi")
            .position(new LatLng(20.59, 78.96)));
marker.setTag(TYPE_ROUTEREPLY_ACTIVITY);

在标记上单击:

@Override
public boolean onMarkerClick(final Marker marker) {
      mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(getLayoutInflater(), this,mMap, mapWrapperLayout));
      return false;
}

适配器代码:

View popup = inflater.inflate(R.layout.route_replay_map_info_window, null);
button = (Button)popup.findViewById(R.id.button);
infoButtonListener = new OnInfoWindowElemTouchListener(button,
                routeReplayActivity.getResources().getDrawable(R.drawable.ic_launcher),
                    routeReplayActivity.getResources().getDrawable(R.drawable.ic_launcher)) {
                @Override
                protected void onClickConfirmed(View v, Marker marker) {
                    int dsa =2;
                }
            };
button.setOnTouchListener(infoButtonListener);

popup.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
    }
});

mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
    @Override
    public void onInfoWindowClick(Marker marker) {

    }
});

infoButtonListener.setMarker(marker);

// We must call this to set the current marker and infoWindow references
// to the MapWrapperLayout
mapWrapperLayout.setMarkerWithInfoWindow(marker, popup);

marker.setInfoWindowAnchor(0.5f, 0.5f);
return popup;

0 个答案:

没有答案