Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何清除地图上的标记_Javascript_Jquery_Leaflet_Markerclusterer - Fatal编程技术网

Javascript 如何清除地图上的标记

Javascript 如何清除地图上的标记,javascript,jquery,leaflet,markerclusterer,Javascript,Jquery,Leaflet,Markerclusterer,我正在用传单滑块制作一张地图,当滑块经过几天之后,在某一天设置的每个标记都会显示出来,到目前为止还不错,但问题是,放置的标记永远不会被移除,它们会留下,即使我再次到达同一天,它也会越过旧标记。 我已经改变了一些事情,以便它的工作。修改后的文件现在看起来像这样 L.Control.SliderControl=L.Control.extend{ 选项:{ 位置:'topright', 图层:空, timeAttribute:'时间', isEpoch:false,//时间属性是否为从历元开始经过的

我正在用传单滑块制作一张地图,当滑块经过几天之后,在某一天设置的每个标记都会显示出来,到目前为止还不错,但问题是,放置的标记永远不会被移除,它们会留下,即使我再次到达同一天,它也会越过旧标记。 我已经改变了一些事情,以便它的工作。修改后的文件现在看起来像这样

L.Control.SliderControl=L.Control.extend{ 选项:{ 位置:'topright', 图层:空, timeAttribute:'时间', isEpoch:false,//时间属性是否为从历元开始经过的秒数 startTimeIdx:0,//从何处开始查找时间字符串 timeStrLength:19,//yyyy-mm-dd的大小hh:mm:ss-如果存在毫秒,则会更大 最大值:-1, 最小值:0, showAllOnStart:false, 标记:空, 范围:false, 下面是:错, alwaysShowDate:错误, 重新缩放:空 }, 初始化:函数选项{ L.Util.setoptions此选项; this.\u layer=this.options.layer; }, extractTimestamp:functiontime,选项{ if options.isEpoch{ time=new DateparseInttime.toString;//这是本地时间 } 返回time.substroptions.startTimeIdx,options.startTimeIdx+options.timeStrLength; }, 设置位置:功能位置{ var map=此。_map; 如果映射{ map.removeControlthis; } this.options.position=位置; 如果映射{ map.addControlthis; } 这是startSlider; 归还这个; }, _updateCurrentDiv:函数startIdx,endIdx{ 此.currentStartDiv.htmlthis.options.markers[startIdx].feature.properties[this.options.timeAttribute]; 此.currentEndDiv.htmlthis.options.markers[endIdx].feature.properties[this.options.timeAttribute]; 此.$currentStartDiv=$'slider-current.start time',sliderContainer; 此.currentEndDiv=$'slider-current.end time',sliderContainer; 这是.\u updateCurrentDiv0,0; }, onAdd:函数映射{ this.options.map=map; //使用jquery ui滑块创建控件滑块容器 var sliderContainer=L.domautil.create'div','slider',this.\u容器; $sliderContainer.append'-'; //使用滑块时防止地图平移/缩放 $sliderContainer.mousedown函数{ map.draging.disable; }; $document.mouseupffunction{ map.draging.enable; //如果不在范围内,则隐藏滑块时间戳,并且选项alwaysShowDate设置为false 如果options.range | |!options.alwaysShowDate{ $'slider-timestamp'.html; } }; var options=this.options; this.options.markers=[]; //如果已提供图层:计算滑块的最小值和最大值 如果是这样的话{ var指数=0; 此._layer.eachlayer功能层{ 选项.标记[索引温度]=图层; ++指数温度; }; options.maxValue=索引温度-1; this.options=选项; }否则{ logError:您必须通过新的SliderControl{layer:your_layer}指定一个层;; } 返回滑块容器; $'slider-min',sliderContainer.htmlthis.options.markers[this.options.minValue].feature.properties[this.options.timeAttribute]; $'slider-max',sliderContainer.htmlthis.options.markers[this.options.maxValue].feature.properties[this.options.timeAttribute]; }, onRemove:函数映射{ //删除通过滑块添加的所有标记,并删除滑块div 对于i=this.options.minValue;i对于i=ui.values[0];我可以让你对你的案例进行修改吗?不是修改,但这里是站点。你不需要首先修复滑块JS中第206行出现的错误吗?map.removeLayermarkall;markall在代码中的该点未定义。