1
When opening the map, in Mainactivity, I display some pins on the screen (markerOptions), as codes below:
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;
}
}
How can I set this address as a "sub-title" to appear when clicking the marker on the map? . title("Marker1 n"+address) -> does not work.