亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何讓我的線條與地球一起旋轉?

如何讓我的線條與地球一起旋轉?

慕俠2389804 2023-07-20 17:28:36
以在繪制地球儀后動態添加位置/點和紅線。(本質上,我想動態添加數據,而不是像示例那樣從一組固定的點開始)。繪制紅色虛線,但隨著地球旋轉,這些線保持在相同位置。如何讓我的線條像示例中那樣隨地球旋轉?我的小提琴: https:?//jsfiddle.net/6qhvt8aL/2/? var width = 960,? ? height = 500;? var proj = d3.geoOrthographic().scale(230).translate([width / 2, height / 2]).clipAngle(90);? var path = d3.geoPath().projection(proj).pointRadius(1.5);? var graticule = d3.geoGraticule();? var london = [-0.118667702475932, 51.5019405883275];? var time = Date.now();? var rotate = [39.666666666666664, -30];? var velocity = [.015, -0];? var lineToLondon = function(d) {? ? return path({? ? ? "type": "LineString",? ? ? "coordinates": [london, d.geometry.coordinates]? ? });? }? function stripWhitespace(str) {? ? if (!str) {? ? ? return "";? ? }? ? return str.replace(" ", "");? }? var svg = d3.select("body").append("svg").attr("width", width).attr("height", height)? svg.call(d3.drag().on("start", dragstarted).on("drag", dragged));? queue().defer(d3.json, "https://openlayers.org/en/latest/examples/data/topojson/world-110m.json").defer(d3.json, "/static/destinations.json").await(ready);? var places = {? ? "type": "FeatureCollection",? ? "features": [{? ? ? "type": "Feature",? ? ? "properties": {? ? ? ? "name": "San Francisco"? ? ? },? ? ? "geometry": {? ? ? ? "type": "Point",? ? ? ? "coordinates": [-122.417168773552248, 37.769195629687431]? ? ? }? ? }, {? ? ? "type": "Feature",? ? ? "properties": {? ? ? ? "name": "Chicago"? ? ? },? ? ? "geometry": {? ? ? ? "type": "Point",? ? ? ? "coordinates": [-87.752000832709314, 41.831936519278429]? ? ? }? ? }, {? ? ? "type": "Feature",? ? ? "properties": {? ? ? ? "name": "Los Angeles"? ? ? },? ? ? "geometry": {? ? ? ? "type": "Point",? ? ? ? "coordinates": [-118.243683, 34.052235]? ? ? }? ? }
查看完整描述

1 回答

?
臨摹微笑

TA貢獻1982條經驗 獲得超2個贊

您可以在刷新功能中更新除行之外的所有內容,您只需要更新它們即可。


您不能使用,svg.selectAll(".lines").attr("d", lineToLondon)因為您有一個包含該類的所有路徑的g類。lines相反,您可以使用:


 svg.selectAll("path.lines").attr("d", lineToLondon);

需要注意的一件事是,您的代碼中不需要這些行:


svg.selectAll(".lines").attr("d", (d) => {

  if (d) {

    return lineToLondon(d);

  }

});

這是這些更改的更新小提琴。


查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 164 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號