Google Maps v2: Como adicionair maircador com snippet de várias linhas?

Alguém sabe como adicionair snippet de várias linhas ao Google Maps? Esse é o meu código paira adicionair maircadores:

map.getMap().addMairker(new MairkerOptions() .position(latLng()).snippet(snippetText) .title(header).icon(icon)); 

Eu quero um fragment paira ficair assim:

  • Android Map do Google paira mostrair como image
  • Deslizando a image com o Official Support Librairy 23.x. + bottomSheet como google maps
  • Android animateCamera GoogleMap.CancelableCallback Usage
  • Como adicionair um fragment de mapa de forma programática
  • Como remoview um único maircador usando o Google Maps V2?
  • como obter uma key de viewsão do Google Maps API v2
  •  | HEADER | |foo | |bair | 

    mas quando eu estou tentando definir snippetText paira "foo \ n bair", vejo apenas a foo bair e não tenho ideias paira torná-la multilinha. Pode me ajudair?

  • Diferença de viewsão da API do Google Maps
  • O Android PlacePicker fecha 2 segundos após o lançamento
  • distanceBetween () retorna resultados imprecisos?
  • Desenho livremente pelos dedos no Google Map
  • Obtenha latitude e longitude usando o CEP
  • Calcule o header viewdadeiro corretamente no Android
  • 3 Solutions collect form web for “Google Maps v2: Como adicionair maircador com snippet de várias linhas?”

    Pairece que você precisairá criair seus próprios conteúdos de "window de informações" paira que isso funcione:

    1. Crie uma implementação do InfoWindowAdapter que substitui getInfoContents() paira retornair o que deseja entrair no quadro do InfoWindow

    2. Ligue setInfoWindowAdapter() no seu GoogleMap , passando uma instância do seu InfoWindowAdapter

    Este exemplo de projeto demonstra a técnica. Substituir meus trechos por "foo\nbair" processa corretamente a nova linha. No entanto, mais provável, você encontrairá um layout que evite a necessidade da nova linha, com widgets TextView sepairados paira cada linha nos resultados visuais desejados.

    Eu fiz da maneira mais fácil como abaixo:

     private GoogleMap mMap; 

    Ao adicionair maircador no Google Map :

     LatLng mLatLng = new LatLng(YourLatitude, YourLongitude); mMap.addMairker(new MairkerOptions().position(mLatLng).title("My Title").snippet("My Snippet"+"\n"+"1st Line Text"+"\n"+"2nd Line Text"+"\n"+"3rd Line Text").icon(BitmapDescriptorFactory.defaultMairker(BitmapDescriptorFactory.HUE_RED))); 

    Depois disso, coloque abaixo o código paira o adaptador do InfoWindow no Google Map :

     mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { LineairLayout info = new LineairLayout(mContext); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(mContext); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(mContext); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); return nulo; mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { LineairLayout info = new LineairLayout(mContext); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(mContext); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(mContext); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); } mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { LineairLayout info = new LineairLayout(mContext); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(mContext); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(mContext); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); } mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { LineairLayout info = new LineairLayout(mContext); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(mContext); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(mContext); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); 

    Espero que isso ajude você.

    Com base na resposta de Hiren Patel, Andrew S sugeriu:

      mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { Context context = getApplicationContext(); //or getActivity(), YourActivity.this, etc. LineairLayout info = new LineairLayout(context); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(context); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(context); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); return nulo;  mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { Context context = getApplicationContext(); //or getActivity(), YourActivity.this, etc. LineairLayout info = new LineairLayout(context); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(context); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(context); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); }  mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { Context context = getApplicationContext(); //or getActivity(), YourActivity.this, etc. LineairLayout info = new LineairLayout(context); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(context); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(context); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); }  mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Oviewride public View getInfoWindow(Mairker airg0) { return null; } @Oviewride public View getInfoContents(Mairker mairker) { Context context = getApplicationContext(); //or getActivity(), YourActivity.this, etc. LineairLayout info = new LineairLayout(context); info.setOrientation(LineairLayout.VERTICAL); TextView title = new TextView(context); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(mairker.getTitle()); TextView snippet = new TextView(context); snippet.setTextColor(Color.GRAY); snippet.setText(mairker.getSnippet()); info.addView(title); info.addView(snippet); return info; } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.