从谷歌地图标记传递数据?

时间:2013-11-14 07:54:39

标签: android google-maps

如何通过点击标记infowindow将动态数据(如用户代码)从一个活动传递到另一个活动

for(int pin=0; pin<userData.size(); pin++)
          {
              BitmapDescriptor icon;
              if(  userData.get(pin).userloginSTS==1)
              {
                 icon = BitmapDescriptorFactory.fromResource(R.drawable.greenpin);
              }
              else
              {
                  icon = BitmapDescriptorFactory.fromResource(R.drawable.redpin);
              }

              LatLng pinLocation = new LatLng(userData.get(pin).userlat,userData.get(pin).userlon);
              Marker storeMarker = mMap.addMarker(new MarkerOptions()
              .position(pinLocation )
              .icon(icon)
              .title(userData.get(pin).userName)
              .snippet(GetAddress(userData.get(pin).userlat, userData.get(pin).userlon))
              );
              storeMarker.showInfoWindow();

              final int usercod =userData.get(postion).userCode;
              mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {                          
                  @Override

                  public void onInfoWindowClick(Marker arg0) {




                      Intent intent = new Intent(DataClass.this,test.class);
                      intent.putExtra("usercod", usercod);
                      startActivity(intent); 
                  }
              });

          }

点击信息窗口,每当有任何解决方案时,它都会发送最后一个用户值

1 个答案:

答案 0 :(得分:2)

  googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {                          
                        @Override

                        public void onInfoWindowClick(Marker arg0) {

                            Bundle bundle = new Bundle();
                            bundle.putString("mId",Data);
                            Intent intent = new Intent();
                            intent.setClass(ctx, YourClass.class);
                            intent.putExtra("mDetails", bundle);
                            startActivity(intent);
                        }
                    });