javascript-将强度点数组转换为标记

所以我有这段代码.

热图已经添加,但是现在我需要为每个具有强度点的地方添加标记.

我有经度和纬度,也有强度.

我也想使用该标记显示数据.

我有此代码,无法为每个强度点添加标记并显示数据.

<html>
<head>
    <title>Leaflet HeatMap </title>
    <meta charset="utf-8" />
    <link
            rel="stylesheet"
            href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
    />
</head>
<body>
<div id="map" style="width: 1000px; height: 600px"></div>

<script
        src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js">
</script>

<script
        src="http://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js">
</script>
<script src="2013-earthquake.js"></script>
<script>

    var map = L.map('map').setView([21.7679,78.8718], 10);
    mapLink =
        '<a href="http://openstreetmap.org">OpenStreetMap</a>';
    L.tileLayer(
        'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '&copy; ' + mapLink + ' Contributors',
            maxZoom: 10,
        }).addTo(map);


    var heat = L.heatLayer(quakePoints,{
        radius: 20,
        blur: 50,
        maxZoom: 10,
    }).addTo(map);


</script>
</body>
</html>

这是我的示例数据:

var quakePoints = [
    [17.123184,79.208824,1.7345],
    [19.123184,79.208824,1.7345],
    [-41.7349,174.013,2.5696],
    [-41.99,174.1059,2.006],
    [-41.6164,174.1405,1.9665],
    [-41.7005,174.0838,2.3406],
    [-40.3361,174.9797,2.9515],
    [-41.7147,174.1782,3.0804],
    [-41.7154,174.0453,1.8717],
    [-41.623,174.1742,2.2847],
];

解决方法:

添加多个标记的一种简单方法:

for (var i = 0; i < quakePoints.length; i++) {
        marker = new L.marker(quakePoints[i])
            .bindPopup(quakepoints[i][2])
            .addTo(map);
    }
上一篇:javascript-根据需要在点击时填写传单弹出窗口


下一篇:javascript – Leaflet .addLayer()函数失败,在控制台工作