OpenLayers OpenLayers

Ticket #863 (closed feature: fixed)

Opened 2 years ago

Last modified 2 years ago

IE getPosition() 2,2 offset

Reported by: pgiraud Assigned to:
Priority: minor Milestone: 2.5 Release
Component: general Version: 2.4
Keywords: Cc:
State:

Description (Last modified by crschmidt)

As told in the #817 [5] ticket, I found something interesting about the "IE doesn't draw vector elements where the user clicks" problem.

From what I understand, in some cases [1] IE’s clientX and clientY measurements are sometimes a couple pixels out. It seems that for some reason, IE start from (2,2) to measure clientX and clientY.

It involves that the OpenLayers.Events.getMousePosition(evt) returns a response with a (2,2) pixels offset. Then the computed coordinates are somewhat invalid. Man can reproduce this by trying to show the -180 longitude in the mousePosition in the controls.html examples under IE at zoomLevel = 1. The value always can't go lower than 177.89....

Following the [1] example of code given to get the mouse position [1], I managed to get the mouse-position.html [2] pixel coordinates starting at (0,0) by modifying a bit the getMousePosition() method [3].

But, despite what Beau [1] explains, this does only work in standard mode. In quirksmode [4], clientLeft and clientTop are both still equal to 0.

Hope this is clear enough. Don't hesitate to rewrite this in a more readable english.

  1. http://hartshorne.ca/2006/01/23/javascript_cursor_position/
  2. see attachment : mouse-position.html
  3. see attachment : patch.diff
  4. for those who don't know nothing about quirksmode, standard compliant mode, etc... please have a look at http://www.quirksmode.org/css/quirksmode.html and http://hsivonen.iki.fi/doctype/
  5. http://trac.openlayers.org/ticket/817

Attachments

mouse-position.html (1.2 kB) - added by pgiraud on 07/25/07 11:57:48.
example to get mouse position in pixels
patch.diff (1.0 kB) - added by pgiraud on 07/25/07 11:59:47.

Change History

07/25/07 11:57:48 changed by pgiraud

  • attachment mouse-position.html added.

example to get mouse position in pixels

07/25/07 11:59:47 changed by pgiraud

  • attachment patch.diff added.

07/31/07 05:02:16 changed by pgiraud

  • keywords set to review.

08/28/07 22:47:46 changed by crschmidt

  • milestone set to 2.5 Release.

08/28/07 22:51:58 changed by crschmidt

  • description changed.

08/28/07 22:52:23 changed by crschmidt

  • description changed.

08/28/07 22:58:03 changed by crschmidt

Reading through the linked description, it's clear that this is a common problem. Given that this doesn't happen in quirks mode, I'm going to skip making this a full test, and instead add the html file ot the examples with an appropriate description, since one of my things to do before releases is to run through the examples and make sure they still all work (within some reasonable definition of work).

Pierre: Thanks for this. In the future, please feel free to move anything which is marked for review into the current milestone: I almost missed this in 2.5, which would have sucked.

08/28/07 23:03:14 changed by crschmidt

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [4098]) Commit fix for an off-by-two error on standards complaint HTML pages in IE, and add an HTML example that can be used as an acceptance test. (Closes #863) Thanks pierre for the research and report!