问题描述
我想在传单中的地图上添加以特定长度绘制的线/折线的比例。我该怎么做?
解决方法
您可以在更新函数 _updateMetric 和 _updateImperial 函数时更改控件的值。
您的代码可能如下所示:
scale = L.control.scale().addTo(map);
scale._updateMetric = function (maxMeters) {
var meters = this._getRoundNum(maxMeters),label = meters < 1000 ? meters + ' m CUSTOM' : (meters / 1000) + ' km CUSTOM';
scale._updateScale(this._mScale,label,meters / maxMeters);
};
scale._update()