请帮助我创建一个类似的界面,如实地考察应用程序,我有一个水平回收服务卡列表。我想把地图上的每一个标记都和它的卡片连接起来,当一个标记被点击时,连接到它的卡片会比其他标记移动得更高,底部的空白是20。我怎样才能做到这一点?

Override
public boolean onMarkerClick(Marker marker) {
    // TODO Auto-generated method stub
    marker=selected_marker;
    selected_marker_title=marker.getTitle();

    lm.smoothScrollToPosition(mRecyclerView, null, 3);


    return false;
}

最佳答案

有点晚了,试试这个:

map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(final Marker marker){

final LatLng markerPosition = marker.getPosition();
int selected_marker = -1;
for (int i = 0; i < YOURLIST.size(); i++) {
    if (markerPosition.latitude == YOURLIST.get(i).getMap().getLatitude() && markerPosition.longitude == YOURLIST.get(i).getMap().getLongitude()) {
        selected_marker = i;
     }
}
CameraPosition cameraPosition = new CameraPosition.Builder().target(markerPosition).zoom(12).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
YOURADAPTER.notifyDataSetChanged();
YOURRECYCLERVIEW.smoothScrollToPosition(selected_marker);

marker.showInfoWindow();

return false;

}
});

10-08 06:45