{"id":1827,"date":"2018-08-22T01:56:33","date_gmt":"2018-08-22T01:56:33","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1827"},"modified":"2018-08-22T01:56:33","modified_gmt":"2018-08-22T01:56:33","slug":"remove-geojson-datasource-as-well-as-entities","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2018\/08\/remove-geojson-datasource-as-well-as-entities\/","title":{"rendered":"Remove GeoJSON datasource as well as entities"},"content":{"rendered":"<pre>\r\n\/\/ 1. we can save the references to the entities that are labels in an array called 'labels'\r\nvar labels = [];\r\n\r\n\r\nvar promise = Cesium.GeoJsonDataSource.load('..\/..\/..\/cesiumLayers\/sampledata\/nextgen\/World_Lables.geojson');\r\npromise.then(function (dataSource) { \r\n    \/\/viewer.dataSources.add(dataSource); \r\n    var entities = dataSource.entities.values; \r\n\r\n    for (var i = 0; i < entities.length; i++) { \r\n        var entity = entities[i]; \r\n        var abc = entity.position.getValue(); \r\n        var stPt = convertCartesianToCartographic(abc); \r\n        \/\/entity.position = Cesium.Cartesian3.fromDegrees(stPt[0],stPt[1],stPt[2]); \r\n\r\n        \/\/ 2. Now, push each entity that's a label to our 'labels' array\r\n        labels.push(viewer.entities.add({ \r\n            position: Cesium.Cartesian3.fromDegrees(stPt[0], stPt[1], stPt[2]), \r\n            label: { \r\n                text: entity.properties.name, \r\n                font: '16px Helvetica', \r\n                fillColor: Cesium.Color.WHITE, \r\n                outlineColor: Cesium.Color.BLACK, \r\n                outlineWidth: 5, \r\n                \/\/pixelOffset : new Cartesian3(50.0, -50.0), \r\n                style: Cesium.LabelStyle.FILL_AND_OUTLINE, \r\n                translucencyByDistance: new Cesium.NearFarScalar(2.5e6, 1.0, 2.5e7, 0.0) \r\n            } \r\n        })); \r\n    } \r\n});\r\n\r\n\/\/ some code later...\r\n\r\nfor (var i = 0; i < labels.length; i++) {\r\n    \/\/ remove each entity that's a label\r\n    viewer.entities.remove(labels[i]);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ 1. we can save the references to the entities that are labels in an array called &#8216;labels&#8217; var labels = []; var promise = Cesium.GeoJsonDataSource.load(&#8216;..\/..\/..\/cesiumLayers\/sampledata\/nextgen\/World_Lables.geojson&#8217;); promise.then(function (dataSource) { \/\/viewer.dataSources.add(dataSource); var entities = dataSource.entities.values; for (var i = 0; i < entities.length; i++) { var entity = entities[i]; var abc = entity.position.getValue(); var stPt = [&hellip;]\n<\/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],"tags":[],"class_list":["post-1827","post","type-post","status-publish","format-standard","hentry","category-cesiumjs"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1827","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=1827"}],"version-history":[{"count":1,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1827\/revisions"}],"predecessor-version":[{"id":1828,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1827\/revisions\/1828"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}