当我点击地图的标记时,我无法弄清楚为什么信息窗口没有出现。我在开发者 android 网站上读到,我只应该添加标记并给他们标题、片段等。但结果什么都没有。
public class ClubMapActivity extends DefaultActivity implements GoogleMap.OnMarkerClickListener {
private GoogleMap mMap;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clubmap);
Bundle bundle = getIntent().getExtras();
double lat = bundle.getDouble("latitude");
double lng = bundle.getDouble("longitude");
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(lat, lng))
.title(bundle.getString("clubNmae")).snippet("AAA"));
animateCameraTo(lat, lng);
CameraUpdate zoom=CameraUpdateFactory.zoomTo(20);
mMap.animateCamera(zoom);
}
public void animateCameraTo(final double lat, final double lng)
{
CameraUpdate center=
CameraUpdateFactory.newLatLng(new LatLng(lat, lng));
CameraUpdate zoom=CameraUpdateFactory.zoomTo(18);
mMap.moveCamera(center);
mMap.animateCamera(zoom);
}
@Override
public boolean onMarkerClick(Marker marker) {
if(marker.isInfoWindowShown()) {
marker.hideInfoWindow();
} else {
marker.showInfoWindow();
}
return true;
}
}