MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / createGraticuleLayer

Method createGraticuleLayer

src/openlayers/mapping/WebMap.js:5458–5507  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.createGraticuleLayer * @description 创建经纬网图层 * @param {Object} layerInfo - 图层信息 * @returns {ol.layer.Vector} 矢量图层

(layerInfo)

Source from the content-addressed store, hash-verified

5456 * @returns {ol.layer.Vector} 矢量图层
5457 */
5458 createGraticuleLayer(layerInfo) {
5459 const { strokeColor, strokeWidth, lineDash, extent, visible, interval, lonLabelStyle, latLabelStyle } = layerInfo;
5460 const epsgCode = this.baseProjection;
5461 // 添加经纬网需要设置extent、worldExtent
5462 let projection = new olProj.get(epsgCode);
5463 projection.setExtent(extent);
5464 projection.setWorldExtent(olProj.transformExtent(extent, epsgCode, 'EPSG:4326'));
5465
5466 let graticuleOptions = {
5467 layerID: 'graticule_layer',
5468 strokeStyle: new StrokeStyle({
5469 color: strokeColor,
5470 width: strokeWidth,
5471 lineDash
5472 }),
5473 extent,
5474 visible: visible,
5475 intervals: interval,
5476 showLabels: true,
5477 zIndex: 9999,
5478 wrapX: false,
5479 targetSize: 0
5480 };
5481 lonLabelStyle &&
5482 (graticuleOptions.lonLabelStyle = new Text({
5483 font: `${lonLabelStyle.fontSize} ${lonLabelStyle.fontFamily}`,
5484 textBaseline: lonLabelStyle.textBaseline,
5485 fill: new FillStyle({
5486 color: lonLabelStyle.fill
5487 }),
5488 stroke: new StrokeStyle({
5489 color: lonLabelStyle.outlineColor,
5490 width: lonLabelStyle.outlineWidth
5491 })
5492 }));
5493 latLabelStyle &&
5494 (graticuleOptions.latLabelStyle = new Text({
5495 font: `${latLabelStyle.fontSize} ${latLabelStyle.fontFamily}`,
5496 textBaseline: latLabelStyle.textBaseline,
5497 fill: new FillStyle({
5498 color: latLabelStyle.fill
5499 }),
5500 stroke: new StrokeStyle({
5501 color: latLabelStyle.outlineColor,
5502 width: latLabelStyle.outlineWidth
5503 })
5504 }));
5505 const layer = new olLayer.Graticule(graticuleOptions);
5506 this.map.addLayer(layer);
5507 }
5508 /**
5509 * @private
5510 * @function WebMap.prototype.getLang

Callers 1

addGraticuleMethod · 0.95

Calls 2

setExtentMethod · 0.45
addLayerMethod · 0.45

Tested by

no test coverage detected