我用的是传单v1.5.1。Chrome的错误是:
leaflet.js:5 Uncaught : this.callInitHooks不是Object.i as Marker的map1Rose2.php:77上的函数
下面是在Chrome中复制问题的最低限度代码。我看不出这个功能有什么问题。中的第一个'var‘(第77行)出现错误。我已经把这东西戳得精疲力竭了,有人有主意吗?
<!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>
发布于 2020-04-30 06:05:29
你必须打电话给new L.Marker()
或L.marker()
要修复第二个错误(在注释中),您必须首先定义featureGroup,然后创建标记。
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();
而且,您不会在地图上看到任何东西,因为您没有将您的功能组添加到地图中。你需要一个地图实例。
var map = L.map('map', {
...
});
fg.addTo(map);
https://stackoverflow.com/questions/61512240
复制相似问题