How can I mix layers with another coordinate system in OpenLayers?

I use an OpenLayers map, and I want to use different map servers in it that use different coordinate systems. Can OpenLayers integrate it into one map and automatically convert coordinate systems?

+3
source share
3 answers

Depending on the layers, you will always have some kind of base layer (map) that you cannot convert. If you want to add data (markers, geo json stuff, etc.) to this map, you will have to convert it to the projection used by baselayer.

For markers, this is easy to do:

// defining our coordinate systems
var google = new OpenLayers.Projection("EPSG:900913"),
    latlon = new OpenLayers.Projection("EPSG:4326");

// transforming the location to the right coordinate system
var location = new OpenLayers.LonLat( 10, 10 ).transform( latlon, google );

// assuming you made an icon and marker layer
var marker = new OpenLayers.Marker( location, icon );     

markerLayer.addMarker( marker );

Openlayers .

+3

, .

, (, KML) JavaScript- (, Dre-), , . OpenLayers (. Dre), , , Proj4JS, .

Proj4JS .

+2

, , , .

, , . WMS . EPSG: 900913, EPSG: 3857. , , , , , . 900913 ( , , ).

, ( ):

var myLayer = new OpenLayers.Layer.WMS(
    "Name",
    "URL", {
        "layer": "layer"
    });

myLayer.projection = "EPSG:3857";

?request=getCapabilities URL- , CRS .

+2
source

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


All Articles