title: how to move marker in google map, when i click anywhere
body: <p>how to make : if i click some where place in google map, the marker will appear on it, if i click other place, the marker will change/move to new place.</p>
  
  <p>I think, will create event onClick, but i confused how to start.</p>
  
  <p>here my code :</p>
  
  <p>this code is only the basic of google map, Map is already appear.</p>
  
  <pre><code>&lt;script&gt;
  function loadmap()
  {
  var watchID = navigator.geolocation.getCurrentPosition(onSuccess, onError);
  }
  function onSuccessjalan(position) 
  {
  
  var element = document.getElementById('peta');
  var lat=position.coords.latitude;
  var lang=position.coords.longitude;
  var myLatlng = new google.maps.LatLng(lat,lang);
  
  
   var myMapOptions = {
     zoom: 12
     ,center: myLatlng
     ,mapTypeId: google.maps.MapTypeId.HYBRID
   };
   var theMap = new google.maps.Map(document.getElementById("map_canvas"), myMapOptions);
   var image = "images/loctag.png";
  
  
  
  
  
   var myOptions = {
    content: ""
   ,disableAutoPan: false
   ,maxWidth: 0
   ,pixelOffset: new google.maps.Size(-140, -110)
   ,pixelOffset: new google.maps.Size(140, 110)
   ,zIndex: null
   ,boxStyle: { 
    background: "url('tipbox.gif') no-repeat"
    ,opacity: 0.90
   }
   ,closeBoxMargin: "10px 2px 2px 2px"
   ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
   ,infoBoxClearance: new google.maps.Size(1, 1)
   ,isHidden: false
   ,pane: "floatPane"
   ,enableEventPropagation: false
   };
  
  
  
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>i need output like this screenshoot below</p>
  
  <p><a href="https://i.stack.imgur.com/g4pjB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g4pjB.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/9B5OH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9B5OH.png" alt="enter image description here"></a></p>