I have a marker on my map representing the current location of the International Space Station (pulled from http://open-notify-api.herokuapp.com/iss-now.json?callback=?). I'm also trying to get it to move every 1 second to follow along with the station's orbit.
This is the code I have now:
$.getJSON('http://open-notify-api.herokuapp.com/iss-now.json?callback=?', function(data) {
var latitude = data["data"]["iss_position"]["latitude"];
var longitude = data["data"]["iss_position"]["longitude"];
var iss = L.marker([latitude,longitude]).bindPopup("I am the ISS").addTo(map);
$(function() {
setInterval(function() {
iss.setLatLng([latitude,longitude]).update();
},1000);
});
});
Here's everything in a jsFiddle: http://jsfiddle.net/zmkqu/
It seems to place the marker in the correct position on load, but does not update every second as it should be. Any tips on what I'm doing wrong?
Thanks!