【发布时间】:2020-05-07 02:27:13
【问题描述】:
我有一个这样定义的传单标记:
var W0KCN3 = new L.marker(new L.LatLng(39.2859182,-94.667236),{
opacity: 0.5,
contextmenu: true,
contextmenuWidth: 140,
contextmenuItems: [{ text: 'Click here to add mileage circles',
callback: circleKoords}],
icon: firstaidicon,
title:`marker_1 ` }).addTo(fg).bindPopup(`1<br>Northland ARES Platte Co. Resource Center<br>Kansas City, MO<br><br>39.2859182, -94.667236<br>EM29PG`).openPopup();
我有一个这样定义的图标:
// Define a PoiIcon class
var PoiIcon = L.Icon.extend({
options: {
iconSize: [32, 37]
}
});
// Create five icons from the above PoiIcon class
var firstaidicon = new PoiIcon({iconUrl: 'images/markers/firstaid.png'}),
eocicon = new PoiIcon({iconUrl: 'images/markers/eoc.png'}),
policeicon = new PoiIcon({iconUrl: 'images/markers/police.png'}),
skywarnicon = new PoiIcon({iconUrl: 'images/markers/skywarn.png'}),
repeatericon = new PoiIcon({iconUrl: 'markers/repeater.png'});
我想在标记定义中使用 firstaidicon,但我很难让它发挥作用。 我试过了:
icon: firstaidicon,
但现在我明白了;
Uncaught TypeError: Cannot read property 'createIcon' of undefined
来自 Leaflet.js:5 中的各种位置 我做错了什么?
【问题讨论】:
标签: leaflet