javascript - Get Position of Mouse Cursor on Mouseover of Google Maps V3 API Marker -


i trying make div visible @ position of cursor when cursor mouseover marker using jquery. kind of tooltip. cannot seem figure out how x/y coordinates of point below cursor.

current code:

google.maps.event.addlistener(marker, "mouseover", function(event) {      $("#tooltip").css({         position: "absolute",         top: event.pagey,         left: event.pagex     }).toggle(); 

i believe event not have properties pagey , pagex in event in jquery.

how osition of mouse cursor?

this extension of previous answer regarding computation of pixel positions (google maps api v3). introduce "global" variable overlay:

var overlay = new google.maps.overlayview(); overlay.draw = function() {}; overlay.setmap(map); // 'map' new google.maps.map(...) 

use overlay in listener projection , pixel coordinates:

google.maps.event.addlistener(marker, 'mouseover', function() {     var projection = overlay.getprojection();      var pixel = projection.fromlatlngtocontainerpixel(marker.getposition());     // use pixel.x, pixel.y ... (after rounding) });  

you may have @ projection.fromlatlngtodivpixel().


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -