我正在使用传单控制搜索来搜索标记。http://labs.easyblog.it/maps/leaflet-search/examples/outside.html 标记存储在json中,如此
[{"loc":["lat","lng"],"title":"black","region":"West-Kilimajaro"}]
在上面的脚本中只显示1个值:screen shot
我想显示2(两个)值'标题和'颜色';
答案 0 :(得分:0)
来自项目' github repo的示例 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);
答案 1 :(得分:0)
我终于找到了解决方案的第二个属性,假设要添加如下
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"}