Reputation: 485
I'm creating x markers on map in leaflet. (Generating via php script, but it shouldn't be important) Problem is, that I generate new image every 60 seconds, but icons on web maps are not updating.
I want to update icons every X seconds - not important again. I couldn't find any methods to update icons. So I tried removing markers and them recreating them, but wasn't successful too - marker is not defined. Is there any way how to do it?
Edited code:
var icon = L.Icon.extend({
options: {
iconSize: [35, 35]
}
});
function createIcons() {
//Icons_start
kopanky = new icon({iconUrl: 'img/kopanky.png'});
kopankyM.setIcon(kopanky);
kopankyM.update();
}
function testCreate() {
kopanky = new icon({iconUrl: 'img/hvezdarna.png'});
kopankyM.setIcon(kopanky);
kopankyM.update();
console.log("test");
}
function createMarkers() {
//Markers_start
kopankyM = L.marker([48.9585,17.791666666667]).bindPopup("Kopanky Bile Karpaty").bindLabel('9 kt, 145°', { noHide: true }).addTo(map);
}
createMarkers();
createIcons();
setInterval(function(){
testCreate();
}, 5000);
I can't refresh via meta-tag, because when I do it, I lost user's current map settings.
Upvotes: 4
Views: 11749