[OpenLayers-Users] strange click events with internet explorer
Christian Sengstock
csengstock at gmail.com
Fri Jun 1 07:05:22 EDT 2007
After debugging i found the problem to be in the method:
OpenLayers.Events#getMousePosition
Problem is, that i have my map div element in a "dislpay:none" div at
startup (so the map div offsets are 0). However inside of
#getMousePosition there's just once the check for the div offsets at
first method call. After that the offsets are saved as a member var.
So my problem was solved by checking the map div element offsets each
time i call #getMousePosition .. thus:
getMousePosition: function (evt) {
// if (!this.element.offsets) { // COMMENTED
this.element.offsets = OpenLayers.Util.pagePosition(this.element);
this.element.offsets[0] += (document.documentElement.scrollLeft
|| document.body.scrollLeft);
this.element.offsets[1] += (document.documentElement.scrollTop
|| document.body.scrollTop);
// } // COMMENTED
return new OpenLayers.Pixel(
(evt.clientX + (document.documentElement.scrollLeft
|| document.body.scrollLeft)) -
this.element.offsets[0],
(evt.clientY + (document.documentElement.scrollTop
|| document.body.scrollTop)) - this.element.offsets[1]
);
},
I saw that most of the click handling stuff comes from the prototype
library. Wouldn't it be easier using the prototype methods directly (
and make use of all the benefits of a constantly enhanced library) ?
Chris
2007/5/31, percy <percyd at pdx.edu>:
> This sounds similar to a problem I had last October. I think it was
> fixed in version 2.2, I'll paste the email below...
> Percy
>
> -------- Original Message --------
> Subject: Re: [OpenLayers-Users] "interesting" cross browser problem
> with mouse click position
> Date: Fri, 27 Oct 2006 11:09:34 -0700
> From: percy <percyd at pdx.edu>
> To: Christopher Schmidt <crschmidt at metacarta.com>
> CC: users at openlayers.org
> References: <20061011160003.A6010EDFAF at rainier.metacarta.com>
> <45401072.3020304 at pdx.edu> <20061026143712.GB15808 at metacarta.com>
>
> that fixed it, thanks!
>
> any idea when 2.2 will become the "stable" release?
>
> I just got the SVN version out yesterday and was playing with that SWEET
> new MousePosition control. I need to wait to put that on our production
> server until it gets blessed, though.
>
> Thanks again for the groovy interface,
> Percy
>
> Christopher Schmidt wrote:
> > On Wed, Oct 25, 2006 at 06:33:38PM -0700, percy wrote:
> >
> >> Hi All,
> >>
> >> We are attempting to use an openlayers frontend to a kamap tiled
> backend.
> >>
> >> My test page, http://ngmdb.usgs.gov/ol/examples/ngmdb4.html , works
> >> great in both "major" browsers. However when we integrate it into the
> >> main search page (which is not yet on a public site, but here's a
> >> simpler Kamap version: http://ngmdb.usgs.gov/ngm_compsearch_map.html) we
> >> get errant behaviour with regard to how the mouseclicks are handled by
> >> OpenLayers in FireFox!
> >>
> >> to see this in action, just edit your test file by sticking in this div
> >> just after the body tag:
> >>
> >> <div style="width:600px;height:800px;background-color:#008800;">
> >> Push the map down the screen
> >> </div>
> >>
> >> and then load the test file in a browser. firefox will exhibit the same
> >> breaking behavior as it does on the working page!"
> >>
> >
> > Mistakenly sent my response to Percy, rather than to the list: This was
> > fixed with r1692, http://trac.openlayers.org/changeset/1692 closing bug
> > #333, http://trac.openlayers.org/ticket/333 , and the patch available at
> > the bottom of the page on r1692 should allow you to fix this issue for
> > older OpenLayers instances. Alternatively, this fix is included in the
> > 2.2-rc1 currently being tested, and will be included in the final 2.2
> > release.
> >
> > Regards,
> >
>
> Christopher Schmidt wrote:
> > On Thu, May 31, 2007 at 11:00:08AM +0200, Christian Sengstock wrote:
> >> Is this a known problem and is there maybe a workaround? I think the
> >> problem depends on where the map div is located in the DOM, because it
> >> worked properly when i tested the MouseToolbar with a very basic html
> >> page (just the map div).
> >
> > I'm not aware of this problem, or a workaround. (This just means I
> > haven't run into it, largely because I mostly use simple DOMs :))
> >
> > Anyone else run into this issue?
> >
> > Regards,
>
> --
> David Percy
> Geospatial Data Manager
> Geology Department
> Portland State University
> http://gisgeek.pdx.edu
> 503-725-3373
>
More information about the Users
mailing list