diff --git a/src/ol/Graticule.js b/src/ol/Graticule.js index fc8b5f3932..abb4c37c9b 100644 --- a/src/ol/Graticule.js +++ b/src/ol/Graticule.js @@ -17,7 +17,7 @@ import Text from './style/Text.js'; /** - * @type {ol.style.Stroke} + * @type {module:ol/style/Stroke~Stroke} * @private * @const */ @@ -41,107 +41,94 @@ const INTERVALS = [ */ /** - * @typedef {{map: (ol.PluggableMap|undefined), - * maxLines: (number|undefined), - * strokeStyle: (ol.style.Stroke|undefined), - * targetSize: (number|undefined), - * showLabels: (boolean|undefined), - * lonLabelFormatter: (undefined|function(number):string), - * latLabelFormatter: (undefined|function(number):string), - * lonLabelPosition: (number|undefined), - * latLabelPosition: (number|undefined), - * lonLabelStyle: (ol.style.Text|undefined), - * latLabelStyle: (ol.style.Text|undefined)}} + * @typedef {Object} GraticuleOptions + * @property {module:ol/PluggableMap~PluggableMap} [map] Reference to an + * {@link module:ol/Map~Map} object. + * @property {number} [maxLines=100] The maximum number of meridians and + * parallels from the center of the map. The default value of 100 means that at + * most 200 meridians and 200 parallels will be displayed. The default value is + * appropriate for conformal projections like Spherical Mercator. If you + * increase the value, more lines will be drawn and the drawing performance will + * decrease. + * @property {module:ol/style/Stroke~Stroke} [strokeStyle='rgba(0,0,0,0.2)'] The + * stroke style to use for drawing the graticule. If not provided, a not fully + * opaque black will be used. + * @property {number} [targetSize=100] The target size of the graticule cells, + * in pixels. + * @property {boolean} [showLabels=false] Render a label with the respective + * latitude/longitude for each graticule line. + * @property {function(number):string} [lonLabelFormatter] Label formatter for + * longitudes. This function is called with the longitude as argument, and + * should return a formatted string representing the longitude. By default, + * labels are formatted as degrees, minutes, seconds and hemisphere. + * @property {number} [lonLabelPosition=0] Longitude label position in fractions + * (0..1) of view extent. 0 means at the bottom of the viewport, 1 means at the + * top. + * @property {number} [latLabelPosition=1] Latitude label position in fractions + * (0..1) of view extent. 0 means at the left of the viewport, 1 means at the + * right. + * @property {module:ol/style/Text~Text} [lonLabelStyle] Longitude label text + * style. If not provided, the following style will be used: + * ```js + * new Text({ + * font: '12px Calibri,sans-serif', + * textBaseline: 'bottom', + * fill: new Fill({ + * color: 'rgba(0,0,0,1)' + * }), + * stroke: new Stroke({ + * color: 'rgba(255,255,255,1)', + * width: 3 + * }) + * }); + * ``` + * Note that the default's `textBaseline` configuration will not work well for + * `lonLabelPosition` configurations that position labels close to the top of + * the viewport. + * @param {module:ol/style/Text~Text} [latLabelStyle] Latitude label text style. + * If not provided, the following style will be used: + * ```js + * new Text({ + * font: '12px Calibri,sans-serif', + * textAlign: 'end', + * fill: new Fill({ + * color: 'rgba(0,0,0,1)' + * }), + * stroke: Stroke({ + * color: 'rgba(255,255,255,1)', + * width: 3 + * }) + * }); + * ``` + * Note that the default's `textAlign` configuration will not work well for + * `latLabelPosition` configurations that position labels close to the left of + * the viewport. */ -export let GraticuleOptions; /** * Render a grid for a coordinate system on a map. * @constructor - * @param {GraticuleOptions=} opt_options Options. - * @param {ol.PluggableMap|undefined} opt_options.map Reference to an `ol.Map` - * object. - * @param {number|undefined} opt_options.maxLines The maximum number of - * meridians and parallels from the center of the - * map. The default value is 100, which means that at most 200 meridians - * and 200 parallels will be displayed. The default value is appropriate - * for conformal projections like Spherical Mercator. If you increase - * the value more lines will be drawn and the drawing performance will - * decrease. - * @param {ol.style.Stroke|undefined} opt_options.strokeStyle The stroke style - * to use for drawing the graticule. If not provided, the - * lines will be drawn with `rgba(0,0,0,0.2)`, a not fully opaque black. - * @param {number|undefined} opt_options.targetSize The target size of the - * graticule cells, in pixels. Default value is 100 pixels. - * @param {boolean|undefined} opt_options.showLabels Render a label with the - * respective latitude/longitude for each graticule line. Default is false. - * @param {undefined|function(number):string} opt_options.lonLabelFormatter - * Label formatter for longitudes. This function is called with the - * longitude as argument, and should return a formatted string representing - * the longitude. By default, labels are formatted as degrees, minutes, - * seconds and hemisphere. - * @param {number|undefined} opt_options.lonLabelPosition Longitude label - * position in fractions (0..1) of view extent. 0 means at the bottom of the - * viewport, 1 means at the top. Default is 0. - * @param {number|undefined} opt_options.latLabelPosition Latitude label - * position in fractions (0..1) of view extent. 0 means at the left of the - * viewport, 1 means at the right. Default is 1. - * @param {ol.style.Text|undefined} options.lonLabelStyle Longitude label text - * style. The default is - * ```js - * new ol.style.Text({ - * font: '12px Calibri,sans-serif', - * textBaseline: 'bottom', - * fill: new ol.style.Fill({ - * color: 'rgba(0,0,0,1)' - * }), - * stroke: new ol.style.Stroke({ - * color: 'rgba(255,255,255,1)', - * width: 3 - * }) - * }); - * ``` - * Note that the default's `textBaseline` configuration will not work well - * for `lonLabelPosition` configurations that position labels close to the - * top of the viewport. - * @param {ol.style.Text|undefined} opt_options.latLabelStyle Latitude label - * text style. The default is - * ```js - * new ol.style.Text({ - * font: '12px Calibri,sans-serif', - * textAlign: 'end', - * fill: new ol.style.Fill({ - * color: 'rgba(0,0,0,1)' - * }), - * stroke: new ol.style.Stroke({ - * color: 'rgba(255,255,255,1)', - * width: 3 - * }) - * }); - * ``` - * Note that the default's `textAlign` configuration will not work well for - * `latLabelPosition` configurations that position labels close to the left - * of the viewport. + * @param {module:ol/Graticule~GraticuleOptions=} opt_options Options. * @api */ const Graticule = function(opt_options) { const options = opt_options || {}; /** - * @type {ol.PluggableMap} + * @type {module:ol/PluggableMap~PluggableMap} * @private */ this.map_ = null; /** - * @type {?ol.EventsKey} + * @type {?module:ol/types~EventsKey} * @private */ this.postcomposeListenerKey_ = null; /** - * @type {ol.proj.Projection} + * @type {module:ol/proj/Projection~Projection} */ this.projection_ = null; @@ -206,49 +193,49 @@ const Graticule = function(opt_options) { this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100; /** - * @type {Array.