Open yhahn opened 11 years ago
The culprit is these two lines in MM.getMousePoint
https://github.com/modestmaps/modestmaps-js/blob/master/modestmaps.js#L866-867.
Simply wrapping these in an if statement based on whether or not the map div has position: fixed
works, but this is dependent on the user placing the fixed attribute on the map div and not some higher level container. Also not positive if this covers all possible uses of fixed
.
Sticking a custom version of the function in your site works well, for example:
MM.getMousePoint = function(e, map) {
// start with just the mouse (x, y)
var point = new MM.Point(e.clientX, e.clientY);
if (!$('.map-container').hasClass('fixed')) {
// correct for scrolled document
point.x += document.body.scrollLeft + document.documentElement.scrollLeft;
point.y += document.body.scrollTop + document.documentElement.scrollTop;
}
// correct for nested offsets in DOM
for (var node = map.parent; node; node = node.offsetParent) {
point.x -= node.offsetLeft;
point.y -= node.offsetTop;
}
return point;
};
Test case:
http://bl.ocks.org/4601671
From MapBox Support 954