首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >传单错误: this.callInitHooks不是函数错误吗?

传单错误: this.callInitHooks不是函数错误吗?
EN

Stack Overflow用户
提问于 2020-04-29 21:43:30
回答 1查看 4.4K关注 0票数 3

我用的是传单v1.5.1。Chrome的错误是:

leaflet.js:5 Uncaught : this.callInitHooks不是Object.i as Marker的map1Rose2.php:77上的函数

下面是在Chrome中复制问题的最低限度代码。我看不出这个功能有什么问题。中的第一个'var‘(第77行)出现错误。我已经把这东西戳得精疲力竭了,有人有主意吗?

代码语言:javascript
运行
复制
<!DOCTYPE html>

<html lang="en">
<head>

    <title>NCM Map of Station Locations</title>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" type="image/x-icon" href="images/favicon-32x32.png" >

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 

    <!-- ******************************** Load LEAFLET from CDN *********************************** -->
   <link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"
  integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
  crossorigin=""/>
  <script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"
  integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
  crossorigin=""></script>
     <!-- ********************************* End Load LEAFLET **************************************** -->

     <!-- ******************************** Load ESRI LEAFLET from CDN ******************************* -->
     <script src="https://unpkg.com/esri-leaflet@2.2.4/dist/esri-leaflet.js"
    integrity="sha512-tyPum7h2h36X52O2gz+Pe8z/3l+Y9S1yEUscbVs5r5aEY5dFmP1WWRY/WLLElnFHa+k1JBQZSCDGwEAnm2IxAQ=="
    crossorigin=""></script>

    <!-- Load Esri Leaflet Geocoder from CDN -->
    <link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@2.2.14/dist/esri-leaflet-geocoder.css"
    integrity="sha512-v5YmWLm8KqAAmg5808pETiccEohtt8rPVMGQ1jA6jqkWVydV5Cuz3nJ9fQ7ittSxvuqsvI9RSGfVoKPaAJZ/AQ=="
    crossorigin="">
    <script src="https://unpkg.com/esri-leaflet-geocoder@2.2.14/dist/esri-leaflet-geocoder.js"
    integrity="sha512-uK5jVwR81KVTGe8KpJa1QIN4n60TsSV8+DPbL5wWlYQvb0/nYNgSOg9dZG6ViQhwx/gaMszuWllTemL+K+IXjg=="
    crossorigin=""></script>   

    <!-- ******************************** End ESRI LEAFLET ***************************************** -->

     <!-- ******************************** Added Functionality *************************************** -->
    <link rel="stylesheet" href="css/leaflet_numbered_markers.css" />
    <link rel="stylesheet" href="css/L.Grid.css" />   
    <link rel="stylesheet" href="css/L.Control.MousePosition.css" />
    <link rel="stylesheet" href="css/control.w3w.css" />

    <link rel="stylesheet" href="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.css" />
    <link rel="stylesheet" type="text/css" href="css/maps.css">

    <link rel="stylesheet" type="text/css" href="css/leaflet/leaflet.contextmenu.min.css">

    <script src="js/leaflet_numbered_markers.js"></script>
    <script src="js/L.Grid.js"></script>   <!-- https://github.com/jieter/Leaflet.Grid -->
    <script src="js/L.Control.MousePosition.js"></script>  <!-- https://github.com/ardhi/Leaflet.MousePosition -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/OverlappingMarkerSpiderfier-Leaflet/0.2.6/oms.min.js"></script>
    <script src="js/control.w3w.js"></script>
    <script src="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.js"></script>

    <script src="js/leaflet/leaflet.contextmenu.min.js"></script>

    <script src="https://unpkg.com/leaflet.maidenhead@1.0.0/src/maidenhead.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/leaflet-geometryutil@0.9.1/src/leaflet.geometryutil.min.js"></script>

    <!-- https://github.com/Turfjs/turf -->
    <script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>

    <style>
    </style>

</head>
<body>

<!-- the map div holds the map -->
<div id="map"></div>

<script>
    var WA0TJT = L.Marker(new L.LatLng(39.202911,-94.602887),{
        contextmenu: true,
        contextmenuWidth: 140,
        contextmenuItems: [{ text: 'Click here to add mileage circles', callback: circleKoords}],               
        icon: new L.NumberedDivIcon({number: '1' }),
        title:"marker_1" }).addTo(fg).bindPopup("1<br><b>ID: #0013</b><br>WA0TJT<br>Keith Kaiser<br>Platte  Co., MO Dist: A<br>39.202911, -94.602887<br>EM29QE").openPopup();

    var KA0OTL = L.Marker(new L.LatLng(39.233702,-94.635126),{
        contextmenu: true,
        contextmenuWidth: 140,
        contextmenuItems: [{ text: 'Click here to add mileage circles', callback: circleKoords}],               
        icon: new L.NumberedGreenDivIcon({number: '2' }),
        title:"marker_2" }).addTo(fg).bindPopup("2<br><b>ID: #0025</b><br>KA0OTL<br>Jeff Libby<br>Platte  Co., MO Dist: A<br>39.233702, -94.635126<br>EM29qf").openPopup();

/*              
var map = L.map('map', {
    center: [39.73, -104.99],
    zoom: 10,
    layers: [base, pois]
});
*/

var fg = new L.featureGroup();

function circleKoords(e) { };

</script>

</body>
</html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-30 06:05:29

你必须打电话给new L.Marker()L.marker()

要修复第二个错误(在注释中),您必须首先定义featureGroup,然后创建标记。

代码语言:javascript
运行
复制
var fg = new L.featureGroup();

var WA0TJT = L.Marker(new L.LatLng(39.202911,-94.602887),{
        contextmenu: true,
        contextmenuWidth: 140,
        contextmenuItems: [{ text: 'Click here to add mileage circles', callback: circleKoords}],               
        icon: new L.NumberedDivIcon({number: '1' }),
        title:"marker_1" }).addTo(fg).bindPopup("1<br><b>ID: #0013</b><br>WA0TJT<br>Keith Kaiser<br>Platte  Co., MO Dist: A<br>39.202911, -94.602887<br>EM29QE").openPopup();

而且,您不会在地图上看到任何东西,因为您没有将您的功能组添加到地图中。你需要一个地图实例。

代码语言:javascript
运行
复制
var map = L.map('map', {
...
});
fg.addTo(map);
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61512240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档