I'm new in android and java and I'm programming my first app in Android Studio with a database and a Mapbox Map. I have few Activities and a database in .SQLite using Room persistence library. Right now I'm programming a Mapbox Activity.
I'm programming an activity which shows the map. This map visualizes several markers. Now I want to implement small annotations with information for each marker (e.g. address, house number, coordinates) after clicking on. At the moment the markers themselves are created by going through a List with a for loop.
How can I create an annotation window without a geoJSON file, but with accessing the SQLite database. Is it possible? I found only examples like this: https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/?size=n_10_n which uses a geoJSON file, which is transformed to a List, but I have only a List.
How is the best way to implement the example with SQLite database as source? Thank you in advance!
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
MapboxActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(
new Style.Builder().fromUri("mapbox://styles/aroid435/ckiohlr9a0c3m17nq6tx5ajjs")
,
new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
enableLocationComponent(style);
SymbolManager symbolManager = new SymbolManager(mapView, mapboxMap, style);
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().target(new LatLng(51.051877, 13.741517)).zoom(10.5).build()));
for (int i= 0; i < stolpersteine_list.size() ; i = i+1 ) {
mapboxMap.getStyle().addImage("my-star-marker", BitmapFactory.decodeResource(getResources(), R.drawable.rectangle));
symbolManager.create(new SymbolOptions()
.withLatLng(new LatLng( stolpersteine_list.get(i).getLatitude(),stolpersteine_list.get(i).getLongitude()))
.withIconImage("my-star-marker")
.withIconAnchor("bottom"));
}
}
});
} // end of onMapReady
ยดยดยด
