@@ -182,8 +182,10 @@ MapboxMap.prototype.getLegendColorCodes = function () {
182182 * filter.key - {String} attribute name
183183 * filter.value - {String} attribute value OR
184184 * filter.value - {Array} string attribute value(s)
185+ * attributeNames - {Object} key-value pair of alternate names for feature attributes to display on the pop-up
186+ * i.e. { 'ADM2_EN': 'Province', 'ADM3_EN': 'Municipality' }
185187 */
186- MapboxMap . prototype . addLayerSource = function ( layerName , tilesetName , tilesetUrl , filter ) {
188+ MapboxMap . prototype . addLayerSource = function ( layerName , tilesetName , tilesetUrl , filter , attributeNames ) {
187189 const that = this
188190 const layerID = `${ layerName } -layer`
189191 this . isLoading = true
@@ -210,7 +212,7 @@ MapboxMap.prototype.addLayerSource = function (layerName, tilesetName, tilesetUr
210212 'visibility' : 'visible'
211213 } ,
212214 "paint" : {
213- "fill-outline-color" : "rgba(0,0,0,1.0 )" ,
215+ "fill-outline-color" : "rgba(0,0,0,0.2 )" ,
214216 "fill-color" : colorExpression ,
215217 "fill-opacity" : 1.0 ,
216218 } ,
@@ -251,7 +253,12 @@ MapboxMap.prototype.addLayerSource = function (layerName, tilesetName, tilesetUr
251253 // print all data
252254 var content = ""
253255 for ( key in e . features [ 0 ] . properties ) {
254- content += `${ key } : ${ e . features [ 0 ] . properties [ key ] } `
256+ let attr = key
257+ if ( attributeNames ) {
258+ attr = attributeNames [ key ] ? attributeNames [ key ] : key
259+ }
260+
261+ content += `${ attr } : ${ e . features [ 0 ] . properties [ key ] } `
255262 content += "<br>"
256263 }
257264
0 commit comments