title: How can I show and hide markers on google map in android using a button
body: <p>I am new to android coding. I am trying to toggle on and off markers that I managed to display on my map, with a button in my action bar.</p>
  
  <p>So far I have created this method, I do not understand what I need to do next</p>
  
  <p>Here, basically I make an array of locations and use for loop to put all the markers on my map. Now what I want to be able to do is hide the markers if they are visible via a button click and show the markers if they are hidden.</p>
  
  <pre><code>public boolean showShops(){
          rL = new ArrayList&lt;LatLng&gt;();
          rl.add(new LatLng(40.433433, -1.422423));
          rl.add(new LatLng(40.433434, -1.422534));
  
          for(LatLng nRL : rL){ 
              mMap.addMarker(new MarkerOptions() 
              .position(nRL)
              .title("Shop")
          }
  
          return true;
      }
  </code></pre>
  
  <p>I have been trying to figure it out for a long time now and cannot seem to find the solution. I have managed to find out that you have to setVisible(false); to hide and setVisible(true); to show, but I do not know how I can implement it. I tried adding that instead of .add in my above code but I get errors.</p>
  
  <p>Can someone please help.</p>
  
  <p>Thanks.</p>