f20_primitive_ellipsoid.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="apple-touch-fullscreen" content="yes" />
  7. <meta name="apple-mobile-web-app-capable" content="yes" />
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  9. <meta name="format-detection" content="telephone=no" />
  10. <meta name="x5-fullscreen" content="true" />
  11. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  12. <!-- 标题及搜索关键字 -->
  13. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  14. <meta
  15. name="description"
  16. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  17. />
  18. <link rel="shortcut icon" type="image/x-icon" href="" />
  19. <title>Ellipsoid 球、半球、椭球 </title>
  20. <script
  21. type="text/javascript"
  22. src="../lib/include-lib.js"
  23. libpath="../lib/"
  24. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d"
  25. ></script>
  26. <link href="css/style.css" rel="stylesheet" />
  27. </head>
  28. <body class="dark">
  29. <!--加载前进行操作提示,优化用户体验-->
  30. <div id="mask" class="signmask" onclick="removeMask()"></div>
  31. <div id="mars3dContainer" class="mars3d-container"></div>
  32. <div class="infoview">
  33. <div>
  34. 图层状态:
  35. <div class="checkbox checkbox-primary checkbox-inline">
  36. <input id="chkPopup" class="styled" type="checkbox" checked />
  37. <label for="chkPopup"> Popup绑定 </label>
  38. </div>
  39. <div class="checkbox checkbox-primary checkbox-inline">
  40. <input id="chkTooltip" class="styled" type="checkbox" />
  41. <label for="chkTooltip"> Tooltip绑定 </label>
  42. </div>
  43. <div class="checkbox checkbox-primary checkbox-inline">
  44. <input id="chkContextMenu" class="styled" type="checkbox" checked />
  45. <label for="chkContextMenu"> 右键菜单绑定 </label>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 图层管理相关处理js -->
  50. <script type="text/javascript" src="./js/graphicManager.js"></script>
  51. <script src="./js/common.js"></script>
  52. <script type="text/javascript">
  53. "use script"; //开发环境建议开启严格模式
  54. var map;
  55. function initMap(options) {
  56. //合并属性参数,可覆盖config.json中的对应配置
  57. var mapOptions = mars3d.Util.merge(options, {});
  58. //创建三维地球场景
  59. map = new mars3d.Map("mars3dContainer", mapOptions);
  60. //创建Graphic图层
  61. var graphicLayer = new mars3d.layer.GraphicLayer();
  62. map.addLayer(graphicLayer);
  63. //图层管理的相关处理,代码在\js\graphicManager.js
  64. initLayerManager(graphicLayer);
  65. //加一些演示数据
  66. addGraphic_01(graphicLayer);
  67. addGraphic_02(graphicLayer);
  68. addGraphic_03(graphicLayer);
  69. addGraphic_03b(graphicLayer);
  70. addGraphic_04(graphicLayer);
  71. addGraphic_05(graphicLayer);
  72. addGraphic_06(graphicLayer);
  73. addGraphic_07(graphicLayer);
  74. addGraphic_08(graphicLayer);
  75. addGraphic_09(graphicLayer);
  76. addGraphic_10(graphicLayer);
  77. addGraphic_11(graphicLayer);
  78. addGraphic_12(graphicLayer);
  79. addGraphic_13(graphicLayer);
  80. addGraphic_14(graphicLayer);
  81. }
  82. //
  83. function addGraphic_01(graphicLayer) {
  84. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  85. position: [116.1, 31.0, 1000],
  86. style: {
  87. radii: new Cesium.Cartesian3(1000.0, 1000.0, 1500.0),
  88. color: "#00ff00",
  89. opacity: 0.5,
  90. label: { text: "鼠标移入会高亮", pixelOffsetY: -30 },
  91. //高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
  92. highlight: {
  93. opacity: 0.9,
  94. },
  95. },
  96. });
  97. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  98. //演示个性化处理graphic,代码在\js\graphicManager.js
  99. initGraphicManager(graphic);
  100. }
  101. //
  102. function addGraphic_02(graphicLayer) {
  103. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  104. position: new mars3d.LatLngPoint(116.2, 31.0, 1000),
  105. style: {
  106. radii: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0),
  107. color: Cesium.Color.RED.withAlpha(0.5),
  108. outline: true,
  109. outlineColor: "#ffffff",
  110. },
  111. });
  112. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  113. }
  114. //
  115. function addGraphic_03(graphicLayer) {
  116. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  117. position: new mars3d.LatLngPoint(116.307258, 30.999546, 1239.2),
  118. style: {
  119. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  120. maximumConeDegree: 90,
  121. material: mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.EllipsoidElectric, {
  122. color: Cesium.Color.GREEN,
  123. speed: 5.0,
  124. }),
  125. },
  126. });
  127. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  128. }
  129. function addGraphic_03b(graphicLayer) {
  130. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  131. position: new mars3d.LatLngPoint(116.303345, 31.087028, 452.2),
  132. style: {
  133. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  134. maximumConeDegree: 90,
  135. material: mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.EllipsoidWave, {
  136. color: "#00ffff",
  137. speed: 5.0,
  138. }),
  139. },
  140. });
  141. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  142. }
  143. //
  144. function addGraphic_04(graphicLayer) {
  145. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  146. position: [116.4, 31.0, 1000],
  147. style: {
  148. radii: new Cesium.Cartesian3(2500.0, 2500.0, 2500.0),
  149. innerRadii: new Cesium.Cartesian3(10.0, 10.0, 10.0),
  150. minimumClockDegree: -15.0,
  151. maximumClockDegree: 15.0,
  152. minimumConeDegree: 75.0,
  153. maximumConeDegree: 105.0,
  154. pitch: 30,
  155. color: "#f33349",
  156. opacity: 0.9,
  157. outline: true,
  158. outlineColor: "#ffffff",
  159. label: {
  160. text: "我是原始的",
  161. font_size: 18,
  162. color: "#ffffff",
  163. pixelOffsetY: -10,
  164. distanceDisplayCondition: true,
  165. distanceDisplayCondition_far: 500000,
  166. distanceDisplayCondition_near: 0,
  167. },
  168. },
  169. });
  170. graphicLayer.addGraphic(graphic);
  171. //graphic转geojson
  172. var geojson = graphic.toGeoJSON();
  173. console.log("转换后的geojson", geojson);
  174. addGeoJson(geojson, graphicLayer);
  175. }
  176. //添加单个geojson为graphic,多个直接用graphicLayer.loadGeoJSON
  177. function addGeoJson(geojson, graphicLayer) {
  178. var graphicCopy = mars3d.Util.geoJsonToGraphics(geojson)[0];
  179. delete graphicCopy.attr;
  180. //新的坐标
  181. graphicCopy.position = [116.5, 31.0, 1000];
  182. graphicCopy.style.label = graphicCopy.style.label || {};
  183. graphicCopy.style.label.text = "我是转换后生成的";
  184. graphicLayer.addGraphic(graphicCopy);
  185. }
  186. //2圈平面扇形
  187. function addGraphic_05(graphicLayer) {
  188. var outerRadius = 5000.0;
  189. var innerRadius = 1000;
  190. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  191. position: [116.1, 30.9, 1000],
  192. style: {
  193. radii: new Cesium.Cartesian3(outerRadius, outerRadius, outerRadius),
  194. innerRadii: new Cesium.Cartesian3(innerRadius, innerRadius, innerRadius),
  195. minimumClockDegree: -20.0,
  196. maximumClockDegree: 20.0,
  197. minimumConeDegree: 90,
  198. maximumConeDegree: 90,
  199. color: "rgba(255,255,0,0.2)",
  200. outline: true,
  201. outlineColor: "#ffffff",
  202. },
  203. });
  204. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  205. }
  206. //半圆顶球体
  207. function addGraphic_06(graphicLayer) {
  208. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  209. position: new mars3d.LatLngPoint(116.2, 30.9, 1000),
  210. style: {
  211. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  212. maximumConeDegree: 90,
  213. color: Cesium.Color.BLUE.withAlpha(0.3),
  214. outline: true,
  215. outlineColor: "#ffffff",
  216. },
  217. });
  218. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  219. }
  220. //含内半径 半圆顶球体
  221. function addGraphic_07(graphicLayer) {
  222. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  223. position: new mars3d.LatLngPoint(116.3, 30.9, 1000),
  224. style: {
  225. radii: new Cesium.Cartesian3(2500.0, 2000.0, 1500.0),
  226. innerRadii: new Cesium.Cartesian3(1000.0, 800.0, 600.0),
  227. maximumConeDegree: 90,
  228. color: Cesium.Color.RED.withAlpha(0.3),
  229. outline: true,
  230. outlineColor: "#ffffff",
  231. },
  232. });
  233. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  234. }
  235. //被切开的含内半径 半圆顶球体
  236. function addGraphic_08(graphicLayer) {
  237. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  238. position: new mars3d.LatLngPoint(116.4, 30.9, 1000),
  239. style: {
  240. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  241. innerRadii: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0),
  242. minimumConeDegree: 20.0,
  243. maximumConeDegree: 90,
  244. color: Cesium.Color.YELLOW.withAlpha(0.3),
  245. outline: true,
  246. outlineColor: "#ffffff",
  247. },
  248. });
  249. graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
  250. }
  251. //顶部和底部切出的桶形体
  252. function addGraphic_09(graphicLayer) {
  253. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  254. position: new mars3d.LatLngPoint(116.5, 30.9, 1000),
  255. style: {
  256. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  257. innerRadii: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0),
  258. minimumConeDegree: 60.0,
  259. maximumConeDegree: 140.0,
  260. color: "rgba(31,254,230,0.3)",
  261. outline: true,
  262. outlineColor: "#ffffff",
  263. },
  264. });
  265. graphicLayer.addGraphic(graphic);
  266. }
  267. //碗行体
  268. function addGraphic_10(graphicLayer) {
  269. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  270. position: new mars3d.LatLngPoint(116.1, 30.8, 1000),
  271. style: {
  272. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  273. innerRadii: new Cesium.Cartesian3(1800.0, 1800.0, 1800.0),
  274. minimumConeDegree: 110.0,
  275. color: "rgba(149,228,12,0.3)",
  276. outline: true,
  277. outlineColor: "#ffffff",
  278. },
  279. });
  280. graphicLayer.addGraphic(graphic);
  281. }
  282. //时钟开孔
  283. function addGraphic_11(graphicLayer) {
  284. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  285. position: new mars3d.LatLngPoint(116.2, 30.8, 1000),
  286. style: {
  287. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  288. innerRadii: new Cesium.Cartesian3(1500.0, 1500.0, 1500.0),
  289. minimumClockDegree: -90.0,
  290. maximumClockDegree: 180.0,
  291. minimumConeDegree: 20.0,
  292. maximumConeDegree: 70.0,
  293. color: "rgba(149,228,12,0.3)",
  294. outline: true,
  295. outlineColor: "#ffffff",
  296. },
  297. });
  298. graphicLayer.addGraphic(graphic);
  299. }
  300. //局部圆顶
  301. function addGraphic_12(graphicLayer) {
  302. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  303. position: new mars3d.LatLngPoint(116.3, 30.8, 1000),
  304. style: {
  305. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  306. minimumClockDegree: -90.0,
  307. maximumClockDegree: 180.0,
  308. maximumConeDegree: 90.0,
  309. color: "rgba(242,250,25,0.3)",
  310. outline: true,
  311. outlineColor: "#ffffff",
  312. },
  313. });
  314. graphicLayer.addGraphic(graphic);
  315. }
  316. //部分椭圆体
  317. function addGraphic_13(graphicLayer) {
  318. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  319. position: new mars3d.LatLngPoint(116.4, 30.8, 1000),
  320. style: {
  321. radii: new Cesium.Cartesian3(3000.0, 3000.0, 3000.0),
  322. innerRadii: new Cesium.Cartesian3(700.0, 700.0, 700.0),
  323. minimumClockDegree: 180.0,
  324. maximumClockDegree: 400.0,
  325. maximumConeDegree: 90.0,
  326. color: "rgba(247,154,44,0.3)",
  327. outline: true,
  328. outlineColor: "#ffffff",
  329. },
  330. });
  331. graphicLayer.addGraphic(graphic);
  332. }
  333. //土星综合对象
  334. function addGraphic_14(graphicLayer) {
  335. var position = new mars3d.LatLngPoint(116.5, 30.8, 1000);
  336. var graphic = new mars3d.graphic.EllipsoidPrimitive({
  337. name: "土星",
  338. position: position,
  339. style: {
  340. radii: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  341. color: new Cesium.Color(0.95, 0.82, 0.49),
  342. },
  343. });
  344. graphicLayer.addGraphic(graphic);
  345. var graphicNei = new mars3d.graphic.EllipsoidPrimitive({
  346. name: "土星的内圈",
  347. position: position,
  348. style: {
  349. radii: new Cesium.Cartesian3(4000.0, 4000.0, 4000.0),
  350. innerRadii: new Cesium.Cartesian3(3000.0, 3000.0, 3000.0),
  351. minimumConeDegree: 89.8,
  352. maximumConeDegree: 90.2,
  353. color: new Cesium.Color(0.95, 0.82, 0.49, 0.5),
  354. heading: 30,
  355. pitch: 30,
  356. },
  357. });
  358. graphicLayer.addGraphic(graphicNei);
  359. var graphicWai = new mars3d.graphic.EllipsoidPrimitive({
  360. name: "土星外圈",
  361. position: position,
  362. style: {
  363. radii: new Cesium.Cartesian3(4600.0, 4600.0, 4600.0),
  364. innerRadii: new Cesium.Cartesian3(4150.0, 4150.0, 4150.0),
  365. minimumConeDegree: 89.8,
  366. maximumConeDegree: 90.2,
  367. color: new Cesium.Color(0.95, 0.82, 0.49, 0.5),
  368. heading: 30,
  369. pitch: 30,
  370. },
  371. });
  372. graphicLayer.addGraphic(graphicWai);
  373. }
  374. </script>
  375. </body>
  376. </html>