Reputation: 1007
I want x,y coordinates for the pixel which I click on the google maps using jquery.. How to get it? I can only get the Latitude and longitude values.. But I need left, top positions..
Could anyone please help?
Upvotes: 0
Views: 2474
Reputation: 1007
Click event's PageX, PageY will give the left, top position.
$('#map-canvas').click(function(event) {
$("#tooltip").css('left', event.pageX);
$("#tooltip").css('top',event.pageY);
});
Upvotes: 0
Reputation: 3270
Try using a click event on the container and the event will have an offsetX
and offsetY
on it that are coordinates relative to the container.
See this fiddle:
Upvotes: 1