g3ortega / polygonzo

Automatically exported from code.google.com/p/polygonzo
Other
0 stars 0 forks source link

False position when click or move #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open up the Polygonzo demo map in Firefox 17 or IE 8 (only tested on these 
browsers)
2. move the maps left (or right) and top (or bottom)
3. move your mouse on the map

What is the expected output? What do you see instead?
Marker should be placed on the center of the state which the mouse is on.
What happens is that the marker is placed on another state.

What version of the product are you using? On what operating system?
Firefiox (on ubuntu and windows) and IE 8.
No problem is noticed on chrome.

Please provide any additional information below.
I've found where the bug is.
Here is a dirty fix that would helping you fixing the code :
replace `elementOffset' function in polygonzo.js by this one : 

elementOffset: function( e ) {
        var left = 0, top = 0;
        while( e ) {
            if (e.style.cursor != ''){
                e = e.offsetParent
                continue;
            }
            left += e.offsetLeft;
            top += e.offsetTop;
            e = e.offsetParent;
        }

        return { left:left, top:top };
    }

Original issue reported on code.google.com by hedi.har...@gmail.com on 10 Feb 2013 at 5:54

GoogleCodeExporter commented 9 years ago
Thanks for the report and the workaround. It looks like this broke as a result 
of revision a9375373b0ee. Rolling back that revision isn't the answer, though, 
because the old code was broken in other ways in the latest V3 Maps API.

I'm going to see if there is a cleaner fix - I have a feeling the mouse offset 
code can be simplified from what I had been doing - but in the meantime if the 
cursor style check is taking care of it, that's great.

Original comment by m...@mg.to on 11 Feb 2013 at 6:27

GoogleCodeExporter commented 9 years ago
I would suggest using the mousemove and click events with google maps api.
From what i've seen chrome and firefox render the div in different way.
Firefox creates a div with a negative offset while chrome renders it using a 
moz transform.

Original comment by hedi.har...@gmail.com on 11 Feb 2013 at 7:37

GoogleCodeExporter commented 9 years ago
Fixed in rev 396650518f06.

Thanks for the report and the excellent investigation. Using the Maps API's 
events is a good idea, except that this code gets used in other contexts too, 
for example to overlay polygons onto a static map. So I stuck with the DOM 
events but parse the -webkit-transform style when it's used.

Tested in IE7/8/9 and recent Chrome, Safari, and Firefox.

Original comment by m...@mg.to on 12 Feb 2013 at 11:43

GoogleCodeExporter commented 9 years ago
Great !! 
Thx for this great lib !

Original comment by hedi.har...@gmail.com on 12 Feb 2013 at 1:32