Немного поиграв и прочитав другие темы, вот мое решение:
<input type="text" id="location-text-box" name="address" placeholder="Your location..." required="">
<div id="map"></div>
window.onload = function () {
var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
var mapOptions = {
center: myLatlng,
zoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable:true,
title:"Drag me!"
});
google.maps.event.addListener(marker, 'dragend', function (e) {
var latlng = new google.maps.LatLng(e.latLng.lat(), e.latLng.lng());
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
$("#location-text-box").attr("value", results[1].formatted_address);
}
}
});
});
}