2016-09-12 2 views

답변

0

이 같은 시도

...

public class MarkerDemoActivity extends Activity or FragmentActivity 
    implements OnMarkerClickListener 
{ 
private Marker myMarker;  
.............. 
private void setUpMap() 
{ 
    ....... 
    googleMap.setOnMarkerClickListener(this); 

    myMarker = googleMap.addMarker(new MarkerOptions() 
       .position(latLng) 
       .title("My Spot") 
       .snippet("This is my spot!") 
       .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); 
    ...... 
} 

@Override 
public boolean onMarkerClick(final Marker marker) { 

    if (marker.equals(myMarker)) 
    { 
     Intent intent=new Intent(MarkerDemoActivity.this,AnotherActivity.class); 
     startActivity(); 
    } 
} 
} 
+0

내 코드입니다 너의 도움을 위해 많은 anks! –

+0

괜찮아요. 불행합니다. 좋은 하루 보내세요. –

+0

작동합니다. 여러 마커를 사용하여 동일한 활동에 연결할 수 있도록하려면 어떻게해야합니까? –

0
public void onMapReady(GoogleMap googleMap) { 
     mMap = googleMap; 
     // Add a marker in Sydney and move the camera 
     LatLng chennai = new LatLng(12.9671, 80.2593); 
     mMap.addMarker(new MarkerOptions().position(chennai).title("Chennai")); 

     LatLng perungudi = new LatLng(12.97, 80.25); 
     mMap.addMarker(new MarkerOptions().position(perungudi).title("Perungudi")); 

     LatLng pallikarnai = new LatLng(12.9377, 80.2154); 
     mMap.addMarker(new MarkerOptions().position(pallikarnai).title("Pallikarnai")); 

     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(chennai,12)); 
     mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 
      @Override 
      public boolean onMarkerClick(Marker marker) { 
       if (marker.getTitle().equals("Chennai")){ 
        Intent intent = new Intent(MapsActivity.this, LoginActivity.class); 
       startActivity(intent); 
       return false; 
      } 
     }); 

    }