在OpenLayers Map中更改投影 [英] Change Projection in OpenLayers Map
问题描述
我想将EPSG:4326设置为OpenLayers地图的投影,但是当我尝试时,我总是得到EPSG:900913。
I want to set "EPSG:4326" as the projection of an OpenLayers map, but when I try it, I always get "EPSG:900913".
function init() {
var options = {
projection: new OpenLayers.Projection("EPSG:4326") // ignored
};
map = new OpenLayers.Map('map', options);
var layer = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
map.addLayer(layer);
...
alert(map.getProjection()); // returns "EPSG:900913"
...
}
基本地图是开放的街道地图。
The base map is open street map.
如何将投影设置为EPSG:4326?
How can I set the Projection to EPSG:4326?
推荐答案
Osmarender有一个硬编码的900913投影,与此无关。但你有没有考虑过相反的事情?将坐标或图层转换为EPSG:900913?请查看此处的文档: http://docs.openlayers.org/library/spherical_mercator.html
It is Osmarender that has a hardcoded 900913 projection, nothing to do about that. But have you considered taking things the other way around? Transforming your coordinates or layer to EPSG:900913? Check the documentation here: http://docs.openlayers.org/library/spherical_mercator.html
这篇关于在OpenLayers Map中更改投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!