The below code is working perfectly on click event to retrieve Lat/Long and Current Zoom level. How do I get the same when I hover mouse/drag on map Window (not on submit button)?
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script>
var map;
function initialize()
{
var mapOpt = {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom:6,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map=new google.maps.Map(document.getElementById("googleMap"),mapOpt);
}
function copyText()
{
document.getElementById("latlng").value=map.getCenter();
document.getElementById("Zoom").value=map.getZoom();
}
google.maps.event.addDomListener(window, 'load',initialize);
google.maps.event.addListener(map, 'drag',copyText);
</script>
</head>
<body>
<input type= "text" ID=latlng>
<input type="text" ID=Zoom><br>
<button onclick="copyText()">Submit</button>
<div id="googleMap"style="width:400px;height:300px;"></div>
</body>
</html>
Best Answer
I think this example here might be helpful for you.
It has the function to dynamically displays Lat/Long information when mouse moves which similar to what you are looking for.
thanks,
Jinnan