扩展了一些可有可无的小功能,方便偷懒
// 是否在圆内
L.Circle.include({
contains: function (point) {
let bounds = this.getBounds()
return bounds.contains(point);
},
});
// 是否在矩形内
L.Rectangle.include({
contains: function (point) {
let bounds = this.getBounds()
return bounds.contains(point);
},
});
// 是否在矢量内
L.Polygon.include({
contains: function (point) {
let bounds = this.getBounds()
return bounds.contains(point);
},
});
// 图层组一次添加多个图层
L.LayerGroup.include({
addLayers: function (list) {
for (let i = 0; i < list.length; i++) {
let layer = list[i]
// this.addLayer(layer)
var id = this.getLayerId(layer);
this._layers[id] = layer;
if (this._map) {
this._map.addLayer(layer);
}
}
},
});