Here is the code I used to demonstrate my learning of GoogleMaps.

<!-- $Id: Test 003 - Display mouse pointer lat-lng.html,v 1.0.3 
2011-02-15T14:11:41+00:00 RichardQ $ -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Test 003 - Track mouse pointer moves and clicks.</title>
<meta name = "viewport" content="initial-scale=1.0, user-scalable=no" />
<style type = "text/css">
 html
  {
  height: 100%
  }
body
{
height: 100%;
margin: 0px;
padding: 0px
}
#map_canvas, #map_canvas_results
{
width : 50%;
height: 90%;
float : left;
}
p,a
 {
 clear:both;
 }
</style>
<script type = "text/javascript" 
src="http://maps.google.com/maps/api/js?sensor=false";></script>
<script type = "text/javascript">
function initialize()
{
var map = new google.maps.Map
(
document.getElementById('map_canvas'),
{
zoom      : 12,
center    : new google.maps.LatLng
(
50.386935,
-3.951822
),
mapTypeId : google.maps.MapTypeId.ROADMAP
}
);

google.maps.event.addListener
(
map,
'mousemove',
function(event)
{
document.getElementById('lat').innerText = event.latLng.lat();
document.getElementById('lng').innerText = event.latLng.lng();
}
);
google.maps.event.addListener
(
map,
'click',
function(event)
{
document.getElementById('map_canvas_clicks').innerHTML = 
document.getElementById('map_canvas_clicks').innerHTML + event.latLng + '<br 
/>';
}
);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
<div id="map_canvas_results">
  <div>
   Current position lat <span id="lat">&nbsp;</span>, lng <span 
id="lng">&nbsp;</span>.
  </div>
  <div id="map_canvas_clicks"></div>
 </div>
 <p>
  Monitoring of the user interaction with a Google Map. Here, I'm tracking 
the mouse pointer movements and displaying the Long/Lat of the mouse and any 
mouse clicks are displayed beneath the current Long/Lat.
  Zooming/panning the map is all possible.
  If you zoom down to street view, there is no tracking.
 </p>
</body>
</html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to