1111
1212import { getWrapNum , conversionDegree } from '@supermap/iclient-common' ;
1313import mapboxgl from 'mapbox-gl' ;
14- import proj4 from 'proj4' ;
15-
1614/**
1715 * @class mapboxgl.supermap.GraticuleLayer
1816 * @category Visualization GraticuleLayer
@@ -84,10 +82,10 @@ const defaultOptions = {
8482 latLabelStyle : defaultTextStyle
8583} ;
8684export class GraticuleLayer {
87- constructor ( map , options ) {
85+ constructor ( map , options , sourceId = 'sm-graticule-layer' ) {
8886 this . map = map ;
8987 this . canvasId = 'sm-graticule-canvasid' ;
90- this . sourceId = 'sm-graticule-layer' ;
88+ this . sourceId = sourceId ;
9189 this . options = options ;
9290 this . resetEvent = this . _reset . bind ( this ) ;
9391 this . styleDataEevent = this . _setLayerTop . bind ( this ) ;
@@ -226,13 +224,8 @@ export class GraticuleLayer {
226224 const crs = ( map . getCRS && map . getCRS ( ) ) || { } ;
227225 let { epsgCode, extent : crsExtent } = crs ;
228226 if ( ! crsExtent ) {
229- epsgCode = 'EPSG:3857' ;
230- crsExtent = [ - 20037508.3427892 , - 20037508.3427892 , 20037508.3427892 , 20037508.3427892 ] ;
227+ crsExtent = [ - 180 , - 85.05119 , 180 , 85.05119 ] ;
231228 }
232- crsExtent = [
233- ...this . _unproject ( [ crsExtent [ 0 ] , crsExtent [ 1 ] ] , epsgCode ) ,
234- ...this . _unproject ( [ crsExtent [ 2 ] , crsExtent [ 3 ] ] , epsgCode )
235- ] ;
236229 if ( ! extent || extent . length === 0 ) {
237230 return crsExtent ;
238231 }
@@ -247,18 +240,6 @@ export class GraticuleLayer {
247240 return extent ;
248241 }
249242
250- _unproject ( point , epsgCode ) {
251- if ( epsgCode === 'EPSG:4326' ) {
252- return point ;
253- }
254- const coor = proj4 ( epsgCode , 'EPSG:4326' , point ) ;
255- const proj = proj4 . defs ( epsgCode ) ;
256- if ( proj . axis && proj . axis . indexOf ( 'ne' ) === 0 ) {
257- coor . reverse ( ) ;
258- }
259- return coor ;
260- }
261-
262243 _updateRotate ( ) {
263244 const canvas = this . canvas ;
264245 const sw = this . map . unproject ( [ 0 , canvas . height ] ) ;
0 commit comments