开发者

is there any methord (about google-maps api) to get the mouse's offset when mouseover (not use jquery) [closed]

开发者_高级运维 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.
GEvent.addListener(map, "mouseover", function() {

        });

thanks


I am not sure if I understood your question correctly, but you may want to check out the following example.

Both the geographical coordinates as well as the DOM coordinates would update automatically as you move the mouse over the map:

<!DOCTYPE html>
<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Google Maps mousemove Event Demo</title> 
   <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false" 
           type="text/javascript"></script> 
</head> 
<body onunload="GUnload()" style="font-family: Arial; font-size: 11px;"> 

   <div id="map" style="width: 500px; height: 300px;"></div> 
   <div id="div_coordinates"></div>
   <div id="geo_coordinates"></div>

   <script type="text/javascript"> 

      var map = new GMap2(document.getElementById("map"));

      map.setCenter(new GLatLng(39.00, -77.00), 10);

      GEvent.addListener(map, "mousemove", function(latlng) {
          document.getElementById('div_coordinates').innerHTML =
             'Div Coordinates: ' +
             map.fromLatLngToContainerPixel(latlng).x + ', ' +
             map.fromLatLngToContainerPixel(latlng).y;

          document.getElementById('geo_coordinates').innerHTML =
             'Geographical Coordinates: ' + latlng.lat() + ', ' + latlng.lng();
      });

   </script> 
</body> 
</html>

is there any methord (about google-maps api) to get the mouse's offset when mouseover (not use jquery) [closed]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜