Leaflet + Opendata + WGS 84 = География c Преобразование? - PullRequest
0 голосов
/ 14 апреля 2020

Я визуализирую Opendata из Австрии в формате shp и json. Я могу сопоставить данные с листовкой, но маркеры и дорожки смещены ... Поэтому я связался с ответственным отделом и получил следующий ответ - и я понятия не имею, как мне это сделать в листовке:

D ie геометрич. Projektion der OGD-Daten für Tirol

ist MGI_Austria_GK_West

hier d ie Projektionsparameter: MGI_Austria_GK_West WKID: 31259 * 100 * EPS * 100 * * * * * * * 100 * Проекция: 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());

Спасибо за помощь

Ответы [ 2 ]

0 голосов
/ 15 апреля 2020

Я скачал QGIS (Freeversion)

импортировал файл SHP и затем экспортировал файл в виде слоя Geo json. Важным является диалоговое окно: «KBS», и вы меняете его на: «EPSG: 4326 - WGS84», и поэтому я справился с правильной реализацией ... cheers

0 голосов
/ 14 апреля 2020

Я думаю, это потому, что вы получаете данные с координатами в формате latlng, но L.geo JSON необходимо lnglat

Добавить coordsToLatLng в вас L.geo JSON для конвертировать:

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);

См .: { ссылка }

...