简体   繁体   English

有没有办法在传单中动态绘制圆形标记?

[英]Is there a way to dynamically draw circle markers in a leaflet?

At the outset, I inform you that I am a novice javascript programmer. 首先,我告诉您我是一个JavaScript新手。 I'm writing an application to dynamically draw a circle marker on a map. 我正在编写一个在地图上动态绘制圆形标记的应用程序。 I use the leaflet library. 我使用传单库。 As the source, it uses data loaded from a csv file. 作为源,它使用从csv文件加载的数据。 The csv file consists of three columns: date, x coordinate, y coordinate. csv文件由三列组成:日期,x坐标,y坐标。 At the moment the map works in such a way that it draws all markers at one time. 目前,地图的工作方式是一次绘制所有标记。

var map = L.map("map");                 
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png").addTo(map);
map.setView([51.95, 19.55], 6);

var myRenderer = L.canvas({ padding: 0.02 });
for (var j=1; j<lines.length; j++) 
{
    var values = lines[j].split(';'); // Split up the comma seperated values
    var x= values[2];
    var y = values[3];
    var data2 = values[1];      
    var markery2 = [];                  
    markery2.push(y,x);
    document.getElementById("demo").innerHTML =
    "Data: " + data2;
    console.log("JSON");
    console.log(data2);
    L.circleMarker(markery2, {
        color: 'blue',
        fillColor: 'blue',
        fillOpacity: 0.2,
        weight: 1,
        radius: 3,
        renderer: myRenderer
    }).addTo(map).bindPopup('marker ' + j);
    //Set up the data arrays
}
}       
});

Ultimately, I would like to read records from specific dates, ascending and drawn in such a order on the map with a 3-second time interval 最终,我想读取特定日期的记录,并以3秒的时间间隔在地图上以这种顺序升序绘制

Welcome to SO! 欢迎来到SO!

Look for setTimeout . 寻找setTimeout

Or it can be easier for you to begin with setInterval . 或者,您可以更轻松地从setInterval开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM