Change projection on an OpenLayers map

I want to set "EPSG: 4326" as the projection of the OpenLayers map, but when I try to do this, 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"

    ...

}

Basic map is an open street map.

How to set up projection on EPSG: 4326?

+3
source share
4 answers

This Osmarender has a hard-coded projection 900913, and there's nothing to be done. But do you think everything is different? Converting your coordinates or layer to EPSG: 900913? Check out the documentation here: http://docs.openlayers.org/library/spherical_mercator.html

+2
source

, / ( 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);
+5

. GMaps Bing? , OpenLayers , .

0

, . - , - WSG-84 (EPSG: 4326)

0

Source: https://habr.com/ru/post/1741902/


All Articles