[OpenLayers-Users] Problem clicking on a map (OL-2.5) - RESOLVED

David R Robison drrobison at openroadsconsulting.com
Tue Jun 10 10:31:49 EDT 2008


I found the problem... On my page I have a fixed header and footer and a 
client region with the style "overflow: scroll". The problem is in 
getMousePosition:

    getMousePosition: function (evt) {
        if (!this.element.offsets) {
            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);
        }
        return new OpenLayers.Pixel(
            (evt.clientX + (document.documentElement.scrollLeft
                         || document.body.scrollLeft)) - 
this.element.offsets[0]
                         - (document.documentElement.clientLeft || 0),
            (evt.clientY + (document.documentElement.scrollTop
                         || document.body.scrollTop)) - 
this.element.offsets[1]
                         - (document.documentElement.clientTop || 0)
        );
    },

The first conditional "caches" the offsets. However, if the client area 
is scrolled, the new positions are not recalculated. If I comment out 
the conditional, then everything works great. I'm not sure this is 
clear... Any thoughts? David
 

Eric Lemoine wrote:
> On Thu, Jun 5, 2008 at 6:18 PM, David R Robison
> <drrobison at openroadsconsulting.com> wrote:
>   
>> We are having a pecular problem when clicking on a map. The map is on a
>> large web page. If the page is scrolled partway down (not positioned at
>> the top of the map), clicking on the map will return an XY position that
>> is above the actual click. If we scroll the page back to the top, then
>> the clicking works. We are using OL-2.5. Has anyone else experienced
>> this?
>>     
>
> No. Do you a public page where we can see that, or some code for
> someone to reproduce?
>
>   
>> Was it fixed in 2.6?
>>     
>
> Dunno.
>
>   
>> Thanks, David Robison
>>     
>
> --
> Eric
>   

-- 

David R Robison
Open Roads Consulting, Inc.
708 S. Battlefield Blvd., Chesapeake, VA 23322
phone: (757) 546-3401
e-mail: drrobison at openroadsconsulting.com
web: http://openroadsconsulting.com
blog: http://therobe.blogspot.com
book: http://www.xulonpress.com/book_detail.php?id=2579

This e-mail communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed.  If you are not the intended recipient, you should immediately stop reading this message and delete it from all computers that it resides on. Any unauthorized reading, distribution, copying or other use of this communication (or its attachments) is strictly prohibited.  If you have received this communication in error, please notify us immediately.  



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080610/6b615d46/attachment.html


More information about the Users mailing list