[OpenLayers-Users] Vector layer on top of SphericalMercator layer
jrom
jerome.gasperi at gmail.com
Wed May 7 10:08:40 EDT 2008
Hi,
I am trying to reproject lat/lon vector ontop of commercial api using
OpenLayers.
I've spent quite a lot of time on a strange behaviour. My vector does
not appear on the map when i switch on sphericalMercator to true...
The problem is that the point does not appear at all on the map.
However, when i switch sphericalMercator to false, it appears (but not
on the right place at large scale due to projection difference)
I really don't understand what i am doing wrong. I've check the
projected coordinates and they are correct...
Did someone experience such an issue ?
Regards
ps: Here is the code
<html>
<head>
<title>OpenLayers Example</title>
<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer='defer' type='text/javascript'>
var map = new OpenLayers.Map("map", {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
map.addControl(new OpenLayers.Control.Permalink());
map.addControl(new OpenLayers.Control.MousePosition());
var layer = new OpenLayers.Layer.Google("Google",
{ sphericalMercator: true });
map.addLayer(layer);
map.zoomToMaxExtent();
var wkt = new OpenLayers.Format.WKT();
var features = wkt.read("POINT(-71, 42)");
var myVector = new OpenLayers.Layer.Vector("GML",
{projection: new OpenLayers.Projection("EPSG:900913")});
myVector.addFeatures(features);
map.addLayer(myVector);
map.zoomToExtent(myVector.getExtent());
</script>
</body>
</html>
For your information i'm using firefox 2.0.0.14 (inux and windows) and
Safari (Leopard). Same problems on each platforms
--
jrom.
http://www.ombresetlumieres.com
--
jrom.
http://www.ombresetlumieres.com
More information about the Users
mailing list