在geodjango上运行传单时出现路由错误

时间:2018-07-29 05:11:24

标签: javascript leaflet geodjango

我正在关注geodjango的教程。我使用从Leaflet下载的leaflet-routing-machine.js来实现路由功能。但是我在运行系统时遇到此错误。

  

{状态:-3,消息:“ TypeError:无法读取未定义的属性'appendChild'”}

错误的详细信息如下:

defaultErrorHandler @ leaflet-routing-machine.js:493
fire @ leaflet.js:5
(anonymous) @ leaflet-routing-machine.js:788
(anonymous) @ leaflet-routing-machine.js:2415
loaded @ leaflet-routing-machine.js:51
XMLHttpRequest.send (async)
corslite @ leaflet-routing-machine.js:93
route @ leaflet-routing-machine.js:2388
route @ leaflet-routing-machine.js:773
initialize @ leaflet-routing-machine.js:516
e @ leaflet.js:5
L.Routing.control @ leaflet-routing-machine.js:821
our_layers @ (index):116
L.Map.djangoMap @ leaflet.extras.js:234
loadmap @ (index):148

javascript代码:

var routing = L.Routing.control({
              waypoints: [
                  L.latLng(-0.23, 36.87),
                  L.latLng(0.23, 37.64)
              ]
          });
          L.easyButton('fa-compass',
              function () {
                  $('.leaflet-routing-container').is(':visible') ? routing.removeFrom(map) : routing.addTo(map)
              },
              'Routing'
          ).addTo(map);

          function createButton(label, container) {
            var btn = L.DomUtil.create('button', '', container);
            btn.setAttribute('type', 'button');
            btn.innerHTML = label;
            return btn;
          }

html代码:

<script type="text/javascript" src="{% static 'routing/leaflet-routing-machine.js' %}"></script>

0 个答案:

没有答案