将强度点数组转换为标记 [英] Convert array of intensity points to Markers

查看:67
本文介绍了将强度点数组转换为标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个代码。

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

Heat map has already been added but now I need to add the markers for each of the place that has intensity point.

我有纬度和经度以及强度。

I have the latitude and longitude and also intensity.

我还想用这个标记显示数据。

I also want to show the data using that marker.

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

I have this code and I am unable to add marker for each intensity point and display the data.

<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],
];


推荐答案

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

A straightforward way of adding multiple markers:

for (var i = 0; i < quakePoints.length; i++) {
        marker = new L.marker(quakePoints[i])
            .bindPopup(quakepoints[i][2])
            .addTo(map);
    }

这篇关于将强度点数组转换为标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆