如何在传单控件搜索结果中显示 2 个值(工具提示)

How to display 2 values on leaflet control search result(tooltip)

我正在使用 leaflet-control-search 来搜索标记。http://labs.easyblog.it/maps/leaflet-search/examples/outside.html 标记存储在 json 中,像这样

[{"loc":["lat","lng"],"title":"black","region":"West-Kilimajaro"}]

在上面的脚本中它只显示 1 个值:screen shot

我想显示 2(两个)值 'title 和 'colour';

来自项目 github 回购的例子 Project's Github example html

////////////populate map with markers from sample data
for(i in data) {
    var title = data[i].title,  //value searched
        loc = data[i].loc,      //position found
        marker = new L.Marker(new L.latLng(loc), {title: title} );//se property searched
    marker.bindPopup('title: '+ title );
    markersLayer.addLayer(marker);
}

要向标记添加额外值,请使用额外字段更新此行

marker.bindPopup('title: '+ title + ' color:' data[i].color);

我终于找到解决方案第二个属性假设添加如下

 for(i in data) {
 var title = data[i].title,region=data[i].region,
 loc = data[i].loc, 
 marker = new L.Marker(new L.latLng(loc), {title: title,region:region} );
 marker.bindPopup('title: '+ title );
 markersLayer.addLayer(marker);}

标记存储在 json 中应该如下所示

{"loc":[-3.3869, 36.6830], "title": "aquamarinee", "region": "West-Kilimanaro"}