OpenLayers: Map doesn't render with a non 'standard' EPSG-code

前端 未结 2 452
借酒劲吻你
借酒劲吻你 2021-01-22 07:00

I have a problem with getting a map in EPSG 3031 to work.

From my research I have already learned that the parameters for the projection have to be defined in the javasc

2条回答
  •  滥情空心
    2021-01-22 07:40

    Please have a look at the following snippet:

    proj4.defs("EPSG:3031", "+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
    ol.proj.proj4.register(proj4);
    var proj3031 = ol.proj.get('EPSG:3031');
    
    var esriArctic = new ol.layer.Tile({
      title: 'ESRI Imagery',
      type: 'base',
      zIndex: 0,
      source: new ol.source.XYZ({
        url: 'https://services.arcgisonline.com/arcgis/rest/services/Polar/Antarctic_Imagery/MapServer/tile/{z}/{y}/{x}'
      })
    });
    
    var map = new ol.Map({
      target: 'map',
      layers: [esriArctic],
      view: new ol.View({
        center: ol.proj.fromLonLat([0, -80], proj3031),
        zoom: 3
      })
    })
       html,
       body,
       #map {
         width: 100%;
         height: 100%;
         overflow: hidden;
       }
    
    
    
    
      

提交回复
热议问题