I have a fragment with a list of categories:

private void initializeData() { persons = new ArrayList<>(); persons.add(new Person("category1", "Первая", R.drawable.category1)); persons.add(new Person("category2", "Вторая", R.drawable.category2)); persons.add(new Person("category3", "Третья", R.drawable.category3)); } 

By clicking on some of the categories, I turn to activity, where I have a map containing the markers with their values ​​(name, coordinates). Since I have all my categories contain a map, but with different values ​​of the markers I want to try to implement everything in one activity.

That is, by clicking on a category, we switch to activation, passing to it certain parameters of this category (for example, a bakery location). Activity, in turn, should receive the parameters and determine for which category the markers should be displayed (the bakery should display the markers, not libraries).

At the moment, I transmit for each activity as follows:

  public void onMapReady(GoogleMap map) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); Marker Pekarnea= map.addMarker(new MarkerOptions() .position(new LatLng(47.045029, 28.861427)) .title("Marker")); Marker Biblioteka= map.addMarker(new MarkerOptions() .position(new LatLng(47.000327, 28.867950)) .title("Marker")); Marker marker3 = map.addMarker(new MarkerOptions() .position(new LatLng(47.024204, 28.889236)) .title("Marker")); builder.include(marker.getPosition()); builder.include(marker2.getPosition()); builder.include(marker3.getPosition()); } 
  • как реализовать в одной активности - условие выбора категорий - from this place you need more detail. Do you need to transfer persons or persons ? - post_zeew
  • Initially, you need to pass the parameters to the activit and then in the final activit, depending on the parameter that arrives, display the necessary markers for a particular category. Perhaps it’s better to pass on the category ID. - Morozov
  • @post_zeew question incorrectly asked? - Morozov
  • I cannot say anything about correctness, but I did not understand the question as a whole, yes it is. - post_zeew Nov.
  • @post_zeew updated the question. - Morozov

0