[OpenLayers-Users] FW: OpenLayers Beginners Questions

Matt Hancher mdh at email.arc.nasa.gov
Sun Jun 17 13:55:56 EDT 2007


On Jun 17, 2007, at 5:04 AM, Christopher Schmidt wrote:

>> 2.	
>>
>> 	Problem with "var pointLayer = new OpenLayers.Layer.Vector("Point
>> Layer");" and similar (Line and Polygon): All draw controls seem  
>> to draw
>> points and vertices south-east of where the mouse-click occurred  
>> by about
>> 1/2 of the diameter of the drawn Point-Circle. That means all  
>> drawn features
>> are miss-placed. Is this a bug or is it just that I do use the  
>> draw feature
>> wrongly? Source attached below. The website is at this stage not  
>> public for
>> administrative reasons; sorry.
>
> Internet Explorer has problems with its 'box model': the 3px border
> you're putting on your map is causing the browser to incorrectly  
> report
> your mouse position relative to the map. If you remove that border,  
> this
> will be fixed: you can instead create a slightly more complicated map
> setup, with the map div inside another div which does have a border,
> rather than putting it directly on a map.
>
> Erik, this is a bug we might be able to work around, can you file a
> ticket for 2.6 to look at this? Gerd, if you or anyone want to  
> submit a
> patch before that, then it should be able to make it into 2.5. The
> function to look into is OpenLayers.Events.getMousePosition().

For what it's worth, I've encountered a similar issue using Firefox  
under
certain specific situations.  For example, again modifying the
editingtoolbar.html example, try this:

     <table style="position:absolute; margin:20px"><tr><td> <div  
id="map"></div> </td></tr></table>

In this case getMousePosition() appears not to properly translate  
from client
coordinates to map-local coordinates, with an offset equal to the  
20px margin.
The problem goes away if you use padding instead of margin, if you  
make the
table non-absolute, if you use a div instead of a table, or if you  
use WebKit
instead of Firefox.  So this was easy enough for me to work around on  
my own,
but I thought if anybody starts looking at adding workarounds to  
getMousePosition()
they might want to know about it.

Matt

Matthew D. Hancher
Intelligent Systems Division
NASA Ames Research Center
Official: mdh at email.arc.nasa.gov
Personal: mdh at maximumentropy.org






More information about the Users mailing list