title: How do you add addMarker on GoogleMap on Arraylist correctly
body: <p>I am having a problem on how to add the addMarker on Arraylist. While I am using createMarker on my for loop to add values.</p>
  
  <pre><code>MainActivity extends BaseActivityLocation
          implements NavigationView.OnNavigationItemSelectedListener, SearchView.OnQueryTextListener,
          SearchView.OnSuggestionListener {
  
  @Override
  public boolean onQueryTextSubmit(String query) {
      for(Marker m : list) {
          System.out.println(list+m.getSnippet() + m.getTitle() + m.getPosition() + " snippet");
          if(m.getSnippet().toLowerCase().equals(query)) {
              Toast.makeText(this, "You searched for: " + query , Toast.LENGTH_SHORT).show();
              mMapFragment.animateCamera(CameraUpdateFactory.newLatLngZoom(m.getPosition(), 9.0f));
              break; // stop the loop
          }
      }
      return false;
  }
  
     public void onResponse(Call&lt;JsonElement&gt; call, Response&lt;JsonElement&gt; response) {
          // success response
          if (response.body().isJsonArray()) {
              JsonArray objectWhichYouNeed = response.body().getAsJsonArray();
              System.out.println(objectWhichYouNeed + " Object");
  
              for (int i = 0; i &lt; response.body().getAsJsonArray().size(); i++) {
                  JsonElement plate_num_array = response.body().getAsJsonArray().get(i);
                  JsonObject plate_num_obj = plate_num_array.getAsJsonObject();
                  String plate_n = plate_num_obj.get("plate_num").toString();
                  String plate_nString = plate_n;
                  plate_nString = plate_nString.replace("\"", "");
                  String plate_num = String.valueOf(plate_nString);
  
                  JsonElement lat_array = response.body().getAsJsonArray().get(i);
                  JsonObject lat_obj = lat_array.getAsJsonObject();
                  String lati = lat_obj.get("lat").toString();
                  String latiString = lati;
                  latiString = latiString.replace("\"", "");
                  String lat = String.valueOf(latiString);
  
                  JsonElement lng_array = response.body().getAsJsonArray().get(i);
                  JsonObject lng_obj = lng_array.getAsJsonObject();
                  String longi = lng_obj.get("lng").toString();
                  String longiString = longi;
                  longiString = longiString.replace("\"", "");
                  String lng = String.valueOf(longiString);
  
                  createMarker(d, d2, plate_num);
              }
  </code></pre>
  
  <p>Problem here is when createMarker is called the marker will just replace its value on the Arraylist. What I want is to add the marker in arraylist like [0,0,0,0].. How do I achieve that?</p>
  
  <pre><code> public MarkerOptions createMarker(Double latitude, final Double longitude, String Plate_num) {
      BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.bus);
  
      list = new ArrayList&lt;&gt;();
  
      System.out.print(list + " Snippp");
  
     /*  mMapFragment.addMarker(new MarkerOptions()
              .position(new LatLng(latitude, longitude))
              .anchor(0.5f, 0.5f)
              .title("Plate No.")
              .snippet(Plate_num)
              .icon(image));*/
  
      mMapFragment.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
          @Override
          public void onInfoWindowClick(Marker marker) {
              marker.hideInfoWindow();
          }
      });
  
      mMapFragment.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 9.0f));
  
      mMapFragment.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
  
          @Override
          public boolean onMarkerClick(final Marker marker) {
              vm = new VehicleMap();
  
              vm.setSnippet(marker.getSnippet());
              vm.setPlate_num(marker.getSnippet());
  
              latitudeG = marker.getPosition().latitude;
              longitudeG = marker.getPosition().longitude;
  
              marker.showInfoWindow();
  
              BottomSheetDialogFragment bottomSheetDialogFragment = new BottomSheetModalFragment(activity);
              bottomSheetDialogFragment.show(getFragmentManager(), bottomSheetDialogFragment.getTag());
  
              return true;
          }
      });
  
      return new MarkerOptions()
              .position(new LatLng(latitude, longitude))
              .title("Plate No.")
              .snippet(Plate_num)
              .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
  
  }
  </code></pre>