I am trying to display completely custom info windows over map markers on marker click. I have successfully implemented this answer to get a div to show over a map-canvas click... but I am not able to replicate it on a marker click.
Is it possible to get the markers pixel position inside of the marker click function, and suppress the normal infowindow to show the desired custom infowindow?
I tried this:
google.maps.event.addListener(marker, 'click', function(args) {
var x=args.pixel.x+$('#map').offset().left; //we clicked here
var y=args.pixel.y;
info.style.left=x+'px';
info.style.top=y+'px';
info.style.display='block';
});
but in the console, I see:
Uncaught TypeError: Cannot read property 'x' of undefined
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…