ProjectMap

HTML

<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBM79aEMafCmyY72e-kUrEWkLCsv7Ib1OU&sensor=false&libraries=places">
</script>
<body>
<div id="map_canvas" style="width: 500px; height: 250px;"></div>
  
  
  <p>
<label for="search_new_places">Adres:</label>
<input type="text"  placeholder="Konum" class="form-control" id="search_new_places" name="search_new_places"  autofocus>
</p>
</body>

JavaScript

var lat = 41.013995; //default latitude
    var lng = 28.979741; //default longitude
    var homeLatlng = new google.maps.LatLng(lat, lng); //set default coordinates
    var homeMarker = new google.maps.Marker({ //set marker
      position: homeLatlng, //set marker position equal to the default coordinates
      map: map, //set map to be used by the marker
      draggable: true //make the marker draggable
    });
    
    var geocoder = new google.maps.Geocoder;

    var myOptions = {
      center: new google.maps.LatLng(41.013995, 28.979741), //set map center
      zoom: 17, //set zoom level to 17
      mapTypeId: google.maps.MapTypeId.ROADMAP //set map type to road map
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions); //initialize the map

    var marker = new google.maps.Marker({
        draggable: true,
        position: homeLatlng,
        map: map,
        title: "Your location"
    });




    google.maps.event.addListener(marker, 'dragend', function (event) {


        document.getElementById("lat").value = event.latLng.lat();
        document.getElementById("long").value = event.latLng.lng();
        
        // Reverse geo code using latLng
        geocoder.geocode({'location': event.latLng }, function(results, status) {
        
          if (status === 'OK') {
            if (results[0]) {
              $('#search_new_places').val( results[0].formatted_address );
            } else {
              window.alert('No results found');
            }
            
          } else {
            window.alert('Geocoder failed due to: ' + status);
          }
          
        });
        
    });

    //if the position of the marker changes set latitude and longitude to
    //current position of the marker
    google.maps.event.addListener(homeMarker, 'position_changed', function(){
      var lat = homeMarker.getPosition().lat(); //set lat current latitude where the marker is plotted
      var lng =...