-9
嗨,大家好,我點擊Google地圖標記發起新活動時遇到問題,當我點擊它時,沒有窗口彈出。點擊谷歌地圖後,標記新的活動並不開始
這裏是整個代碼我使用:
public class MainActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
@Override
public void onMapReady(final GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (marker.equals(mMap)){
Intent intent = new Intent(MainActivity.this, MarkerAdded.class);
startActivity(intent);
}
return false;
}
});
}
您要比較'和'Marker' GoogleMap'對象,他們將是顯然不等於 – Selvin
什麼你的意思是說這個嗎? –
marker.equals(mMap) 查看您的狀態 – Namy