{"id":1534,"date":"2016-01-22T21:03:12","date_gmt":"2016-01-22T21:03:12","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1534"},"modified":"2016-01-22T21:03:12","modified_gmt":"2016-01-22T21:03:12","slug":"cesium-how-to-changes-the-polygon-positions-on-left-click","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2016\/01\/cesium-how-to-changes-the-polygon-positions-on-left-click\/","title":{"rendered":"Cesium &#8211; How to changes the polygon positions on left click ?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2016\/01\/changes-the-polygon-positions-on-left-click.png\" alt=\"changes-the-polygon-positions-on-left-click\" width=\"659\" height=\"308\" class=\"aligncenter size-full wp-image-1535\" srcset=\"https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2016\/01\/changes-the-polygon-positions-on-left-click.png 659w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2016\/01\/changes-the-polygon-positions-on-left-click-300x140.png 300w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2016\/01\/changes-the-polygon-positions-on-left-click-624x292.png 624w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/p>\n<pre>\r\nvar viewer = new Cesium.Viewer('cesiumContainer', {\r\n    selectionIndicator : false,\r\n    infoBox : false\r\n});\r\n\r\nvar scene = viewer.scene;\r\n\r\nvar entity = viewer.entities.add({\r\n    polygon : {\r\n        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,\r\n                                                        -115.0, 32.0,\r\n                                                        -107.0, 33.0,\r\n                                                        -102.0, 31.0,\r\n                                                        -102.0, 35.0]),\r\n        material : Cesium.Color.RED\r\n    }\r\n}); \r\n\r\nvar handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);\r\nhandler.setInputAction(function(click) {\r\n    var pickedObject = scene.pick(click.position);\r\n    if (Cesium.defined(pickedObject) && (pickedObject.id === entity)) {\r\n        var positions = entity.polygon.hierarchy.getValue(viewer.clock.currentTime);\r\n        positions[0] = Cesium.Cartesian3.fromDegrees(-110.0, 37.0);\r\n        entity.polygon.hierarchy = positions;\r\n    }\r\n}, Cesium.ScreenSpaceEventType.LEFT_CLICK);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>var viewer = new Cesium.Viewer(&#8216;cesiumContainer&#8217;, { selectionIndicator : false, infoBox : false }); var scene = viewer.scene; var entity = viewer.entities.add({ polygon : { hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -115.0, 32.0, -107.0, 33.0, -102.0, 31.0, -102.0, 35.0]), material : Cesium.Color.RED } }); var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); handler.setInputAction(function(click) { var pickedObject = scene.pick(click.position); if (Cesium.defined(pickedObject) &#038;&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[53,27],"tags":[],"class_list":["post-1534","post","type-post","status-publish","format-standard","hentry","category-cesiumjs","category-javascript"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1534"}],"version-history":[{"count":1,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1534\/revisions"}],"predecessor-version":[{"id":1536,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1534\/revisions\/1536"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}