1.自己发布了一个投影坐标为2383的地图,iServer中可以浏览。
2.然后利用Proj4定义了2383的投影坐标,但是在使用的过程中No projection definition for code EPSG:2383。
您好,这个2383的proj4.js不支持,需要自己定义,可以参考
http://iclient.supermap.io/en/web/introduction/leafletDevelop.html#multiProjection
上面定义了啊,
proj4.defs["EPSG:2383"] = "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs";
但是定义了之后还是找不到,我用npm安装了proj4包,并且引入了leaflet。
import React, {Component} from 'react'; import logo from './logo.svg'; import styles from './style.css'; import './App.css'; import proj4 from 'proj4'; const L = window.L; class App extends Component { componentDidMount() { var url1 = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World"; var urlMap = "http://10.219.245.97:8090/iserver/services/map-DGGW/rest/maps/Map"; // TODO:初始化地图信息success // var map = L.map('mapContainer', { // crs: L.CRS.EPSG4326, // center: [0, 0], // maxZoom: 18, // zoom: 1 // }); // L.supermap.tiledMapLayer(url1).addTo(map); //TODO:测试1 // var map = L.map('mapContainer', { // crs: L.CRS.NonEarthCRS({ // bounds: L.bounds([ 100000.0,2000000.0], [509631.29,2524214.69]), // origin: L.point(100000.0, 2524214.69 ) // }), // center: [509340.59 , 2523457.49 ], // maxZoom: 18, // zoom: 1 // }); //TODO:测试2 proj4.defs["EPSG:2383"] = "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m +no_defs"; var crs =L.Proj.CRS("EPSG:2383",{ origin: [509340.59,2523457.49], scales:0.001369265315, }); var map = L.map('mapContainer', { crs: crs, center: [0, 0], maxZoom: 18, zoom: 1 }); // 添加图层 // L.supermap.tiledMapLayer(urlMap, {noWrap: true}).addTo(map); L.supermap.tiledMapLayer(urlMap).addTo(map); } render() { return ( <div className="App"> <div id="mapContainer"></div> </div> ); } } export default App;