Place a Circle shape and show toast if clicked

If user clicks a circle, show a toast message.

1️⃣ Declare variables for a circle. Ensure that the clickable property is set to true.

1
2
3
    val circles = CircleOptions()
        .radius(10.0) 
        .clickable(true)   


2️⃣ Place the circle on the map, and add a tag to identify each placement.

1
 mMap.addCircle(circles.center(LatLng(25.16828, 121.44430))).tag = "haha"


3️⃣ Initialize setOnCircleClickListener to listen for user clicks, then show a toast message if the clicked circle matches the tag.

      mMap.setOnCircleClickListener {

          if (it.tag == "haha") {

              Toast.makeText(
                  applicationContext,
                  "haha message haha",
                  Toast.LENGTH_SHORT
              ).show()
          }
          else {
              Toast.makeText(
                  applicationContext,
                  "This is a test message",
                  Toast.LENGTH_SHORT
              ).show()
          }
      }