I'm trying to figure out how to add numbers to markers programmatically in mapbox to get the result of the image below
Here is the code of the map that displays some markers
public class DepartMissionFragment extends Fragment {
private MapView mapView;
private static final String TAG = "DirectionsActivity";
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Mapbox.getInstance(requireActivity(), getString(R.string.access_token));
View view = inflater.inflate(R.layout.fragment_mission_depart, container, false);
mapView = view.findViewById(R.id.mapView20);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(33.589886, -7.603869))
.title("marker one"));
// It is possible to use .setIcon() to get a custom icon from ressources
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(33.589790, -7.603989))
.title("marker two"));
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(33.589190, -7.603089))
.title("marker three"));
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(33.588790, -7.603289))
.title("etc.."));
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(33.580790, -7.603989))
.title("etc...."));
mapboxMap.setStyle(getString(R.string.navigation_guidance_day), new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
}
});
}
});
return view;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
}
@Override
public void onStart() {
super.onStart();
mapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onStop() {
super.onStop();
mapView.onStop();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
}
I'm searching for a way to give numbers to the markers, a proper way for me would be to add custom marker from drawable.
Any other method is welcomed.