首页 > 解决方案 > 无法读取传单中折线箭头的代码中出现未定义错误的属性“箭头头”

问题描述

var somePoints = [];

for (var rowIndex in rows) {

    somePoints.push(L.latLng(rows[rowIndex].Lat, rows[rowIndex].Lon));
}

var pl = L.polyline(somePoints);

pl.addTo(map);

var decorator = L.polylineDecorator(pl, {
    patterns: [
        {offset: 0, repeat: 50, symbol: L.Symbol.arrowHead({pixelSize: 8, polygon: false, pathOptions: {stroke: true}})}
    ]
}).addTo(map);

标签: javascriptasp.netleaflet

解决方案


在您的 html 文件中,您是否导入了 polylinedecorator 脚本,

<script src="../dist/leaflet.polylineDecorator.js"></script>

就像在这里?https://github.com/bbecquet/Leaflet.PolylineDecorator/blob/96858e837a07c08e08dbba1c6751abdec9a85433/example/example.html#L17

听起来很愚蠢,但我多次为这个错误挠头。


推荐阅读