<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=093545617-22012010><FONT face=Arial
color=#0000ff size=2>Hi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=093545617-22012010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=093545617-22012010><FONT face=Arial
color=#0000ff size=2>instead of your declaration</FONT></SPAN></DIV>
<DIV dir=ltr align=left>gbase = new OpenLayers.Layer.Google( "Google Physical",
{type: G_PHYSICAL_MAP}, {'sphericalMercator': true} ); <BR></DIV>
<DIV dir=ltr align=left><SPAN class=093545617-22012010><FONT face=Arial
color=#0000ff size=2>you have to use</FONT></SPAN></DIV>
<DIV dir=ltr align=left>gbase = new OpenLayers.Layer.Google( "Google Physical",
{type: G_PHYSICAL_MAP, 'sphericalMercator': true} ); <BR></DIV>
<DIV><SPAN class=093545617-22012010></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT size=2><SPAN
class=093545617-22012010>t</SPAN>hen your map is in spericalMercator<SPAN
class=093545617-22012010>. Otherwise it seems, that instead of your options for
the map, the baselayer projection is taken and that is
EPSG:4326.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=093545617-22012010></SPAN></FONT></FONT></FONT><FONT face=Arial
color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=093545617-22012010><FONT face=Arial color=#0000ff
size=2>Arnd</FONT></SPAN></DIV>
<DIV><BR></DIV>
<DIV class=OutlookMessageHeader lang=de dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Von:</B> users-bounces@openlayers.org
[mailto:users-bounces@openlayers.org] <B>Im Auftrag von </B>julien
minet<BR><B>Gesendet:</B> Freitag, 22. Januar 2010 13:57<BR><B>An:</B>
users@openlayers.org<BR><B>Betreff:</B> [OpenLayers-Users] Points and Popup
shifted on a Google background<BR></FONT><BR></DIV>
<DIV></DIV>Hi again, <BR><BR>I've seen that no attachment can be sent to the
list. So I've put the code at the end of this
mail...<BR><BR><BR>-----------------<BR>I've have a problem of misplacement of
features and popup when adding a vector layer to a OL map with a background
Google.<BR><BR>I just want ot add some points entered in WGS84 (by
OpenLayers.Layer.Vector) to a map with a Google layer as the base layer. I've
put my map in spherical Mercator, as well as the google layer and I've
transformed my points in EPSG:900913 but I still have a problem!<BR><BR>My
points are displayed near the exact location, but with a slight shift. When I
zoom/zoom over or if I pan in the N-S direction, points are changing of
position. Until here, it seems that it is just a projection problem, but I think
I'm doing right in the projection setup(?)<BR><BR>But the most surprising is
that the popup, which should be displayed on the points when clicking on it, are
displayed at the exact locations, at any scale! So the position of the popup are
right!<BR><BR>If I try to transfom the points from EPSG4326 to EPSG900913, they
are not displayed anymore anywhere...<BR><BR>I've attached my stand-alone
working code.<BR><BR><BR>This identically happen under WinXP-IE7 or FF and
Ubuntu-FF.<BR><BR>Any hints are
welcome!<BR><BR>Julien<BR><BR>----------------------------<BR> <html
xmlns="<A
href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>">
<BR> <head> <BR> <link rel="stylesheet"
href="<A
href="http://openlayers.org/dev/theme/default/style.css">http://openlayers.org/dev/theme/default/style.css</A>"
type="text/css" /> <BR> <link rel="stylesheet"
href="<A
href="http://openlayers.org/dev/examples/style.css">http://openlayers.org/dev/examples/style.css</A>"
type="text/css" /> <BR> <title>Wallonie with
GoogleMaps</title> <BR> <script src='<A
href="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAACxUxJ46tcIiZKWG81HlNYBQNmDPi4Y89dW251X5Bl4Z1--Eg2BTkAwr63SeUaRI4wI8RwX7LgtHN0g">http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAACxUxJ46tcIiZKWG81HlNYBQNmDPi4Y89dW251X5Bl4Z1--Eg2BTkAwr63SeUaRI4wI8RwX7LgtHN0g</A>'></script>
<BR> <script src="<A
href="http://openlayers.org/api/OpenLayers.js">http://openlayers.org/api/OpenLayers.js</A>"></script>
<BR> <script type="text/javascript">
<BR> var map, gbase, points, selectControl,
selectedFeature;<BR> var proj = new
OpenLayers.Projection("EPSG:4326");<BR> var bounds = new
OpenLayers.Bounds(6.190,50.517,6.205,50.535);<BR>
bounds.transform(proj, map.getProjectionObject());<BR><BR> var
options = { <BR> projection: new
OpenLayers.Projection("EPSG:900913"),<BR>
displayProjection: new
OpenLayers.Projection("EPSG:4326"),<BR>
units: "m",<BR> numZoomLevels:
18,<BR> maxResolution:
156543.0339,<BR> maxExtent: new
OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)
<BR> };<BR><BR>
function onPopupClose(evt)
{<BR>
selectControl.unselect(selectedFeature);<BR>
}<BR> function
onFeatureSelect(feature)
{<BR>
selectedFeature =
feature;<BR>
popup = new OpenLayers.Popup.FramedCloud("chicken",
<BR>
feature.geometry.getBounds().getCenterLonLat(),<BR>
null,<BR>
"<div" + <A href="http://feature.id">feature.id</A>
+"></div>",<BR>
null, true,
onPopupClose);<BR>
popup.setBackgroundColor("red");<BR>
popup.setBorder("10px");<BR>
feature.popup =
popup;<BR>
map.addPopup(popup);<BR>
}<BR><BR> function
onFeatureUnselect(feature)
{<BR>
map.removePopup(feature.popup);<BR>
feature.popup.destroy();<BR>
feature.popup = null;<BR>
} <BR> <BR> function init() {
<BR> map = new
OpenLayers.Map('map',options);
<BR> // Add google layers
<BR> gbase = new
OpenLayers.Layer.Google( "Google Physical", {type: G_PHYSICAL_MAP},
{'sphericalMercator': true} );
<BR><BR>
map.addLayer(gbase);<BR><BR> // Add
Bornes Frontières Geometry<BR> var
Bornes = new Array();<BR>
<BR> Bornes[0] = new
OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(6.20475,50.52167));<BR>
Bornes[1] = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(6.20440,50.52148));
<BR> //Bornes[0] = new
OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(6.20475,50.52167).transform(new
OpenLayers.Projection("EPSG:4326"),new
OpenLayers.Projection("EPSG:900913")));<BR>
//Bornes[1] = new OpenLayers.Feature.Vector(new
OpenLayers.Geometry.Point(6.20440,50.52148).transform(new
OpenLayers.Projection("EPSG:4326"),new
OpenLayers.Projection("EPSG:900913")));<BR><BR>
points = new OpenLayers.Layer.Vector("Infos", {projection: new
OpenLayers.Projection("EPSG:4326")});<BR>
points.addFeatures(Bornes);<BR>
<BR>
map.addLayer(points);<BR> <BR> //
Ajout des Controls <BR>
map.addControl(new OpenLayers.Control.LayerSwitcher());
<BR> map.addControl(new
OpenLayers.Control.ScaleLine({div:document.getElementById("scale")}));
<BR> map.addControl(new
OpenLayers.Control.MousePosition({div:document.getElementById("mouseposition")}));
<BR><BR>
selectControl = new OpenLayers.Control.SelectFeature(points,{onSelect:
onFeatureSelect, onUnselect:
onFeatureUnselect});<BR>
map.addControl(selectControl);<BR>
selectControl.activate();<BR> <BR>
map.zoomToExtent(bounds);<BR>
} <BR> <BR>
</script> <BR> </head> <BR> <body
onload="init()"> <BR> <h4
id="title">Wallonie with GoogleMaps</h4>
<BR> <div> Carte dynamique
OpenLayers</div> <BR> <div
style="width:100%; height:80%" id="map"></div>
<BR> <div align="right"
id="mouseposition"></div> <BR> <div
align="right" id="scale"> </div> <BR> </body>
<BR></html><BR></BODY></HTML>