在android api v2中没有显示infowindow

时间:2014-10-31 15:38:39

标签: android google-maps marker

这是我的代码:

public class A_mapaAmigos extends FragmentActivity  {
    public GoogleMap mapa;
    ArrayList<Marker> marcadores;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.a_mapaamigos);
        mapa=((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapamigos)).getMap();

        marcadores=new ArrayList<Marker>();


         Bundle bundle = getIntent().getExtras();
         if(bundle!=null)
         {
             Lugar milugar=(Lugar)bundle.getSerializable("lugar");
             LatLng pos=new LatLng(milugar.getLatitud(), milugar.getLongitud());
             Marker mimarca=AgregarMarca(pos, milugar.getNombre(), milugar.getDescripcion());
             marcadores.add(mimarca);
             CameraUpdate cu=CameraUpdateFactory.newLatLngZoom(mimarca.getPosition(),17);
             mapa.moveCamera(cu);

         }


    }



public Marker AgregarMarca(LatLng pos, String nombre,String Descripcion)
{
    BitmapDescriptor icono= BitmapDescriptorFactory.fromResource(R.drawable.marker);
    Marker mMarcador=  mapa.addMarker(
        new MarkerOptions()
        .position(pos)
        .title(nombre)
        .snippet(Descripcion)
        .icon(icono)
    )
    ;
    mMarcador.showInfoWindow();
    return mMarcador;
}

只有当加载地图标记没有任何信息窗口时才显示,告诉我欣赏我的错误或者这是一个错误?

原谅我的英语,但我是西班牙裔,我正在使用翻译,感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

如果此标记为隐藏(),则在地图上显示此标记的信息窗口。

     if( mMarcador.isVisible())
        {
            mMarcador.showInfoWindow();
        }
     else {
             Log.d(.......);
        }

尝试一个简单的标记并触摸它以查看是否出现infoWindow。

static final LatLng MELBOURNE = new LatLng(-37.81319, 144.96298);
Marker melbourne = mMap.addMarker(new MarkerOptions()
                          .position(MELBOURNE)
                          .title("Melbourne"));
melbourne.showInfoWindow();