您需要按照以下步骤执行自定义信息窗口单击:
--> 实现“GoogleMap.OnInfoWindowClickListener”和“GoogleMap.InfoWindowAdapter”
--> 膨胀自定义信息窗口:
@Override
public View getInfoContents(Marker marker) {
// Inflate the layouts for the info window, title and snippet.
View infoWindow = getActivity().getLayoutInflater().inflate(R.layout.custom_info_contents, null);
TextView txtStoreName = ((TextView) infoWindow.findViewById(R.id.txtStoreName));
txtStoreName.setText(marker.getTitle());
TextView txtStoreAddress = ((TextView) infoWindow.findViewById(R.id.txtStoreAddress));
txtStoreAddress.setText(marker.getSnippet());
return infoWindow;
}
--> 设置监听器:// InfoWindowClick
mGoogleMap.setOnInfoWindowClickListener(this);
@Override
public void onInfoWindowClick(final Marker marker) {
// TODO Here perform action on balloon view click
mRecyclerStore.post(new Runnable() {
@Override
public void run() {
StoreModel model = (StoreModel) marker.getTag();
boolean isAddedToBackStack = true;
StoreDetailsAndProductListFragment storeDetailsAndProductListFragment = new StoreDetailsAndProductListFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(ExtrasUtil.STORE, model);
storeDetailsAndProductListFragment.setArguments(bundle);
showOtherFragment(storeDetailsAndProductListFragment, getActivity().getFragmentManager(), isAddedToBackStack);
}
});
}