2017-10-06 18 views
-9

こんにちは私はそれをクリックすると、Googleマップのマーカーをクリックして新しい活動を開始すると問題が発生しないウィンドウがポップアップします。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; 
     } 
    }); 
} 
+7

彼らは明らかに等しくない – Selvin

+0

何だろうあなたは 'Marker'で' GoogleMap'オブジェクトを比較しようとしている。ここで

は、私が使用する全体のコードですそれを言っているのですか? –

+0

marker.equals(mMap) あなたの状態を参照してください – Namy

答えて

0
mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { 
      @Override 
      public void onInfoWindowClick(Marker marker) { 
      Intent intent = new Intent(MainActivity.this, MarkerAdded.class); 
      startActivity(intent); 


      } 
     }); 

または

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 
      @Override 
      public boolean onMarkerClick(Marker marker) { 
       if (marker.equals(yourMarkerObj))// you should compare with your marker not with the google map obj or you can normally pass the intent without condition 
{ 
        Intent intent = new Intent(MainActivity.this, MarkerAdded.class); 
        startActivity(intent); 
       } 
        return false; 
      } 
    }); 
+0

は今では、動作のおかげと申し訳ありませんが、約心のラグ。 –

+0

plzはそれを投票します.. – Namy

関連する問題