简体   繁体   English

你如何让标记在 leaflet map 上一段时间后消失

[英]How do you make markers disappear after a certain amount of time on leaflet map

Using this code to let users mark where they see things on leaflet map but I want the markers to disappear after an hour.使用此代码让用户标记他们在 leaflet map 上看到的东西,但我希望标记在一小时后消失。 Is there a way I can set a time limit on them?有没有办法给他们设置时间限制?

function getClickedLanLon(e) {

    var lat,
        lon,
        zoom;

    lat = e.latlng.lat;
    lon = e.latlng.lng;
    zoom = map.getZoom();

    marker2 = new L.Marker(new L.LatLng(lat, lon));
    map.addLayer(marker2);
    marker.bindPopup("Cat Spotted").addTo(map);

}

map.on('click', getClickedLanLon);

try setTimeout() built-in function in javascript.在 javascript 中尝试 setTimeout() 内置 function。

 let removeMarkerTimeOut = setTimeout({ merker.removeFrom(map) }, 3600000 )

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

相关问题 如何使画布上的圆圈在一定时间后消失? - How to make a circles in canvas disappear after a certain amount of time? 在一定时间后如何使下拉菜单消失JavaScript - How to make dropdown menu disappear after a certain amount of time JavaScript 单击一定数量后如何使按钮消失 - How do I make a button disappear after a certain amount of clicks 制作<p>使用 JS 或 JQuery 一段时间后消失</p> - Make <p> disappear after certain amount of time using JS or JQuery 如何使用不同的图像和描述向 Leaflet map 添加标记? - How do you add markers to a Leaflet map with different images and descriptions? 如何在一定量的反应后使反应消失? - How to make a reaction disappear after a certain amount of reactions? 一段时间后如何更新Google地图标记 - How to update Google map markers after a certain period of time 如何使我的 Leaflet js 地图上的每个标记在悬停并单击时运行某个功能 - how to make each of the markers on my Leaflet js map run a certain function when it is hovered and clicked on 将鼠标放在div上一定时间后,如何调用一个函数? - How do you have a function called after the mouse has been on a div for a certain amount of time? 一定数量的切换点击后,地图标记消失了 - Map markers are disappearing after a certain amount of toggle clicks
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM