1
A
回答
1
是的,有一些注意事项:首先,铯实体本身没有颜色。它可以有一个点,并且点可以具有color
和outlineColor
,它也可具有一个标签与自己的颜色(一个或多个)等
接着,铯性质都能够进行时间动态或不变。因此,当您“获得”实体属性(如点颜色)时,您通常应通过viewer.clock.currentTime
以在特定时间获取该物业。如果您确定知道您获得的财产是ConstantProperty而不是SampledProperty或TimeIntervalCollectionProperty,则无关紧要。
对于下面的演示,我为所有颜色和属性隐式使用了ConstantProperty。我还压制了“SelectionIndicator”(当你点击一个实体时通常出现的绿色框),因为这种情况看起来很奇怪。
我正在使用selectedEntityChanged
事件来指示点应该从蓝色变为红色还是回来。本月(2017年3月)发布的Cesium 1.31中新增了selectedEntityChanged
事件。如果您的版本较旧且无法升级,则可以根据需要发布旧版本的解决方法。
var viewer = new Cesium.Viewer('cesiumContainer', {
// Turn off nav help and stuff we're not using.
navigationInstructionsInitiallyVisible: false, animation: false, timeline: false,
// Optionally, you can turn off the green selection box, like this:
selectionIndicator : false,
// These next 6 lines are just to avoid Stack Snippet error messages.
imageryProvider : Cesium.createTileMapServiceImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
}),
baseLayerPicker : false,
geocoder : false,
infoBox : false
});
var dots = [
{ lon: -75, lat: 40 },
{ lon: -95, lat: 40 },
{ lon: -115, lat: 40 },
{ lon: -75, lat: 30 },
{ lon: -95, lat: 30 },
{ lon: -115, lat: 30 },
{ lon: -85, lat: 20 },
{ lon: -105, lat: 20 }
];
dots.forEach(function(dot) {
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(dot.lon, dot.lat),
point : {
pixelSize : 7,
color : Cesium.Color.STEELBLUE,
outlineColor : Cesium.Color.BLACK,
outlineWidth : 1.0
}
});
});
viewer.selectedEntityChanged.addEventListener(function(entity) {
// Check if an entity with a point color was selected.
if (Cesium.defined(entity) &&
Cesium.defined(entity.point) &&
Cesium.defined(entity.point.color)) {
// Get the current color
var color = entity.point.color.getValue(viewer.clock.currentTime);
// Test for blue
if (Cesium.Color.equals(color, Cesium.Color.STEELBLUE)) {
// Set to red
entity.point.color = Cesium.Color.RED;
}
// Test for red
else if (Cesium.Color.equals(color, Cesium.Color.RED)) {
// Set to red
entity.point.color = Cesium.Color.STEELBLUE;
}
}
});
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
font-family: sans-serif;
}
#message {
position: absolute;
top: 4px; left: 5px; color: #edffff;
}
<link href="http://cesiumjs.org/releases/1.31/Build/Cesium/Widgets/widgets.css"
rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.31/Build/Cesium/Cesium.js">
</script>
<div id="cesiumContainer"></div>
<div id="message">Single-click a dot to change its color.</div>
相关问题
- 1. 从图像中获取和比较物体的颜色
- 2. 获取未进行比较
- 3. Android颜色挑选不正确颜色
- 4. 比较颜色对比以选择最终颜色
- 5. 颜色亮度的比较
- 6. 获取图片的平均颜色和使用java比较图片颜色
- 7. 挑选颜色更是从白色
- 8. 实体框架在内存实体中与保存的实体进行比较
- 9. Excel VBA - 按颜色比较行时的改进时间
- 10. QFontDialog:获取字体颜色
- 11. 如何从选取器中获取值(或索引)并将其与实体的属性值进行比较?
- 12. Python PIL比较颜色
- 13. 比较画笔和颜色
- 14. 比较颜色与容忍
- 15. 比较Winform按钮颜色
- 16. Python,RGB颜色比较
- 17. 比较L * A * B *颜色
- 18. 使用matlab对两幅图像进行颜色比较
- 19. AS3:从对象中挑选颜色
- 20. 用JComboBox Java Swing挑选颜色
- 21. SDL2.0纹理颜色变为挑选
- 22. C++,directx 12:颜色挑选问题
- 23. 从数组中挑选两种颜色
- 24. 从弯曲线挑选颜色
- 25. 挑选两种颜色,并在
- 26. 图像颜色挑选脚本
- 27. 挑选颜色通过Interface Builder中
- 28. 如何挑选颜色UIBarButtonItem tintColor
- 29. android java从ImageView中挑选颜色
- 30. 从数组中挑选随机颜色