2016-07-26 48 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()

看來,標籤必須是字符串,在我的數據,我試圖把一個整數作爲標籤。所以我得到了一個空白的標籤。