* @function GraticuleLayer.prototype.onAdd * @description 添加该图层。 * @param {maplibregl.Map} map - MapLibreGL Map 对象。
(map)
| 106 | * @param {maplibregl.Map} map - MapLibreGL Map 对象。 |
| 107 | */ |
| 108 | onAdd(map) { |
| 109 | this.map = map; |
| 110 | this.renderer = new GraticuleLayerRenderer(this.map, this.options, { |
| 111 | getMapStateByKey: this.getMapStateByKey, |
| 112 | getDefaultExtent: this.getDefaultExtent, |
| 113 | updateGraticuleLayer: this.updateGraticuleLayer.bind(this), |
| 114 | setVisibility: this.setVisibility.bind(this) |
| 115 | }, { |
| 116 | mapElement: this.map.getCanvas(), |
| 117 | targetElement: this.map.getCanvasContainer(), |
| 118 | id: this.id |
| 119 | }); |
| 120 | this.addGraticuleLayer(); |
| 121 | this.resizeEvent = this.renderer._resizeCallback.bind(this.renderer); |
| 122 | this.zoomendEvent = this.setVisibility.bind(this); |
| 123 | this._bindEvent() |
| 124 | } |
| 125 | |
| 126 | render() { |
| 127 | this.renderer.draw(); |
nothing calls this directly
no test coverage detected