阅读此源代码后
,您可以重新定义header和fromat 消息函数
L.Routing.errorControl(control, {
header: 'Routing error',
formatMessage(error) {
if (error.status < 0) {
return 'Calculating the route caused an error. Technical description follows: <code><pre>' +
error.message + '</pre></code';
} else {
return 'The route could not be calculated. ' +
error.message;
}
}
}).addTo(map);
我相信在你的控制下你可以重新定义这两个选项
您也可以使用带有类leaflet-bar leaflet-routing-error的leaflet元素并在其上注入更多的html代码,就像他们创建警报一样
var L = require('leaflet');
onAdd: function() {
var header,
message;
this._element = L.DomUtil.create('div', 'leaflet-bar leaflet-routing-error');
this._element.style.visibility = 'hidden';
header = L.DomUtil.create('h3', null, this._element);
message = L.DomUtil.create('span', null, this._element);
header.innerHTML = this.options.header;
return this._element;
}
所以检索div
类或 idleaflet-routing-error
并在其上注入您想要的 html 组件模板应该没问题