答案 0 :(得分:1)
尝试这样......
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();
}
}
}
答案 1 :(得分: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;
}
});
}