I\'m new in google maps, and I\'m trying to learn it.
marker = new google.maps.Marker(
{
map:map,
draggable:tru
Here is the code which gets drag-able marker with position in text box:
/**
*Receiving the value of text box and type done conversion by Number()
*/
var latitude = Number(document.getElementById("la").value);
var longitude = Number(document.getElementById("lo").value);
function initMap() {
/**
*Passing the value of variable received from text box
**/
var uluru = {
lat: latitude,
lng: longitude
};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: uluru
});
marker = new google.maps.Marker({
map: map,
draggable: true,
animation: google.maps.Animation.DROP,
position: uluru
});
google.maps.event.addListener(marker, 'dragend',
function(marker) {
var latLng = marker.latLng;
currentLatitude = latLng.lat();
currentLongitude = latLng.lng();
$("#la").val(currentLatitude);
$("#lo").val(currentLongitude);
}
);
}
#map {
height: 400px;
width: 100%;
}
Latitude Longitude
Please Use jQuery at the head