【问题标题】:Leaflet + Opendata + WGS 84 = Geographic Transformation?Leaflet + Opendata + WGS 84 = 地理转型?
【发布时间】:2020-04-15 23:33:47
【问题描述】:

我正在以 shp 和 json 格式可视化来自奥地利的 Opendata。 我可以用传单映射数据,但是标记和轨迹发生了变化......所以我联系了负责部门并得到了以下回复 - 我不知道如何在传单中进行管理:

Die geometrische Projektion der OGD-Datan für Tirol

ist MGI_Austria_GK_West

hier die Projektionsparameter: MGI_Austria_GK_West WKID: 31254 权威:EPSG

投影:Transverse_Mercator

False_Easting:0,0 False_Northing:-5000000,0 Central_Meridian: 10,33333333333333 Scale_Factor:1,0 Latitude_Of_Origin:0,0 线性 单位:米(1,0)

ETRS_1989_To_WGS_1984+MGI_To_ETRS_1989_5

该代码运行良好,但我如何实现 wgs?

var mymap = L.map('map').setView([47.25, 11.39], 14)

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(mymap);

var markers = L.markerClusterGroup();
var geoJsonLayer;

    shp("natur/RNA_NSGEBPolygon").then(function(geojson){
        //do something with your geojson
        console.log(geojson);

    geoJsonLayer = L.geoJSON(geojson, {

            filter: function(feature, layer) {
                if(feature.properties){ 
                    return true;
                }//End if
            },//end filter
            onEachFeature: function(feature, layer){
                layer.bindPopup(feature.properties.NAME);
            }

        })//end L.geojson
        //.addTo(mymap);

    markers.addLayer(geoJsonLayer);
    mymap.addLayer(markers);
    mymap.fitBounds(markers.getBounds());

感谢您的帮助

【问题讨论】:

  • 请分享您的代码
  • ...在原始帖子中添加的代码。问候

标签: leaflet wgs84


【解决方案1】:

我认为这是因为您收到的数据采用 latlng 格式的坐标,但 L.geoJSON 需要 lnglat

在你的 L.geoJSON 中添加coordsToLatLng 进行转换:

geoJsonLayer = L.geoJSON(geojson, {

            filter: function(feature, layer) {
                if(feature.properties){ 
                    return true;
                }//End if
            },//end filter
            onEachFeature: function(feature, layer){
                layer.bindPopup(feature.properties.NAME);
            },

    coordsToLatLng: function (coords) {
        //                    latitude , longitude, altitude
        //return new L.LatLng(coords[1], coords[0], coords[2]); //Normal behavior
        return new L.LatLng(coords[0], coords[1], coords[2]);
    }

        })//end L.geojson
        //.addTo(mymap);

见:https://stackoverflow.com/a/43549799/8283938

【讨论】:

  • 感谢您的回答... lang lat 不混。轨道只移动了几米......他们告诉我我有一个错误的“项目”,应该使用 wgs84......不知道如何在 lefalet 中实现它......问候
【解决方案2】:

我已经下载了 QGIS(免费版)

导入 SHP 文件,然后将该文件导出为 Geojson 层。重要的是对话框:“KBS”,然后您更改为:“EPSG:4326 - WGS84”,所以我管理了正确的实施...... 干杯

【讨论】:

    猜你喜欢
    • 2012-08-11
    • 2013-10-30
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    • 2021-02-07
    • 2023-03-06
    相关资源
    最近更新 更多