How to create marker on the map whenever user tap the map

I want to add a marker on the map whenever the user clicks on a specific location on the map, is this possible?

here’s the example Google Developers