@@ -341,6 +341,11 @@ export class WebMap extends Observable {
341
341
that . addLayers ( mapInfo ) ;
342
342
}
343
343
}
344
+
345
+ // 经纬网
346
+ if ( mapInfo . grid && mapInfo . grid . graticule ) {
347
+ that . createGraticuleLayer ( mapInfo . grid . graticule ) ;
348
+ }
344
349
} else {
345
350
// 不支持的坐标系
346
351
that . errorCallback && that . errorCallback ( { type : "Not support CS" , errorMsg : `Not support CS: ${ mapInfo . projection } ` } , 'getMapFaild' , that . map ) ;
@@ -4708,4 +4713,54 @@ export class WebMap extends Observable {
4708
4713
version = userAgent . match ( / c h r o m e \/ ( [ \d . ] + ) / ) ;
4709
4714
return + version [ 1 ] ;
4710
4715
}
4716
+
4717
+ /**
4718
+ * @private
4719
+ * @function ol.supermap.WebMap.prototype.createGraticuleLayer
4720
+ * @description 创建经纬网图层
4721
+ * @param {object } layerInfo - 图层信息
4722
+ * @returns {ol/layer/Vector } 矢量图层
4723
+ */
4724
+ createGraticuleLayer ( layerInfo ) {
4725
+ const { strokeColor, strokeWidth, lineDash, extent, visible, interval, lonLabelStyle, latLabelStyle } = layerInfo ;
4726
+ let graticuleOptions = {
4727
+ layerID : 'graticule_layer' ,
4728
+ strokeStyle : new StrokeStyle ( {
4729
+ color : strokeColor ,
4730
+ width : strokeWidth ,
4731
+ lineDash
4732
+ } ) ,
4733
+ extent,
4734
+ visible : visible ,
4735
+ intervals : interval ,
4736
+ showLabels : true ,
4737
+ zIndex : 9999 ,
4738
+ wrapX : false ,
4739
+ targetSize : 0
4740
+ } ;
4741
+ lonLabelStyle && ( graticuleOptions . lonLabelStyle = new Text ( {
4742
+ font : `${ lonLabelStyle . fontSize } ${ lonLabelStyle . fontFamily } ` ,
4743
+ textBaseline : lonLabelStyle . textBaseline ,
4744
+ fill : new FillStyle ( {
4745
+ color : lonLabelStyle . fill
4746
+ } ) ,
4747
+ stroke : new StrokeStyle ( {
4748
+ color : lonLabelStyle . outlineColor ,
4749
+ width : lonLabelStyle . outlineWidth
4750
+ } )
4751
+ } ) )
4752
+ latLabelStyle && ( graticuleOptions . latLabelStyle = new Text ( {
4753
+ font : `${ latLabelStyle . fontSize } ${ latLabelStyle . fontFamily } ` ,
4754
+ textBaseline : latLabelStyle . textBaseline ,
4755
+ fill : new FillStyle ( {
4756
+ color : latLabelStyle . fill
4757
+ } ) ,
4758
+ stroke : new StrokeStyle ( {
4759
+ color : latLabelStyle . outlineColor ,
4760
+ width : latLabelStyle . outlineWidth
4761
+ } )
4762
+ } ) )
4763
+ const layer = new olLayer . Graticule ( graticuleOptions ) ;
4764
+ this . map . addLayer ( layer ) ;
4765
+ }
4711
4766
}
0 commit comments