Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.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 更新标记位置json传单和WebGLEarth_Javascript_Json_Leaflet_Cesium - Fatal编程技术网

Javascript 更新标记位置json传单和WebGLEarth

Javascript 更新标记位置json传单和WebGLEarth,javascript,json,leaflet,cesium,Javascript,Json,Leaflet,Cesium,此问题与此问题相关:。只有我想用WebGLEarth将用传单创建的地图投影到3D地球仪上。通常,您可以通过在原始传单代码中用WE.map、WE.marker替换L.map、L.marker等,将传单和WebGLEarth组合起来 我想将国际空间站的当前位置投影到我的3D地球仪上,所以我在代码的更新位置功能中替换了L.标记 var cloudmadeUrl = 'http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg'; v

此问题与此问题相关:。只有我想用WebGLEarth将用传单创建的地图投影到3D地球仪上。通常,您可以通过在原始传单代码中用WE.map、WE.marker替换L.map、L.marker等,将传单和WebGLEarth组合起来

我想将国际空间站的当前位置投影到我的3D地球仪上,所以我在代码的更新位置功能中替换了L.标记

var cloudmadeUrl = 'http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg';
            var subDomains = ['otile1','otile2','otile3','otile4'];
            var cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 11,     subdomains: subDomains});

            var map = new L.Map('map', {layers : [cloudmade]}).fitWorld();

var iss;

function update_position() {
$.getJSON('http://open-notify-api.herokuapp.com/iss-now.json?callback=?', function(data) {
    console.log(data);
    var latitude = data["iss_position"]["latitude"];
    var longitude = data["iss_position"]["longitude"];
    if (!iss) {
        iss = L.marker([latitude,longitude]).bindPopup("I am the ISS").addTo(map);
        }
    iss.setLatLng([latitude,longitude]).update();
    setTimeout(update_position, 1000);
    });
   }

update_position();

…由我们,马克。不幸的是,位置的更新在我的3D地球仪上不再起作用,而在2D地图上起作用了。 我试着加上

setInterval(update_position,2000);
就在更新位置()的上方;,然后标记更新了几次(~5次),然后突然停止。如果我在地球上通过平移与鼠标交互,标记将更新到其当前位置,并在之后更新几次,最终再次停止

主要问题: 是否有人知道如何修复此问题,以便我进行连续的标记更新

补充问题: 理想情况下,我希望国际空间站轨道看起来像一条彩色的轨道,空间站在其最后一次环绕地球的轨道上运行。有什么建议吗

提前谢谢

[编辑日期23-1-2015: 我设法通过为iis创建一个新变量(即iis2)来不断更新它。我不清楚为什么这样做。不幸的是,所有“旧”标记位置都没有消失,所以我得到了一个模糊的标记轨迹

    var iss;
var iis2;

function update_position() {
    $.getJSON('http://open-notify-api.herokuapp.com/iss-now.json?callback=?', function(data) {
        console.log(data);
        var latitude = data["iss_position"]["latitude"];
        var longitude = data["iss_position"]["longitude"];
        if (!iss) {
            iss2 = WE.marker([latitude,longitude]).bindPopup("I am the ISS").addTo(map);
        }
        iss2.setLatLng([latitude,longitude]).update();
    });
}
update_position();
setInterval(update_position,1000);
]取下标记

var iss;
var iis2;

function update_position() {
    $.getJSON('http://open-notify-api.herokuapp.com/iss-now.json?callback=?', function(data) {
        console.log(data);
        map.removeLayer(iss2);
        var latitude = data["iss_position"]["latitude"];
        var longitude = data["iss_position"]["longitude"];
        if (!iss) {
            iss2 = WE.marker([latitude,longitude]).bindPopup("I am the ISS").addTo(map);
        }
        iss2.setLatLng([latitude,longitude]).update();
    });
}
update_position();
setInterval(update_position,1000);

试图简化:map.removeLayer(玩家[player].marker);players[player].marker=WE.marker(newLatLng).bindpoop(player).addTo(map);get:player.js:37未捕获类型错误:map.removeLayer不是函数s2.removeFrom(map);