所以这是我在地图中的两个循环,当我单击 setoninfowindow 时,我只会在新屏幕中获得 first.class。说如果我单击一个标记,它必须转到 first.class,如果我单击另一个标记,它必须转到 second.class
第一个循环
for (HashMap<String, Object> data : firstLoop) {
final String regno = (String) data.get(REG_NO);
String dname = (String) data.get(CAR);
final String driver_ph = (String) data.get(MOBILE);
longt=Float.parseFloat((String) data.get(LONGITUDE));
lat=Float.parseFloat((String) data.get(LATITUDE));
map.addMarker(new MarkerOptions()
.position(new LatLng(lat, longt))
.title("title2")
.snippet(name)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.pin_car)));
map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Intent in=new Intent(getApplicationContext(),second.class);
startActivity(in);
}}); }
第二循环
for (HashMap<String, Object> data : secondloop) {
String reg = (String) data.get(ID);
longt=Float.parseFloat((String) data.get(1_LONGITUDE));
lat=Float.parseFloat((String) data.get(1_LATITUDE));
map.addMarker(new MarkerOptions()
.position(new LatLng(lat, longt))
.title("title1")
.snippet(reg)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.pin_car)));
map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Intent in=new Intent(getApplicationContext(),first.class);
in.putExtra("driverid", marker.getSnippet());
startActivity(in); }}); }