简体   繁体   English

小册子:未被捕获的TypeError:尝试使用群集插件时L.markerClusterGroup不是函数

[英]Leaflet: Uncaught TypeError: L.markerClusterGroup is not a function when trying to use Cluster plug-in

I am trying to use Cluster Group plug-in for Leaflet, but I keep getting the "Uncaught TypeError: L.markerClusterGroup is not a function" 我正在尝试为Leaflet使用群集组插件,但是我一直收到“ Uncaught TypeError:L.markerClusterGroup不是函数”

here is my simplified HTML file: 这是我的简化HTML文件:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Brewser</title>
        <link rel="stylesheet" type="text/css" href="brewser.css">
        <link rel="stylesheet" type="text/css" href="leaflet.css"/>
        <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i,900,900i" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="dist/MarkerCluster.css"/>
        <link rel="stylesheet" type="text/css" href="dist/MarkerCluster.Default.css"/>      
    </head>
    <body>
        <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase.js"></script>
        <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-app.js"></script>
        <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-database.js"></script>   
        <script src="leaflet.js" type="text/javascript"></script>
        <script src="app.js" type="text/javascript"></script>
        <script src="brewser.js" type="text/javascript"></script>
        <script src="dist/leaflet.markercluster-src.js"></script>
    </body>
</html>

Here is my JS: 这是我的JS:

var myMap = L.map('map').setView([49.197060, 16.611837], 13);
var markers = L.markerClusterGroup();

Any idea what could be wrong? 知道有什么问题吗?

plug-in files I am using are those in dist directory: 我正在使用的插件文件是dist目录中的文件:

leaflet.markercluster-src.js
leaflet.markercluster.js
leaflet.markercluster-src.js.map
leaflet.markercluster.js.map
MarkerCluster.css
MarkerCluster.Default.css

Your imports are out of order: 您的进口货已损坏:

    <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-database.js"></script>   
    <script src="leaflet.js" type="text/javascript"></script>
    <script src="app.js" type="text/javascript"></script>
    <script src="brewser.js" type="text/javascript"></script>
    <script src="dist/leaflet.markercluster-src.js"></script>

should be: 应该:

    <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/4.9.0/firebase-database.js"></script>   
    <script src="leaflet.js" type="text/javascript"></script>
    <!-- Notice where markercluster import is above app.js -->
    <script src="dist/leaflet.markercluster-src.js"></script>
    <script src="app.js" type="text/javascript"></script>
    <script src="brewser.js" type="text/javascript"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 传单:未捕获的类型错误:L.markerClusterGroup 不是函数 - Leaflet: Uncaught TypeError: L.markerClusterGroup is not a function 未捕获的类型错误:L.minichart 不是 function(传单饼图) - Uncaught TypeError: L.minichart is not a function (Leaflet Piechart) 如何使用传单markerclusterGroup? - How to use leaflet markerclusterGroup? Leaflet 控件搜索错误:未捕获类型错误:L.Control.geocoder 不是 function - Leaflet Control Search Error: Uncaught TypeError: L.Control.geocoder is not a function 尝试使用.split()时JS中未捕获到TypeError - Uncaught TypeError in JS when trying to use .split() 未捕获的类型错误:L.GeometryField 不是构造函数 django-leaflet - Uncaught TypeError: L.GeometryField is not a constructor django-leaflet React-Leaflet:未捕获的TypeError:pointToLayer不是一个函数 - React-Leaflet: Uncaught TypeError: pointToLayer is not a function 传单:未捕获的TypeError:map._getNewTopLeftPoint不是函数 - Leaflet: Uncaught TypeError: map._getNewTopLeftPoint is not a function 传单未捕获的类型错误:map.addLayer 不是函数 - leaflet Uncaught TypeError: map.addLayer is not a function 尝试使用语义 ui 时,我不断收到此错误 Uncaught TypeError: $(...).modal is not a function - When trying to use semantic ui I keep getting this error Uncaught TypeError: $(...).modal is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM