Ao abrir o mapa, na MainActivity, exibo alguns pinos na tela(markerOptions), conforme códigos abaixo:
WAPIService.getInstance().getPontosMapeamento(latitude, longitude, new FutureCallback<List<MapPins>>() {
@Override
public void onSuccess(List<MapPins> result) {
for (MapeamentoColaborativo mapPin : result){
showMapPins(mapPin.getLat_Pino(),mapPin.getLng_Pino(),mapPin.getPino(),mapPin.getAddress());//getAddress no formato para exibicao
}
}
@Override
public void onFailure(Throwable throwable) {
Toast.makeText(activity.getApplicationContext(), "Ocorreu algum problema", Toast.LENGTH_SHORT).show();
}
});
}
});
showMapPins:
...
protected GoogleMap map;
...
private void showMapPins(double lat, double lng, String pin, String address) {
LatLng location = new LatLng(lat, lng);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(location);
switch (pin) {
case "1":
map.addMarker(new MarkerOptions().position(location).title("Marker1").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_one)));//TODO exibir endereço
break;
case "2":
map.addMarker(new MarkerOptions().position(location).title("Marker2").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_two)));
break;
case "3":
map.addMarker(new MarkerOptions().position(location).title("Marker3").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_three)));
break;
case "4":
map.addMarker(new MarkerOptions().position(location).title("Marker4").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_four)));
break;
case "5":
map.addMarker(new MarkerOptions().position(location).title("Marker5").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_five)));
break;
case "6":
map.addMarker(new MarkerOptions().position(location).title("Marker6").icon(BitmapDescriptorFactory.fromResource(R.drawable.mk_six)));
break;
}
}
Como posso colocar este endereço como um "sub-titulo" para aparecer ao se clicar no marcador no mapa? .title("Marker1\n"+address) -> não funciona.