Leaflet 自定义传单传送错误(选项)

Leaflet 自定义传单传送错误(选项),leaflet,leaflet-routing-machine,Leaflet,Leaflet Routing Machine,我在用传单传送机 我将错误控制添加到地图中,如下所示: L.Routing.errorControl(this.control).addTo(map) 对于我使用的样式: .leaflet-routing-error { width: 320px; background-color: rgb(238, 153, 164); padding-top: 4px; transition: all 0.2s ease; box-sizing: border-box; } 这就是我得

我在用传单传送机

我将错误控制添加到地图中,如下所示:

L.Routing.errorControl(this.control).addTo(map)

对于我使用的样式:

.leaflet-routing-error {
  width: 320px;
  background-color: rgb(238, 153, 164);
  padding-top: 4px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
这就是我得到的:

我找不到很多关于这个的解释。有人知道如何定制更多,改变语言,隐藏/显示

读了这篇文章之后 您可以重新定义标题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);
因此,检索类或id的
div
传单路由错误
并在其上注入所需的html组件模板应该可以

        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;
        }