我建立了一个交互式Mapbox示例:https://awahdat.github.io/vizrisk_2020/
我想在地图上添加悬停功能,因此,如果将鼠标移到地图上,您会看到目标状态名称,数据值以及定义数据值单位的字符串。我能够添加悬停功能。但是我希望字符串部分与我从下拉列表中选择的数据值的类型相对应。例如,对于以“ dmg”开头的变量,我希望字符串部分为“损失百万”。对于以“ sum”开头的变量,该字符串为“事件”。以下是我的代码,但似乎不正确。任何想法如何设置?我的github html文件在这里:https://github.com/awahdat/vizrisk_2020/blob/master/index.html
if (name.slice(0, 4) == dmg)
popup.setContent('<div class="marker-title">' + layer.feature.properties.name + '</div>' +
layer.feature.properties[name] + 'million in loss');
else if (name.slice(0, 4) != dmg)
popup.setContent('<div class="marker-title">' + layer.feature.properties.name + '</div>' +
layer.feature.properties[name] + 'incident');