最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Issue adding Leaflet Navigation plugin - Stack Overflow

programmeradmin1浏览0评论

I am a novice when it comes to any kind of coding and am trying to learn some basic web mapping. I have a created a map using Leaflet and am trying to add the Navigation plugin. I have been following the tutorial at GIS Solutions "Leaflet Navigation". I am working in Visual Studio Code and when I run it, I get an error " Uncaught TypeError TypeError: L.control.navbar is not a function...

I am not sure where I am going wrong. I am using a more recent version of Leaflet than the tutorial, but it still didn't work then I used the older version. I double checked where I stored the file I downloaded from GitHub. I feel like I might have missed a set up step as I have tried two other plugins with no luck.

I've looked at How to install a Leaflet Plugin, but got more confused.

Here is the code. Thanks.

<!DOCTYPE html>

<html>
  <head>
    <!--title-->
    <title>St. Andrews United Loyalist Church</title>

    <!--Link to Leaflet CSS document-->
    <link rel="stylesheet" href="/[email protected]/dist/leaflet.css" />
    <!--Link to Leaflet Navigation plugin -->
    <link rel="stylesheet" href="src\Leaflet.NavBar.css" />

    <!--Link to Leaflet JS API-->
    <script src="/[email protected]/dist/leaflet.js"></script>
    <script src="src\Leaflet.NavBar.js"></script>   

    <!--Styling document elements, declaring the map to fill the entire page-->
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #mapid { width: 100%; height: 100%}
    </style>
  </head>

  <body>
   
    <!--Declare map div container to place the map inside on the page-->
    <div id="mapid"></div>

    <!--Javascript map functions-->
    <script>
      
      var map = L.map('mapid').setView([45.180864, -74.452271], 18);
    
      // This example uses custom tiles taken from /
      L.tileLayer('/{z}/{y}/{x}', {
        attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
      }).addTo(map);

      L.control.navbar().addTo(map);
      


      </script>
  </body>
</html>
发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>