title: How to select and deselect a marker in google maps?
body: <p>I have a list of places which are marked in google maps using Markers. I want to select a Marker so that it will highlight with a different color. When I click on the same marker or any other marker I want remove the selection made in the first marker and set it back to the default color.</p>
  
  <p>This is my onClusterItemClick method</p>
  
  <pre><code>override fun onClusterItemClick(p0: Station?): Boolean {
          dragView.visibility = View.VISIBLE
          viewModel.loadStation(p0?.id!!)
          val marker = renderer.getMarker(p0)
  
          //save previous merker here
  
   marker?.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin_selected))
  
          return true
      }
  </code></pre>
  
  <p>This is my Station Renderer</p>
  
  <pre><code>/**
       * Class to design the pin point into the map
       */
  
      inner class StationRenderer(context: Context, map: GoogleMap,
                                  clusterManager: ClusterManager&lt;Station&gt;) : DefaultClusterRenderer&lt;Station&gt;(context, map, clusterManager) {
  
  
          override fun onBeforeClusterRendered(cluster: Cluster&lt;Station&gt;?, markerOptions: MarkerOptions?) {
              markerOptions?.icon(BitmapDescriptorFactory.fromBitmap(createStoreMarker(cluster?.size.toString())))
          }
  
          override fun onBeforeClusterItemRendered(item: Station?, markerOptions: MarkerOptions?) {
              markerOptions?.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin))
          }
  
  
          private fun createStoreMarker(stationsCount:String): Bitmap {
              val markerLayout = layoutInflater.inflate(R.layout.marker_item, null)
              val markerImage = markerLayout.findViewById(R.id.marker_image) as ImageView
              val markerRating = markerLayout.findViewById(R.id.marker_text) as TextView
              markerImage.setImageResource(R.drawable.ic_map_pin)
              markerRating.text = stationsCount
              markerLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED))
              markerLayout.layout(0, 0, markerLayout.getMeasuredWidth(), markerLayout.getMeasuredHeight())
              val bitmap = Bitmap.createBitmap(markerLayout.getMeasuredWidth(), markerLayout.getMeasuredHeight(), Bitmap.Config.ARGB_8888)
              val canvas = Canvas(bitmap)
              markerLayout.draw(canvas)
              return bitmap
          }
  
  
          override fun shouldRenderAsCluster(cluster: Cluster&lt;Station&gt;?): Boolean {
              return cluster?.size !!&gt; 1
          }
  
  
      }
  </code></pre>