2016-07-26 55 views
0

好的,我有一个GeoJSON点文件,我正在阅读Leaflet。我注意到bindPopup读取记录编号(feature.properties.Record/Label),但是我无法使bindLabel读取它。如果我删除feature.properties.Record并将其替换为“Demo”,那么我会得到一个标签。单张标签不读取geojson

onEachFeature: function (feature, layer) { 
    layer.bindPopup("<p>Record: " + feature.properties.Record + "</p>"), //works 
    //layer.bindLabel(feature.properties['Record'], { noHide:true, className: 'text-labels' }), //Doesn't work 
    //layer.bindLabel(feature.properties.Record, { noHide:true, className: 'text-labels' }), //Doesn't work 
    layer.bindLabel('Hello', { noHide:true, className: 'text-labels' }), //works but I don't want to manually label each one. 

layer.addTo(map). 
layer.showLabel(); 

任何想法?我试过提示选项,但我得到的bindtooltip不是一个函数。

回答

1

好的简单的愚蠢的错误。

feature.properties [“记录”]应该是feature.properties [“记录”] 的ToString()

看来,标签必须是字符串,在我的数据,我试图把一个整数作为标签。所以我得到了一个空白的标签。