2
我正在尝试为Leaflet地图查看器开发插件。我有一个带有选项属性列表的类,但是当我尝试访问它们时,使用这个关键字的方法不起作用onAdd
。如何从使用此关键字的方法访问类propertys
L.btsControl = L.Control.extend({
options: {
position: 'topright',
//control position - allowed: 'topleft', 'topright',
//'bottomleft', 'bottomright'
minValue: 'isss',
min: 0,
max: 1,
maxValue: '',
},
initialize: function (options) {
L.Util.setOptions(this, options);
},
onAdd: function (map) {
this._map = map;
this._map.eachLayer(function (layer){
if (layer.options.time_i > this.options.max) {
this.options.maxValue = layer.options.time;
}
if (layer.options.time_i < this.options.min) {
this.options.minValue = layer.options.time;
}
});
//SKIPED CODE
return container;
},
那么,如何从onAdd
方法访问最小和最大属性?现在我越来越
"TypeError: this.options is undefined"
调用函数是:var mycontrol = new L.btsControl().addTo(map);
我编辑问题 – Bungow
请拼写检查您的文章和标题。 – 2016-09-25 13:53:33