当用户单击标记时,我试图显示 infoWindow。我应该在 Infowindow 中返回什么,以便在单击标记时显示默认的 infowindow?非常感谢任何帮助。提前致谢。
这是代码:
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;
}
}