[OpenLayers-Users] Mouse position coordinates

Richard Greenwood richard.greenwood at gmail.com
Wed Jul 27 21:30:42 EDT 2011


On Wed, Jul 27, 2011 at 4:45 AM, Graham Gauld
<graham.gauld at aberdeenshire.gov.uk> wrote:
> I'm new to OpenLayers.
> I have a problem with my OpenLayers application which affects the display of
> the mouse cursor position coordinates and the placement of points digitised
> onto a Vector layer: namely that the displayed coordinate values and placed
> symbols are located just to the south-east of where the mouse cursor
> actually is.
>
> For example:
>
> actual cursor position
> clicked on the map  ==>     +
>
>                                            +        <== center of symbol
> placed at clicked point by my application
>
>
> I believe the problem lies with a mismatch between the cursor position
> OpenLayers is getting and the true cursor position - if I place the cursor
> over a series of points where I know the true coordinates, the coordinate
> readout from OpenLayers is consistently for a point just to the south-east
> of the true position.
>
> My map is contained in an HTML <div> element within an HTML table cell, and
> has a row of command buttons above it (<input type="image" etc>) and an
> ASP.net TreeView to the left of it. I've noticed that in a version of the
> application with no TreeView to the left (but still with a row of command
> buttons above the map), the problem is still present but apparently not as
> bad - i.e. the offset to the south-east looks less severe.
>
> Could the position of the map <div> element in relation to surrounding HTML
> element in the page cause the coordinates problem?
>
>
> I'm using the British National Grid projection as follows:
>
> var mapOptions =
>            {
>                units : "mm",
>                projection: 'GENS:uk_british_national_grid_mm',
>                scales: [1500000, 1100000, 100000, 50000, 10000, 5000, 2500,
> 1250, 500, 250],
>                maxExtent : maxBounds
>            };
>
>
> map = new OpenLayers.Map('map', mapOptions);
>
>
> The problem appears to exist in both IE and FF.

Graham,

It doesn't look like you've gotten an answer so I'll throw a
guess/question out. Are you sure that you know the "actual cursor
position" of the mouse cursor displayed on the screen? The "hot spot"
of a screen cursor is not always obvious. I use the standard
question-mark-with-arrow cursor in some cases. One would think that
the "hot spot" would be at the tip of the arrow near the upper left
corner of the cursor icon but actually it is at the center of the
icon. I believe there have been some threads on this list discussing
the location of a cursor's hot spot.

Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com


More information about the Users mailing list