2017-04-21 52 views
0

我是新手冊js。我想添加一些額外的選項到我的featureGroup層,但它不工作。如何在傳單中爲featureGroup提供額外的選項?

var marker = L.marker(point, { icon: iconMarker, data: random, class: 'hugo', id: random }); 
var circle = L.circle(point, { 
     color: 'red', 
     fillColor: '#f03', 
     fillOpacity: 0.5, 
     radius: 20 
    }); 


var PoleLayer = L.featureGroup([marker, circle], { 
     options: { 
      attribution: "Pole Group", 
      extra:"extra value", 
      id:"some id" 
     } 
    }); 

標誌物,我能夠訪問選項,但在PoleLayer的情況下,我不能設置任何額外的選項或訪問這些選項任何一個可以幫助我在這裏。

我應該如何爲leaflet js中的featureGroup分配額外的選項?

回答

1

從文檔:http://leafletjs.com/reference.html#featuregroup

featureGroup方法沒有考慮期權的說法。

L.featureGroup(<ILayer[]> layers?) 

我認爲你正在做的是正確的,你設置單獨標記的選項,並把它傳遞給L.featureGroup

而是擴展PoleLayer這樣的:

PoleLayer.options = { 
    attribution: "Pole Group", 
    extra:"extra value", 
    id:"some id" 
}; 

console.log(PoleLayer.options); 
相關問題