【问题标题】:Setup projection on Leafletjs在 Leafletjs 上设置投影
【发布时间】:2013-03-06 17:50:11
【问题描述】:

我正在为一个家庭项目使用 Leafletjs(这是它看起来,现在。 但我找不到必须设置投影,我为 OpenLayers 找到了它,看起来像这样:

// Openlayers settings 
    //var defaultMaxExtent = new OpenLayers.Bounds(427304, 6032920, 927142, 6485144); 
    var defaultMaxExtent = new OpenLayers.Bounds(427304, 6032920, 927142, 6485144);

    var defaultProjection = "EPSG:25832";
    var defaultUnits = "Meters";
    var defaultResolutions = new Array(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024);
    var defaultExtent = new OpenLayers.Bounds(215446, 2103547, 706886, 6203897); //this extent is used when the page is loaded.
    //var defaultExtent = new OpenLayers.Bounds(705446, 6203547, 706886, 6203897); //this extent is used when the page is loaded.
    map = new OpenLayers.Map('map', { projection: defaultProjection, units: defaultUnits, maxExtent: defaultMaxExtent, resolutions: defaultResolutions, controls: [

        // Hide controls by default
    new OpenLayers.Control.Navigation({ wheelChange: HideInfoBox() }),
    new OpenLayers.Control.ArgParser(),
    new OpenLayers.Control.Attribution()]
    });
    layer = new OpenLayers.Layer.WMS("kort", "http://serverAddress?", { nbr: '', username: 'admin', password: 'adminadmin', layers: 'Overlayer', format: 'image/png' });

谁能帮帮我?

更新: 我试图从 Leaflet 中获取标准投影并对其进行自定义,就像这样

L.CRS.EPSG25832 = L.extend({}, L.CRS, {
    code: 'EPSG:25832',
    projection: L.Projection.SphericalMercator,
    transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),

    project: function (latlng) { // (LatLng) -> Point
        var projectedPoint = this.projection.project(latlng),
                earthRadius = 6378137;
        return projectedPoint.multiplyBy(earthRadius);
    }
});

现在投影是正确的。但是现在的问题是坐标是错误的,例如,如果我从 Leaflet 获得坐标,Kolding 现在位于法国中部而不是丹麦。

【问题讨论】:

标签: leaflet map-projections


【解决方案1】:

我自己找到了问题的解决方案。 改为这样做:

var crs = L.CRS.proj4js('EPSG:25832', '+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs', new L.Transformation(0.5 / (Math.PI * L.Projection.Mercator.R_MAJOR), 0.5, -0.5 / (Math.PI * L.Projection.Mercator.R_MINOR), 0.5));

  var map = new L.Map('Krak-Map', { center: new L.LatLng(latitude, longitude), zoom: 17, crs: crs });

【讨论】:

  • 嗨 Morten,我在这里与其他投影有类似的问题:stackoverflow.com/questions/31070949/… 问题:你去哪里找到转换部分?
  • 那么问题是 EPSG:25832 不受支持,但您通过添加 utm + zone 32 等来纠正它?
猜你喜欢
  • 2014-04-24
  • 1970-01-01
  • 2012-05-15
  • 2018-08-31
  • 1970-01-01
  • 1970-01-01
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多