- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Cesium 并希望在视觉上表示相同的两个实体之间的多条折线。例如,从实体 A 到实体 B 的绿色多段线,以及从实体 A 到实体 B 的蓝色多段线。我希望它们不要重叠或混合,所以我想象随着绘制更多的线而展开,这样每条线及其代表的内容都可以可视化。我已经包括了一张我试图用扇形展开而不是重叠来解释的粗略图。
我有一个功能性数据结构来跟踪我想要表示的线,以及已经以编程方式在其上绘制的 Cesium map 。我想此时我正在寻找有关如何以编程方式弯曲 map 上的多段线的技术解释,以及有关多段线管理的任何建议,以便识别重叠线,以便我可以应用弯曲。
感谢您的帮助!
最佳答案
这是一种方法。此示例代码将仅沿经度“展开”线条,因此在北/南线上效果最好,而不是在东/西线上。但我认为它应该传达正确的想法,您只需要找出一种更通用的方法将中点“移动”到视觉上令人愉悦的位置。
我在这里使用基于时间的路径来访问 Cesium 的插值逻辑。但是我选择了一个很久以前的引用时间,我只是在查看器上显示完成的路径。因此,用户并不知道时间在这里扮演着任何 Angular 色。
var viewer = new Cesium.Viewer('cesiumContainer', {
navigationInstructionsInitiallyVisible: false,
animation: false,
timeline: false,
// These next 5 lines are just to avoid the Bing Key error message.
imageryProvider : Cesium.createTileMapServiceImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
}),
baseLayerPicker : false,
geocoder : false,
// This next line fixes another Stack Snippet error, you may omit
// this setting from production code as well.
infoBox : false
});
var numberOfArcs = 5;
var startLon = -105;
var startLat = 39.7;
var stopLon = -98.4;
var stopLat = 29.4;
var spread = 5;
var referenceTime = Cesium.JulianDate.fromIso8601('2001-01-01T00:00:00Z');
var midTime = Cesium.JulianDate.addSeconds(referenceTime, 43200, new Cesium.JulianDate());
var stopTime = Cesium.JulianDate.addSeconds(referenceTime, 86400, new Cesium.JulianDate());
for (var i = 0; i < numberOfArcs; ++i) {
var color = Cesium.Color.fromRandom({
alpha : 1.0
});
// Create a straight-line path.
var property = new Cesium.SampledPositionProperty();
var startPosition = Cesium.Cartesian3.fromDegrees(startLon, startLat, 0);
property.addSample(referenceTime, startPosition);
var stopPosition = Cesium.Cartesian3.fromDegrees(stopLon, stopLat, 0);
property.addSample(stopTime, stopPosition);
// Find the midpoint of the straight path, and move it.
var spreadAmount = (spread / (numberOfArcs - 1)) * i - (spread / 2);
var midPoint = Cesium.Cartographic.fromCartesian(property.getValue(midTime));
midPoint.longitude += Cesium.Math.toRadians(spreadAmount);
var midPosition = viewer.scene.globe.ellipsoid.cartographicToCartesian(
midPoint, new Cesium.Cartesian3());
// Redo the path to be the new arc.
property = new Cesium.SampledPositionProperty();
property.addSample(referenceTime, startPosition);
property.addSample(midTime, midPosition);
property.addSample(stopTime, stopPosition);
// Create an Entity to show the arc.
var arcEntity = viewer.entities.add({
position : property,
// This path shows the arc as a polyline.
path : {
resolution : 1200,
material : new Cesium.PolylineGlowMaterialProperty({
glowPower : 0.16,
color : color
}),
width : 10,
leadTime: 1e11,
trailTime: 1e11
}
});
// This is where it becomes a smooth path.
arcEntity.position.setInterpolationOptions({
interpolationDegree : 5,
interpolationAlgorithm : Cesium.LagrangePolynomialApproximation
});
}
// Optionally, add start and stop points, mostly for easy zoomTo().
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(startLon, startLat),
point : {
pixelSize : 8,
color : Cesium.Color.WHITE
}
});
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(stopLon, stopLat),
point : {
pixelSize : 8,
color : Cesium.Color.WHITE
}
});
viewer.zoomTo(viewer.entities);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
font-family: sans-serif;
}
<link href="http://cesiumjs.org/releases/1.30/Build/Cesium/Widgets/widgets.css"
rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.30/Build/Cesium/Cesium.js">
</script>
<div id="cesiumContainer"></div>
关于javascript - 铯 : "fan out" overlapping polylines?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42237055/
我正在尝试比较由 Google Directions API 生成的 Polyline - overview_polyline使用一组已经存在的多段线,并查看新多段线的哪一部分已包含在其中一条多段线中
如何在单击折线事件的两个现有点之间的折线上添加点? 谢谢! 最佳答案 如果您只是在谈论 Polyline只有 2 个点,您可以使用 LatLngBounds 的中心包含 Polyline . Goog
我尝试使用 folium 根据速度(如 Strava 等应用程序)使用不同颜色的比赛路径。 我看到您可以根据数据更改标记的颜色,但我无法使用 PolyLines 将其转置。 这是我的可视化的代码: p
有人可以告诉我这段代码有什么问题吗? Cesium.Math.setRandomNumberSeed(1234); var viewer = new Cesium.Viewer('ce
这里! 有一个关于我们需要实现的功能的查询,它是将多种颜色传递到折线上的航路点 0 到 1,但我们卡在了 H.geo.Polyline 上,只能应用一种样式: polyline = new H.map
阅读@Akexorcist 在 Get driving directions using Google Maps API v2 上的回答后,我实现了他们的解决方案,以使用多段线绘制从调用 maps.g
我目前有一张 map ,每 10 米我使用 LocationListener 刷新我的位置并获取新的纬度和经度。现在我希望用户所走的路线用红线显示。因此,每次调用 LocationListener 类
似乎标题是不言而喻的,但要详细说明,这是我遇到的问题,我在 map 上显示了多条折线,现在我打算做的是,当我将鼠标悬停在上面时列表中的某个折线,只有该折线会突出显示(或更改颜色)。我现在所拥有的是这样
我们正在使用谷歌的折线解码算法来解码我们的坐标。但在我们的例子中,大多数坐标在解码后都是错误的。我们还以更深的精度测试了该过程。 这是我们的代码,也是我们用来测试坐标错误的日志: let coordi
是否可以通过客户端使用带有编码折线的 Google Elevation API? 我知道有 https://maps.googleapis.com/maps/api/elevation/json?ke
我正在使用 google maps API V3 并在折线上创建了一些图标动画。 我的代码 var line; function initialize() { var mapOptions =
我有一个 List我需要在第二个线程中生成,以免失去 GUI 响应能力。线程完成后,我需要访问 List在 GUI 线程中显示。这是我遇到问题的地方。我正在使用匿名方法调用 UI 线程上的复制逻辑,将
我在 map 上有很多长折线。我想优化他们的绘图,因为在几千个点上,折线的绘制速度非常慢。 我的 drawMapRect 看起来像这样: - for each polyline segment - v
我无法使用传单和折线进行串扰 - 这是一个 MWE: library(crosstalk) library(leaflet) theta % addTiles() %>% addCircleM
我无法使用传单和折线进行串扰 - 这是一个 MWE: library(crosstalk) library(leaflet) theta % addTiles() %>% addCircleM
我有一个用折线对象动态制作的图形。它产生了一些有趣的东西,但我只想保留最后 10 个坐标,一旦我们到达第 10 个位置,每个坐标都会向左移动 X 像素,新值将添加到最后。 在我的绘图类的 Add 函数
我尝试显示带有地址而不是经纬度的 google.maps.Polyline。 我现在的代码是: var flightPlanCoordinates = [ new google.maps.La
我正在使用 Cesium 并希望在视觉上表示相同的两个实体之间的多条折线。例如,从实体 A 到实体 B 的绿色多段线,以及从实体 A 到实体 B 的蓝色多段线。我希望它们不要重叠或混合,所以我想象随着
我使用 Google Maps Api 有一段时间了,最近我检查了有没有新东西:绘图管理器。从两天前开始我就在玩这个,现在我想知道一些事情。我正在寻找编辑多段线时触发的事件。 有一个 polyli
当我点击折线时,我希望时间(自定义对象)显示在那个特定经纬度位置。 实现折线的代码 PolylineOptions lineOptions = new PolylineOptions().width(
我是一名优秀的程序员,十分优秀!