I was looking at documentation and it looks like you can accomplish what you want using the annotations plugin for mapbox! (https://docs.mapbox.com/android/plugins/overview/annotation/#options)
Assuming you already have the dependency initialized there are a few steps you need to do to start using this annotation plug-in!
The documentation goes into great detail on how to use this so that is really helpful, but I'll include an example for using this feature to create an annotation. All of the code below is taken from the documentation and pieced together as described. Hope this helps!
First add this code snippet to your gradle file
repositories {
mavenCentral()
}
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0'
}
Next add this code to your fragment/activity you have your mapbox created in.
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
// Use a layer manager here
// create symbol manager object
SymbolManager symbolManager = new SymbolManager(mapView, mapboxMap, style);
// add click listeners if desired
symbolManager.addClickListener(symbol ->
);
symbolManager.addLongClickListener(symbol -> {
});
// set non-data-driven properties, such as:
symbolManager.setIconAllowOverlap(true);
symbolManager.setIconTranslate(new Float[]{-4f,5f});
symbolManager.setIconRotationAlignment(ICON_ROTATION_ALIGNMENT_VIEWPORT);
symbolManager.setIconAllowOverlap(true);
symbolManager.setIconIgnorePlacement(true);
// Add symbol at specified lat/lon
Symbol symbol = symbolManager.create(new SymbolOptions()
.withLatLng(new LatLng(60.169091, 24.939876))
.withIconImage(ICON_ID)
.withIconSize(2.0f));
}
});
}