0

I am trying to show the infoWindow when user clicks on the marker. What should I return inside Infowindow so that the default infowindow shows up when marker is clicked?Any help is greatly appreciated. Thanks in advance.

Here is the code:

    public class LocationFetcher {
    private MapView mapView;

    private List<DeliveryPersonModel> persons=new ArrayList<>();

    //Mock Deliveryboys location
    DeliveryPersonModel person1 =new DeliveryPersonModel("DiMaria",R.drawable.pic_dimaria,new LatLng(34.01885992,-118.2722854));
    DeliveryPersonModel person2=new DeliveryPersonModel("Sergio",R.drawable.pic_ramos,new LatLng(33.8537663,-117.9904174));
    DeliveryPersonModel person3=new DeliveryPersonModel("Robert",R.drawable.pic_firmino,new LatLng(33.5649706,-117.206611));

    IconFactory iconFactory;

    public void showLocations(final Context context){
        mapView= ManagerActivity.mapView;
        iconFactory=IconFactory.getInstance(context);

        persons.add(person1);
        persons.add(person2);
        persons.add(person3);

        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(final MapboxMap mapboxMap) {

                for(int i=0;i<persons.size();i++){
                    DeliveryPersonModel model=persons.get(i);
                    mapboxMap.addMarker(generateMarker(model.getName(),model.getLocation(),model.getImgPic()));
                }

                mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
                    @Nullable
                    @Override
                    public View getInfoWindow(@NonNull Marker marker) {
                        //What should I do here?
                        return null;
                    }
                });

            }
        });
    }

    private MarkerOptions generateMarker(String name,LatLng pos,int image) {
        MarkerOptions marker=new MarkerOptions();
        marker.title(name);
        marker.position(pos);
        marker.icon(iconFactory.fromResource(image));

        return marker;
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Aadhil Ahmed
  • 111
  • 15

1 Answers1

1

try to return this

return v = getActivity().getLayoutInflater().inflate(R.layout.inflater_marker, null);
Sunil P
  • 3,698
  • 3
  • 13
  • 20
Mohit Kalia
  • 351
  • 1
  • 6