From aa0adfbc8374bb9929eb1c02c9ff9fba4fda16d5 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Thu, 21 Nov 2019 16:45:05 +0800 Subject: [PATCH 1/3] support `zIndex` option --- index.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 899b589..6149f8c 100644 --- a/index.js +++ b/index.js @@ -720,19 +720,24 @@ /** * TextIconOverlay * @class 此类表示地图上的一个覆盖物,该覆盖物由文字和图标组成,从Overlay继承。文字通常是数字(0-9)或字母(A-Z ),而文字与图标之间有一定的映射关系。 - *该覆盖物适用于以下类似的场景:需要在地图上添加一系列覆盖物,这些覆盖物之间用不同的图标和文字来区分,文字可能表示了该覆盖物的某一属性值,根据该文字和一定的映射关系,自动匹配相应颜色和大小的图标。 + * 该覆盖物适用于以下类似的场景:需要在地图上添加一系列覆盖物,这些覆盖物之间用不同的图标和文字来区分,文字可能表示了该覆盖物的某一属性值,根据该文字和一定的映射关系,自动匹配相应颜色和大小的图标。 * - *@constructor - *@param {Point} position 表示一个经纬度坐标位置。 - *@param {String} text 表示该覆盖物显示的文字信息。 - *@param {Json Object} options 可选参数,可选项包括:
- *"styles":{Array} 一组图标风格。单个图表风格包括以下几个属性:
- * url {String} 图片的url地址。(必选)
- * size {Size} 图片的大小。(必选)
- * anchor {Size} 图标定位在地图上的位置相对于图标左上角的偏移值,默认偏移值为图标的中心位置。(可选)
- * offset {Size} 图片相对于可视区域的偏移值,此功能的作用等同于CSS中的background-position属性。(可选)
- * textSize {Number} 文字的大小。(可选,默认10)
- * textColor {String} 文字的颜色。(可选,默认black)
+ * @constructor + * @param {Point} position 表示一个经纬度坐标位置。 + * @param {string} text 表示该覆盖物显示的文字信息。 + * @param {TextIconOverlayOptions=} options 选项。 + * + * @typedef {object} TextIconOverlayOptions + * @property {IconStyle[]=} styles 一组图标风格。 + * @property {number=} zIndex 等同与CSS中的z-index属性 + * + * @typedef {object} IconStyle + * @property {string} url 图片的url地址。 + * @property {Size} size 图片的大小。 + * @property {Size=} anchor 图标定位在地图上的位置相对于图标左上角的偏移值,默认偏移值为图标的中心位置。 + * @property {Size=} offset 图片相对于可视区域的偏移值,此功能的作用等同于CSS中的background-position属性。 + * @property {number=} [textSize=10] 文字的大小。 + * @property {string} [textColor='black'] 文字的颜色。 */ var TextIconOverlay = function(position, text, options){ try { @@ -745,6 +750,8 @@ this._text = text; this._options = options || {}; this._styles = this._options['styles'] || []; + /** @type {number | undefined} */ + this._zIndex = this.options['zIndex'] (!this._styles.length) && this._setupDefaultStyles(); }; @@ -896,6 +903,9 @@ var textSize = style['textSize'] || 10; var csstext = []; + if (this._zIndex) { + csstext.push('z-index:' + this._zIndex + ';') + } if (T.browser["ie"] < 7) { csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(' + 'sizingMethod=scale,src="' + url + '");'); From d5af08735c8810940b93b6f16b3f31da7a7c0117 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Thu, 21 Nov 2019 17:03:47 +0800 Subject: [PATCH 2/3] code format --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6149f8c..bdd9e66 100644 --- a/index.js +++ b/index.js @@ -751,7 +751,7 @@ this._options = options || {}; this._styles = this._options['styles'] || []; /** @type {number | undefined} */ - this._zIndex = this.options['zIndex'] + this._zIndex = this.options['zIndex']; (!this._styles.length) && this._setupDefaultStyles(); }; @@ -904,7 +904,7 @@ var csstext = []; if (this._zIndex) { - csstext.push('z-index:' + this._zIndex + ';') + csstext.push('z-index:' + this._zIndex + ';'); } if (T.browser["ie"] < 7) { csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(' + From a5e383395b3c7d0921cf4de1329d6625259bb69f Mon Sep 17 00:00:00 2001 From: ipcjs Date: Thu, 21 Nov 2019 17:57:53 +0800 Subject: [PATCH 3/3] fix typo --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index bdd9e66..8841528 100644 --- a/index.js +++ b/index.js @@ -751,7 +751,7 @@ this._options = options || {}; this._styles = this._options['styles'] || []; /** @type {number | undefined} */ - this._zIndex = this.options['zIndex']; + this._zIndex = this._options['zIndex']; (!this._styles.length) && this._setupDefaultStyles(); };