title: Place marker on click google maps javascript api
body: <p>I have coded a google map in JS Apis. </p>
  
  <p>What I'm trying to achieve is that wherever the user clicks, it places the marker there and outputs its Lat and Lng. </p>
  
  <p>What I have achieved is wherever I click, it outputs the Lat and Lng without dragging the marker there. </p>
  
  <p>Here the Fiddle - <a href="http://jsfiddle.net/sarthakbatra1991/87v0obb4/#&amp;togetherjs=3aTj11AiwO" rel="nofollow">http://jsfiddle.net/sarthakbatra1991/87v0obb4/#&amp;togetherjs=3aTj11AiwO</a></p>
  
  <pre><code>google.maps.event.addListener(map, 'click', function (event) {
  
  
          document.getElementById("lat").value = event.latLng.lat();
          document.getElementById("long").value = event.latLng.lng();
          marker.setPosition(lat, lng);
          marker.setMap(map);
  
      });
  </code></pre>
  
  <p>Please look at it and help me out here. </p>
  
  <p>Cheers! </p>