@Amit Shah nice! that would be helpful a lot, but i just wonder when i set a laltong assigned field to hidden, the assigned field doesn't catch a value, when i drag the marker, it doesn't generate latlong in the assigned field cuz the said field is hidden and the map could get a error in the firebug.
page_ui_crudOp.php (where the add, edit and view pane of groceryCRUD is generated via modal)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<?php foreach ($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach ($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
var myCenter = new google.maps.LatLng(7.281300, 125.684750);
var marker;
function initialize() {
var mapProp = {
center: myCenter,
zoom: 15,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
marker = new google.maps.Marker({
position: myCenter,
draggable: true
});
marker.setMap(map);
google.maps.event.addListener(marker, "drag", function () {
document.getElementById("grid").value = marker.getPosition().toUrlValue(); //set lat current longitude where the marker is plotted
// document.getElementById("grid").value = marker.position.toUrlValue();
});
var flightPlanCoordinates = [{lat:7.292363, lng:125.667018},
{lat:7.291958, lng:125.671030},
{lat:7.292022, lng:125.673777},
{lat:7.291532, lng:125.675864},
{lat:7.292884, lng:125.676464},
{lat:7.292809, lng:125.677291},
{lat:7.292682, lng:125.680069},
{lat:7.292283, lng:125.682475},
{lat:7.291916, lng:125.684653},
{lat:7.290319, lng:125.685536},
{lat:7.290787, lng:125.688089},
{lat:7.292937, lng:125.689033},
{lat:7.294427, lng:125.689951},
{lat:7.296428, lng:125.691737},
{lat:7.295853, lng:125.692123},
{lat:7.295300, lng:125.692273},
{lat:7.293703, lng:125.694247},
{lat:7.294001, lng:125.694612},
{lat:7.294172, lng:125.697123},
{lat:7.291000, lng:125.698678},
{lat:7.289723, lng:125.697091},
{lat:7.287808, lng:125.695717},
{lat:7.285573, lng:125.691866},
{lat:7.284466, lng:125.690793},
{lat:7.282657, lng:125.689763},
{lat:7.279996, lng:125.688411},
{lat:7.278123, lng:125.686930},
{lat:7.277208, lng:125.686287},
{lat:7.276059, lng:125.685600},
{lat:7.274207, lng:125.683604},
{lat:7.274037, lng:125.683175},
{lat:7.275675, lng:125.678412},
{lat:7.275697, lng:125.673975},
{lat:7.280188, lng:125.674565},
{lat:7.280156, lng:125.672009},
{lat:7.286728, lng:125.674788},
{lat:7.287308, lng:125.673302},
{lat:7.288127, lng:125.669896},
{lat:7.287137, lng:125.669834},
{lat:7.287196, lng:125.665787},
{lat:7.288962, lng:125.666312},
{lat:7.288718, lng:125.667889},
{lat:7.290819, lng:125.667830},
{lat:7.291123, lng:125.668512},
{lat:7.289612, lng:125.668116},
{lat:7.289734, lng:125.668899},
{lat:7.290080, lng:125.668830},
{lat:7.290309, lng:125.669729},
{lat:7.290271, lng:125.670128},
{lat:7.290301, lng:125.670828},
{lat:7.291330, lng:125.670852},
{lat:7.291793, lng:125.666922},
{lat:7.291916, lng:125.666885},
{lat:7.292363, lng:125.667018}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
function ageCount() {
var date1 = new Date();
var bday = document.getElementById("bday").value;
var date2 = new Date(bday);
var pattern = /^\d{4}-\d{2}-\d{2}$/;
if (pattern.test(bday)) {
var y1 = date1.getFullYear();
var y2 = date2.getFullYear();
var age = y1 - y2;
document.getElementById("age").value = age;
} else {
alertify.alert("invalid date format.!! Please enter in (YYYY-MM-DD) format").set('modal', false);
document.getElementById("age").value = "";
return false;
}
}
function fillAddress() {
var purok = document.getElementById("purok").value;
if (purok === "") {
document.getElementById("resAddress").value = "";
document.getElementById("perAddress").value = "";
} else {
document.getElementById("resAddress").value = "Prk. " + purok + ", Panabo City, Davao del Norte, Philippines 8105";
document.getElementById("perAddress").value = "Prk. " + purok + ", Panabo City, Davao del Norte, Philippines 8105";
}
}
</script>
</head>
<body id="body" class="body">
<div id="googleMap" style="width:560px;height:380px;"></div>
<div class="block full" style="margin:0 0 0px;">
<div class="block-content-full">
<?php echo $output; ?>
</div>
</div>
</body>
</html>
in the "document.getElementById("grid").value = marker.getPosition().toUrlValue();", the "grid" is the name of the id where i put the latlong value of the dragged marker and the "#grid" field is generated via callback function in add and edit pane. Hope you get my problem @Amit Shah, thanks in advance for answering my questions. :)