Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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>
share|improve this question
add comment

1 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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.