[OpenLayers-Users] mouse-line offset with Google maps

Erwin Poeze erwin.poeze at gmail.com
Mon Mar 9 11:29:21 EDT 2009


Hello,

I'm new to OpenLayer but I have programming experience with the Google
Maps API. I like the fact that OpenLayers is independent of the 'map
provider' and I am considering to continue programming in OpenLayers.

I ran into a problem that I'm unable to solve. I examined the example
draw-feature.html and replace the map by the Google version, see the
few line below.

[code]
               map = new OpenLayers.Map('map',{
                 projection: new OpenLayers.Projection("EPSG:900913"),
                 displayProjection: new OpenLayers.Projection("EPSG:4326")
               });

               var gphy = new OpenLayers.Layer.Google(
                       "Google Physical",
                       {type: G_PHYSICAL_MAP},
                       {'sphericalMercator': true,
                           'maxExtent': new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
                       }
                 );
[/code]

The example continuous to work, but now I get a vertical offset
between the mouse position and the line drawn. I attached a small
picture to illustrate this. The offset is not constant. Drawing at the
top of the map results in a offset of nearly zero and the offset is
maximal when drawing a line at the bottom.

I read the documentation and tried to play around with the projection,
but I can not imagine that the projection is causing this issue.

Does anyone have any idea what kind of phenomenon this is, and more
important, how I can solve this?

Thank you very much,

Erwin



More information about the Users mailing list