I donβt know if this will work, but it will follow the pattern of the link that I shared, maybe something like this ....
function doToolTip(item) { return function () { mTooltip = new Tooltip('<span class="name">' + item.User.Profile.firstname + ' asked:</span> <span class="title">' + item.Post.title + '</span>'); mTooltip.open(this.getMap(), this); }; }
... and this is your main code. I think that "item needs" is initialized outside the scope of the loop (but I could be wrong)
//other code etc... var item; for (var i = 0; i < data.length; i++) { item = data[i]; //other code etc.... google.maps.event.addListener(marker, 'mouseover', doToolTip(item)); //other code etc... }
OK I guess here, since I don't have a local copy of the code, but it seems you need to change the z-index when you execute the draw function ...
//code fragment... // need to force redraw otherwise it will decide to draw after we show the Tooltip $(this).css('z-index', 9999); this.draw(); // show tooltip
As for the position of the tooltip, you will have to experiment with the drawing function, as it seems to calculate the position from the marker. Itβs best to work out a position not from the coordinates of the google map, but from the actual position on the page - I think the culprits are:
pos = this.getProjection().fromLatLngToDivPixel(this.get('position')); // top offset top = pos.y - this.getAnchorHeight() / 2 - this.wdiv.outerHeight() / 2; // left offset if (this.getMap().getCenter().lng() > this.get('position').lng()) { left = pos.x + this.wdiv.outerWidth(); } else { left = pos.x - this.wdiv.outerWidth(); } // window position this.wdiv.css('top', top); this.wdiv.css('left', left);
If positioning is constantly off, you can simply apply the correction to the upper and left values, if it becomes more difficult, you will have to change the algorithm.