arc_z
August 23, 2017, 4:03pm
1
hi,all.
I add some polylines from a geojson datasource, then I hide all of them and only show one , and change its material, then chrome tell me error.
[code]
test:function(){
var entities = ;
for(var i=0; i<viewer.dataSources.length; i++){
if(viewer.dataSources.get(i).name==‘test.json’){
entities =viewer.dataSources.get(i)._entityCollection._entities._array;
break;
}
}
for(var i in entities){
entities[i].show = false;
}
var _en = entities[1];
_en.show = true;
_en.polyline.material = new Cesium.PolylineOutlineMaterialProperty({color : Cesium.Color.fromBytes(255,0,0),outlineWidth : 0});
},
[test.json]
{
“type”: “FeatureCollection”,
“features”: [
{ “type”: “Feature”, “properties”: { “Id”: 0 }, “geometry”: { “type”: “LineString”, “coordinates”: [ [ 114.86133705101572, 40.51725185876473 ], [ 115.27982758793854, 40.326149243638127 ], [ 115.74186049286489, 40.461614388538003 ], [ 115.96682939421648, 40.289863936968516 ], [ 116.20873143868053, 40.555956185878983 ] ] } },
{ “type”: “Feature”, “properties”: { “Id”: 1 }, “geometry”: { “type”: “LineString”, “coordinates”: [ [ 114.86859411234964, 40.166493894291847 ], [ 115.49512040751155, 39.965715197386679 ], [ 116.03940000755568, 39.982648340499161 ], [ 116.31274931780007, 40.043123851615178 ], [ 116.67560238449616, 40.21971234407394 ] ] } }
]
}
[error]
Cesium.js:519 An error occurred while rendering. Rendering has stopped.
undefined
TypeError: Cannot read property ‘id’ of undefined
TypeError: Cannot read property ‘id’ of undefined
at u.updateShows (http://localhost:9082/ksh/js/Cesium/Cesium.js:487:23097 )
at u.update (http://localhost:9082/ksh/js/Cesium/Cesium.js:487:22878 )
at c.update (http://localhost:9082/ksh/js/Cesium/Cesium.js:487:24418 )
at m.update (http://localhost:9082/ksh/js/Cesium/Cesium.js:488:7497 )
at x.update (http://localhost:9082/ksh/js/Cesium/Cesium.js:493:20904 )
at X._onTick (http://localhost:9082/ksh/js/Cesium/Cesium.js:522:12917 )
at r.raiseEvent (http://localhost:9082/ksh/js/Cesium/Cesium.js:457:26930 )
at u.tick (http://localhost:9082/ksh/js/Cesium/Cesium.js:465:25311 )
at P.render (http://localhost:9082/ksh/js/Cesium/Cesium.js:519:24234 )
at t (http://localhost:9082/ksh/js/Cesium/Cesium.js:519:12202 )
P.showErrorPanel @ Cesium.js:519
Hi there,
Class members starting with an underscore (like _entityCollection) are private, and are not recommended for you to use. Instead, check out the DataSourceCollection and EntityCollection documentation for the public supported methods.
Thanks,
Gabby
arc_z
August 29, 2017, 1:31pm
3
thank you , Gabby.
I change my demo, and not use private attribute. but strange questions also exist.
for example, I hide line first, when I want to change color and show , I need to click right button three times.
[test.json]
{
“type”: “FeatureCollection”,
“features”: [
{ “type”: “Feature”, “properties”: { “Id”: 0 }, “geometry”: { “type”: “LineString”, “coordinates”: [ [ 114.86133705101572, 40.51725185876473 ], [ 115.27982758793854, 40.326149243638127 ], [ 115.74186049286489, 40.461614388538003 ], [ 115.96682939421648, 40.289863936968516 ], [ 116.20873143868053, 40.555956185878983 ] ] } },
{ “type”: “Feature”, “properties”: { “Id”: 1 }, “geometry”: { “type”: “LineString”, “coordinates”: [ [ 114.86859411234964, 40.166493894291847 ], [ 115.49512040751155, 39.965715197386679 ], [ 116.03940000755568, 39.982648340499161 ], [ 116.31274931780007, 40.043123851615178 ], [ 116.67560238449616, 40.21971234407394 ] ] } }
]
}
[code]
map
<button type="button" class="btn btn-link" style="position:absolute;z-index:10;left:30px;top:10px;font-size:24px;" onclick="toggleall()">toggleall</button>
<button type="button" class="btn btn-link" style="position:absolute;z-index:10;left:150px;top:10px;font-size:24px;" onclick="showbyid(0)">showbyid</button>
<div id="mapcontainer" style="width: 400px;height: 300px;margin-top:80px;"></div>
在 2017年8月26日星期六 UTC+8上午2:23:22,Gabby Getz写道:
Hi,
The way you are managing your entities with the window isn’t what we recommend. Try reading through our Visualizing Spatial Data tutorial .
Thanks,
Gabby
arc_z
September 4, 2017, 3:14am
5
thank you, gabby.
I change my code , never use window. but the problem still exists.
when clicking left button hide the line first, need to click right button 3 times, the color turn to red.
在 2017年9月1日星期五 UTC+8上午5:40:45,Gabby Getz写道:
test.json (699 Bytes)
map.html (2.85 KB)
Hi,
I think you are still managing adding and styling entities in a confusing way. I would recommend reading through the tutorial I sent in the last post, as well as our Cesium Workshop tutorial section on loading and styling entities .
Thanks,
Gabby
arc_z
September 7, 2017, 11:49am
7
thank you,gabby.
I edit my code, now it is very very very simple, no geojson,no private attribute, but the question also exist.
when hide line first, then show and change color, it worked need three times.
map
@import url(../js/Cesium/Widgets/widgets.css);
<button type="button" class="btn btn-link" style="position:absolute;z-index:10;left:30px;top:10px;font-size:24px;" onclick="hideOrShow()">HideOrShow</button>
<button type="button" class="btn btn-link" style="position:absolute;z-index:10;left:200px;top:10px;font-size:24px;" onclick="showAndChangecolor()">ShowAndChangecolor</button>
<div id="mapcontainer" style="width: 800px;height: 600px;margin-top:80px;"></div>
在 2017年9月5日星期二 UTC+8下午10:45:32,Gabby Getz写道: