我对Google Maps v2有疑问。当用户点击地图上唯一的标记时,我将显示自定义对话框。但唯一发生的事情是,它将地图集中在标记上。
以下是代码:
public class where extends FragmentActivity implements OnMarkerClickListener{
private final LatLng STARTING_POINT=new LatLng(37.5****, 14.2****);
Marker marker;
TextView testo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mappa);
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.moveCamera(CameraUpdateFactory.newLatLngZoom(STARTING_POINT, 5));
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
//zoom che dura 2 secondi
map.animateCamera(CameraUpdateFactory.zoomTo(19), 3000, null);
map.setOnMarkerClickListener(this);
marker = map.addMarker(new MarkerOptions().position(STARTING_POINT).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
}
@Override
public boolean onMarkerClick(Marker marker) {
if(this.marker == marker){
AlertDialog.Builder alertadd = new AlertDialog.Builder(dovesiamo.this);
LayoutInflater factory = LayoutInflater.from(dovesiamo.this);
final View view = factory.inflate(R.layout.alert, null);
alertadd.setView(view);
alertadd.show();
}
return false;
}
答案 0 :(得分:2)
更改
if(this.marker == marker)
到
if(this.marker.equals(marker))