0
我'上mapbox porjekt和使用JavaScript,我讀出了KML文件,並添加自定義圖標,它的工作原理,但我得到這個錯誤在瀏覽器控制檯:mapbox JavaScript的自定義圖標
Uncaught TypeError: undefined is not a function mytilemillscript.js:565
(anonymous function) mytilemillscript.js:565
s.LayerGroup.s.Class.extend.eachLayer mapbox.js:2
(anonymous function) mytilemillscript.js:564
s.Mixin.Events.fireEvent mapbox.js:1
t leaflet-omnivore.min.js:1
o
這裏的js代碼:
var greenIcon = L.icon({
iconUrl: 'icon/bergbahn_pitztalgletscher.svg',
iconSize: [38, 95], // size of the icon
iconAnchor: [22, 94],
popupAnchor: [-3, -76],
shadowAnchor: [22, 94]
});
runLayer = omnivore.kml('data/InntalradwegImst-SilzRundeTour14-02.kml').on('ready', function() {
runLayer.eachLayer(function(marker) {
marker.setIcon(greenIcon);
});
}) .addTo(map);
此行導致錯誤:
marker.setIcon(greenIcon);
爲什麼是錯誤messag è? 謝謝!
什麼是565? – durrrutti
對不起,它的那一行marker.setIcon(greenIcon); – miholzi
您的KML的外觀如何? – geocodezip