dea*_*mon 3 javascript geospatial openlayers openstreetmap proj4js
我想将"EPSG:4326"设置为OpenLayers地图的投影,但是当我尝试它时,我总是得到"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"
...
}
Run Code Online (Sandbox Code Playgroud)
基本地图是开放的街道地图.
如何将投影设置为EPSG:4326?
正如milovanderlinden指出的那样,你必须先转换纬度/经度值(如Google或Bing地图中所使用的那样),然后才能在OpenStreetMap图层中应用,Osmarender或者Mapnik:
var datapoint = new OpenLayers.LonLat(-71.0, 42.0);
var proj_1 = new OpenLayers.Projection("EPSG:4326");
var proj_2 = new OpenLayers.Projection("EPSG:900913");
datapoint.transform(proj_1, proj_2);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13537 次 |
| 最近记录: |