问题描述
我正在使用Dennis Wilhelm的Leaflet Slider来显示Leaflet地图上数据的变化.
I am using Leaflet Slider, of Dennis Wilhelm, to show changes in data on a Leaflet map.
我正在尝试更改标记图标的更改,但没有正确完成.那么,当使用Leaflet Slider显示随时间变化时,如何更改标记图标?我必须在原始SliderControl.js中做哪些更改?
I am trying to change the change the marker icon but not getting it right. So,How can I change marker icon when use Leaflet Slider to show changes over time? What changes I have to do in the original SliderControl.js?
提前谢谢!
下面是Dennis Wilhelm的Leaflet Slider代码的链接:
Below is the link to Dennis Wilhelm's Leaflet Slider code:
https://github.com/dwilhelm89/LeafletSlider/blob/master/SliderControl.js
推荐答案
这将是对原始slidecontrol.js文件的确切更改
This will be the exact changes in the original slidercontrol.js file
if (this._layer) {
var index_temp = 0;
this._layer.eachLayer(function (layer) {
var greenIcon = L.icon({ //add this new icon
iconUrl: i+'.png',
shadowUrl: 'leaf-shadow.png',
iconSize: [38, 95], // size of the icon
shadowSize: [50, 64], // size of the shadow
iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
});
options.markers[index_temp] = layer;
options.markers[index_temp].setIcon(greenIcon); //Here set the icon to indiviual markers
++index_temp;
});
options.maxValue = index_temp - 1;
this.options = options;
}
这篇关于更改传单标记图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!