Mouse position control

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Mouse position control

Alan U
Taking the code from the trunk, the mouse position control seems a bit wrong. I was getting no feedback in FF and only feedback in IE when making a click on the map.

In the redraw function I changed:

            if (this.lastXy == null ||
                Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||
                Math.abs(evt.xy.y - this.lastXy.y) > this.granularity)
            { //don't update

to:
            if (this.lastXy == null ||
                Math.abs(evt.xy.x - this.lastXy.x) < this.granularity ||
                Math.abs(evt.xy.y - this.lastXy.y) < this.granularity)
            {//don't update

Note the greater/less than signs.

Also, with the granularity value even set to 1, moving slowly across the map causes no update of the xy coords in the control. Though this is designed for, it is not intuitive imo. If you are trying to get a coordinate precisely, then it is highly likely you will be moving the mouse below the granularity level: thus I think the default should be 0.

Alan
Reply | Threaded
Open this post in threaded view
|

Re: Mouse position control

Alan U
I take it all back (almost!)
There isn't necessarily a problem with the code, but I always have my mouse on fast pointer movement. This was never giving me a mouse-movement < 2 pixels.

DOH!!

Turning down the sensitivity of my mouse and the code works (of course). It only updates the control display if the mouse-movement is small enough and mine wasn't.
Therefore, the default granularity should be raised or anyone running the examples/default code will see no feed back from the mousePosition control!
My final points about not being able to get latlong values when moving the mouse slowly are rubbish too.

Alan (gently kicking myself)



Alan U wrote
Taking the code from the trunk, the mouse position control seems a bit wrong. I was getting no feedback in FF and only feedback in IE when making a click on the map.

In the redraw function I changed:

            if (this.lastXy == null ||
                Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||
                Math.abs(evt.xy.y - this.lastXy.y) > this.granularity)
            { //don't update

to:
            if (this.lastXy == null ||
                Math.abs(evt.xy.x - this.lastXy.x) < this.granularity ||
                Math.abs(evt.xy.y - this.lastXy.y) < this.granularity)
            {//don't update

Note the greater/less than signs.

Also, with the granularity value even set to 1, moving slowly across the map causes no update of the xy coords in the control. Though this is designed for, it is not intuitive imo. If you are trying to get a coordinate precisely, then it is highly likely you will be moving the mouse below the granularity level: thus I think the default should be 0.

Alan