On Mon, 2008-11-10 at 21:30 -0500, Christopher Schmidt wrote: > > http://openlayers.org/pipermail/users/2008-November/008615.html , > http://faq.openlayers.org/vector-related-questions/why-dont-my-vector-features-work-over-google-yahoo-virtual-earth-etc/ > , > http://crschmidt.net/~crschmidt/spherical_mercator.html#reprojecting-vector-data
Hi Christopher,
Hi list,
I have tested the reprojection according to your doc but it does not
work.
See the very simple attached example. They are two points that should be
in the south of France but they appear in the south atlantic ...The two
points are latlon coordinates (EPSG:4326) and the map is set to a
sphericalMercator projection.
Example :
---------------------------------------------------------------------------------------
<html>
<head>
<title>Test with mercator projection</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script
src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
</head>
<body>
<div id="map"y></div>
<script defer="defer" type="text/javascript">
var mapOptions = {
projection: new OpenLayers.Projection("EPSG:900913") ,
displayProjection: new OpenLayers.Projection("EPSG:4326")
};
var map = new OpenLayers.Map('map', mapOptions);
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP,
sphericalMercator: true}
);
var test_layer = new OpenLayers.Layer.Vector('Tests', {
projection: new OpenLayers.Projection("EPSG:4326")
});
var p1 = new OpenLayers.Geometry.Point(-0.8751825,
43.5078933333333)
var feat1 = new OpenLayers.Feature.Vector(p1);
var p2 = new OpenLayers.Geometry.Point(-0.9251825,
43.4578933333333)
var feat2 = new OpenLayers.Feature.Vector(p2);
test_layer.addFeatures([feat1, feat2]);
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addLayers([gphy, test_layer]);
map.setBaseLayer(gphy);
// sets the map center
var proj = new OpenLayers.Projection("EPSG:4326");
var point = new OpenLayers.LonLat(-0.9, 43.5);
point.transform(proj, map.getProjectionObject());
map.setCenter(point, 4, false, false);
</script>
</body>
</html>
---------------------------------------------------------------------------------------
Didrik
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
