I\'m new in google maps, and I\'m trying to learn it.
marker = new google.maps.Marker(
{
map:map,
draggable:tru
Set a Position on Map using lat/lang and make the marker draggable
Using lat/lang initially sets a marker at the given point on the map
The address variable is used for title purpose. It can be ignored.
draggable:true makes the marker draggable.
Use event listener google.maps.event.addListener(marker, 'dragend', function(marker) To listen for changes in the marker position
function showMap(lat,lang,address) {
var myLatLng = {lat: lat, lng: lang};
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 17,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: address,
draggable:true,
});
google.maps.event.addListener(marker, 'dragend', function(marker){
var latLng = marker.latLng;
currentLatitude = latLng.lat();
currentLongitude = latLng.lng();
jQ("#latitude").val(currentLatitude);
jQ("#longitude").val(currentLongitude);
});
}