Skip to content

Commit 77d6a58

Browse files
committed
chore: Arrange the labels ordering on livelihood zones map pop-up, #43
1 parent 3fb0bb6 commit 77d6a58

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

static/map.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ MapboxMap.prototype.initMap = function ({ mapContainer = 'map', style, zoom, cen
136136
'ADM1_EN': 'Region',
137137
'ADM2_EN': 'Province',
138138
'ADM3_EN': 'Municipality',
139+
'Zone': 'Zone',
139140
'Legend_2': 'Legend'
140141
}
141142

@@ -153,16 +154,13 @@ MapboxMap.prototype.initMap = function ({ mapContainer = 'map', style, zoom, cen
153154

154155
if (features) {
155156
window.MBL.map.on('click', `${that.layerNames[i]}`, function (e) {
156-
// print all data
157+
// print data by order as defined in attributeNames
157158
var content = ''
158-
for (let item in e.features[0].properties) {
159-
let attr = item
160-
if (attributeNames) {
161-
attr = attributeNames[item] ? attributeNames[item] : item
159+
for (let item in attributeNames) {
160+
if (e.features[0].properties[item] !== undefined) {
161+
content += `<strong>${attributeNames[item]}</strong>: ${e.features[0].properties[item]}`
162+
content += '<br>'
162163
}
163-
164-
content += `<strong>${attr}</strong>: ${e.features[0].properties[item]}`
165-
content += '<br>'
166164
}
167165

168166
new mapboxgl.Popup()

0 commit comments

Comments
 (0)