In this short article I will explain how to add marker / create marker when map is clicked in Google Maps V3.
Following is the HTML Markup containing the Google Map implementation. In order to add / create marker when the map is clicked, I have attached a click event handler to the Google Maps.
Now when the map is clicked, first the location is determined and then the using the location a marker is created and attached to the map.
The marker also has a click event handler for displaying the Info Window with the Latitude and Longitude of the location.
<html xmlns="">
<script type="text/javascript" src=""></script>
<script type="text/javascript">
window.onload = function () {
    var mapOptions = {
        center: new google.maps.LatLng(21.0000, 78.0000),
        zoom: 5,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
    //Attach click event handler to the map.
    google.maps.event.addListener(map, 'click', function (e) {
        //Determine the location where the user has clicked.
        var location = e.latLng;
        //Create a marker and placed it on the map.
        var marker = new google.maps.Marker({
            position: location,
            map: map
        //Attach click event handler to the marker.
        google.maps.event.addListener(marker, "click", function (e) {
            var infoWindow = new google.maps.InfoWindow({
                content: 'Latitude: ' + + '<br />Longitude: ' + location.lng()
  , marker);
 <div id="dvMap" style="width: 500px; height: 500px">
Google Maps V3: Add (Create) markers on click of Google Maps

Download Code