Hi, I would like to display GML vector layer in epsg:4326 on top of WMS Layer in epsg:900913.
The map is initialized like
var options = {
maxExtent: new OpenLayers.Bounds(1150000, 6100000, 2500000,
6600000),
maxResolution: "auto",
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
};
map = new OpenLayers.Map("map", options);
var topo = new OpenLayers.Layer.WMS( "Topo",
http://www.bnhelp.cz/cgi-bin/crtopo2",
{layers:'doprava',format:"image/gif"},
{group:"base",sphericalMercator:true});
// the vector map definition
var vector = new OpenLayers.Layer.GML("Vector","gml.xml");
When I try to initialize the map, the vector layer is not drawed, because of
the coordinates are in different projection.
Q1: Is there some option, which would force the vector layer, that it's feature
will be
recalculated from wgs84 to sphericalmercator, if the base layer would be in
spherical mercator ?
----
Then I tried to redefine preFeatureInsert method of OpenLayers.Layer.Vector, to
get coordinates
for all features in epsg:900913
preFeatureInsert = function(feature) {
for (var i = 0; i < feature.geometry.components.length; i++) {
var x = feature.geometry.components[i].x;
var y = feature.geometry.components[i].y;
var ll = kolo.forwardMercator(x,y);
x = x * 20037508.34 / 180;
y = Math.log(Math.tan((90 + y) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
feature.geometry.components[i].x = x;
feature.geometry.components[i].y = y;
}
};
// the vector map definition
var vector = new OpenLayers.Layer.GML("Vector","gml.xml",
{preFeatureInsert:preFeatureInsert});
When I then redraw the map, no vector features are displayed. But when I check
the "vector" layer object
with Firebug, the vector features do have coordinates in epsg:900913 and the
values do look
reasonable.
Q2: What do I wrong? Is there some better method, how to reproject vector
features from wgs84
to epsg:900913?
Thanks
Jachym
--
Jachym Cepicky
e-mail: [EMAIL PROTECTED]
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
signature.asc
Description: Toto je digitálně podepsaná část zprávy
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
