OpenLayers坐标转换


OpenLayers的Map默认使用的地理坐标系统(EPSG:4326),如果我们采用其他投影时,就需要进行投影转换,以使用正确的投影方式。

下面代码为点坐标的转换:

 1 //坐标转换
2
3 this.transform = function (lon, lat) {
4
5 var proj = new OpenLayers.Projection("EPSG:4326");
6
7 var lonlat = new OpenLayers.LonLat(lon,lat);
8
9 lonlat.transform(proj, this.map.getProjectionObject());
10
11 return lonlat;
12
13 }

 

这样,传入的点即可和当前Map保持一致。

posted @ 2011-11-19 15:31  北纬32  阅读(1323)  评论(1编辑  收藏  举报