@@ -341,6 +341,11 @@ export class WebMap extends Observable {
341341 that . addLayers ( mapInfo ) ;
342342 }
343343 }
344+
345+ // 经纬网
346+ if ( mapInfo . grid && mapInfo . grid . graticule ) {
347+ that . createGraticuleLayer ( mapInfo . grid . graticule ) ;
348+ }
344349 } else {
345350 // 不支持的坐标系
346351 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 {
47084713 version = userAgent . match ( / c h r o m e \/ ( [ \d . ] + ) / ) ;
47094714 return + version [ 1 ] ;
47104715 }
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+ }
47114766}
0 commit comments