简体   繁体   English

Proj4:如何将坐标从 EPSG 4326 转换为 EPSG 31370

[英]Proj4: How to convert coordinates from EPSG 4326 to EPSG 31370

Need to convert coordinates of Leaflet.js Map from EPSG 4326 to EPSG 31370.需要将 Leaflet.js Map 的坐标从 EPSG 4326 转换为 EPSG 31370。

What I did till now: Defining EPSG 31370到目前为止我所做的:定义 EPSG 31370

proj4.defs["EPSG:31370"] = "+proj=lcc +lat_1=51.16666723333333 +lat_2=49.8333339 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747 +units=m +no_defs";

And Calling it:并称它:

console.log(proj4('EPSG:31370', [map.getCenter().lat,map.getCenter().lng]));

However, it results into '31370 undefined' error in console.但是,它会导致控制台出现“31370 未定义”错误。

The problem is with your initial definitions for EPSG 31370. The following works.问题在于您对 EPSG 31370 的初始定义。以下工作。

 // Define the source and target projections proj4.defs("EPSG:4326", "+proj=longlat +datum=WGS84 +no_defs"); proj4.defs("EPSG:31370", "+proj=lcc +lat_1=51.16666723333333 +lat_2=49.8333339 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747 +units=m +no_defs"); // Define the coordinates to convert const sourceCoord = [1, 1]; // Convert the coordinates const targetCoord = proj4("EPSG:4326", "EPSG:31370", sourceCoord); console.log(targetCoord);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.8.1/proj4.min.js" integrity="sha512-JToqu2hzfiepDTg9LjkVzYhUhTcYGJIj2aGOn3Q+7sPVSi2n+vmpxISCbOJ2b3I4OQmqG0KQYovX6f3Rx+etAQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

After getting these conversion results, you can verify them here .得到这些转换结果后,你可以在这里验证它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM