viewerDragDropMixin bug?

This is a viewerDragDropMixin bug?

With viewer.dataSources.dataSourceAdded.addEventListener, I try to change color. But catch the entitys is the problem.

Load json file with Cesium.GeoJsonDataSource.load, the entity.polyline is PolylineGraphics

Load json file with Cesium.viewerDragDropMixin, the entity.polyline is undefined

Help, please!

Hi there,

Can you create a code sample with Sandcastle to reproduce? Can you also post the GeoJson or a sample one that can reproduce?

Thanks,

Gabby

Hi Gabby,

You already post the solution:

It will depend on the GeoJson that is dropped. The place to check would be in that if/else block below.

The data is a json file like this:

{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "source": "L_Arruamento", "Shape_Leng": 170.78430733799999, "NAM": "", "WD2": 0.0, "WD1": 0, "Layer": 21, "Linetype": 7, "LTScale": 4, "Color": 11, "FCO": "", "RRA": "", "BSN": 0, "LEN": 0.0, "NOS": 0, "OHC": 0, "SPL": 0, "UBC": 0, "BCC": "", "BSC": "", "MCC": "", "TRF": "" }, "geometry": { "type": "LineString", "coordinates": [ [ -8.708646540042777, 41.200113834086267, 79.671179338358343 ], [ -8.708486992288789, 41.199080127460128, 81.737021273002028 ], [ -8.708414473062048, 41.198586048807428, 82.181673637591302 ] ] } }
]
}

When I use the viewerDragDropMixin, the TYPE is entity.billboard...

So, how I now if is point, line, or polygon on entity.billboard?

Thanks

if (Cesium.defined(entity.billboard)) {
// billboard specific styling code
} else if (Cesium.defined(entity.polyline)) {
// polyline specific styling code
} else if (Cesium.defined(entity.point)) {

`` // point specific styling code
} else if (Cesium.defined(entity.polygon)) {

// polygon specific styling code

}

Hello Gabby,

if (Cesium.defined(entity.billboard)) {
    // billboard specific styling code
    // the problem is inside billboard... json point or polyline or polygon, enter as billboard... know if is point, line, or polygon... how?
} else if (Cesium.defined(entity.polyline)) {
    // no problem
} else if (Cesium.defined(entity.point)) {
    // no problem
} else if (Cesium.defined(entity.polygon)) {
    // no problem

Example:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "Layer": 32, "Linetype": 0, "LTScale": 0, "Color": 3, "RefName": "C101", "Elevation": 11.990497749199999, "source": null, "Shape_Leng": null, "NAM": null, "WD2": null, "WD1": null, "FCO": null, "RRA": null, "BSN": null, "LEN": null, "NOS": null, "OHC": null, "SPL": null, "UBC": null, "BCC": null, "BSC": null, "MCC": null, "TRF": null, "Shape_Area": null }, "geometry": { "type": "Point", "coordinates": [ -8.671536004504599, 41.149943563073762, 72.247754401527345 ] } },
{ "type": "Feature", "properties": { "Layer": 21, "Linetype": 7, "LTScale": 4, "Color": 11, "RefName": null, "Elevation": null, "source": "L_Arruamento", "Shape_Leng": 244.335452863, "NAM": "", "WD2": 0.0, "WD1": 0, "FCO": "", "RRA": "", "BSN": 0, "LEN": 0.0, "NOS": 0, "OHC": 0, "SPL": 0, "UBC": 0, "BCC": "", "BSC": "", "MCC": "", "TRF": "", "Shape_Area": null }, "geometry": { "type": "LineString", "coordinates": [ [ -8.6708621997381, 41.148878863823832, 66.842686244286597 ], [ -8.670800496089294, 41.148976928805162, 67.327407407574356 ], [ -8.670774546309309, 41.149043223338715, 67.480578821152449 ], [ -8.67077557442502, 41.149127900953559, 68.131045251153409 ], [ -8.670815019597189, 41.149325583056203, 70.324718699790537 ], [ -8.670857891613691, 41.149445360767153, 71.842453115619719 ], [ -8.670946400774316, 41.149700552994915, 72.68487471435219 ], [ -8.671042948969873, 41.149908046903597, 73.233858211897314 ], [ -8.671063453684416, 41.149954671709956, 73.909832615405321 ], [ -8.671063593495697, 41.14996624013007, 74.381569015793502 ], [ -8.671057257495381, 41.149984659876935, 74.611117855645716 ], [ -8.671034578926566, 41.150002610202954, 74.955442521721125 ], [ -8.670800706809958, 41.150149101133579, 74.190576039254665 ], [ -8.670707034118109, 41.150242018812854, 74.088736683130264 ], [ -8.670684165440191, 41.150297207910235, 74.165377633646131 ], [ -8.67069505925047, 41.150410499690977, 74.165747318416834 ], [ -8.670718737815262, 41.150506688696453, 74.16608124319464 ], [ -8.670732377520089, 41.150560068638548, 74.16626724973321 ], [ -8.670719455303404, 41.150618787104868, 74.166433059610426 ], [ -8.670687359409527, 41.150719250590292, 74.166702874936163 ], [ -8.670674830900213, 41.15075735373842, 74.166804715059698 ], [ -8.670679164505605, 41.150796506507483, 74.166933266445994 ], [ -8.670715770475763, 41.150907012044463, 74.167329955846071 ] ] } },
{ "type": "Feature", "properties": { "Layer": 17, "Linetype": 0, "LTScale": 3, "Color": 1, "RefName": null, "Elevation": null, "source": null, "Shape_Leng": 728.74606650600003, "NAM": null, "WD2": null, "WD1": null, "FCO": null, "RRA": null, "BSN": null, "LEN": null, "NOS": null, "OHC": null, "SPL": null, "UBC": null, "BCC": null, "BSC": null, "MCC": null, "TRF": null, "Shape_Area": 4278.7607018099998 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -8.671924458925888, 41.149961627566469, 80.413550660945475 ], [ -8.671690550787895, 41.149946236225468, 80.413177499547601 ], [ -8.671689595325729, 41.149867683094506, 80.412930337712169 ], [ -8.671468085994261, 41.149814091372583, 80.488954856991768 ], [ -8.671486933986037, 41.149745610182066, 80.488766731694341 ], [ -8.671345140069336, 41.149699632997326, 80.156925837509334 ], [ -8.671355797852705, 41.149655709122328, 79.226003183983266 ], [ -8.671422049381956, 41.149666917509421, 79.226130308583379 ], [ -8.671435369047451, 41.149640962636454, 78.180567588657141 ], [ -8.671284883015966, 41.149588920050633, 77.338695636950433 ], [ -8.67126410244733, 41.149667721476831, 77.338913374580443 ], [ -8.671239149796097, 41.149667894737533, 77.338879249989986 ], [ -8.671237226812419, 41.149721286170561, 76.956543668173254 ], [ -8.671197556044413, 41.149716991604187, 76.956475110724568 ], [ -8.671231778998909, 41.149548162044553, 76.02529430296272 ], [ -8.671116685444327, 41.149540014879889, 77.937608898617327 ], [ -8.671163253623622, 41.149699241952398, 78.715871903114021 ], [ -8.671116696041514, 41.149699759187683, 78.728608838282526 ], [ -8.671119386227137, 41.14973065874144, 78.728709273040295 ], [ -8.671184608820431, 41.149731276279972, 78.728801823221147 ], [ -8.671175593838994, 41.149804453424132, 78.486718309111893 ], [ -8.671338126804541, 41.149821119300221, 78.486996284686029 ], [ -8.671319089864184, 41.149905839426772, 78.614734969101846 ], [ -8.671441675805136, 41.149916461402327, 78.614938529208302 ], [ -8.671406526341094, 41.149977278309372, 78.678880020976067 ], [ -8.671204420356618, 41.149932690754213, 79.915159679949284 ], [ -8.671074000754, 41.149933596125969, 79.22648131288588 ], [ -8.671002435789461, 41.149802640640473, 78.269772052764893 ], [ -8.670930679149834, 41.149602946706253, 78.830047412775457 ], [ -8.670896565282373, 41.149452480259811, 79.326729130931199 ], [ -8.671074602410643, 41.149421883263656, 79.84968073759228 ], [ -8.671073518703143, 41.149332636114416, 78.931399931199849 ], [ -8.671140528450517, 41.149332171001845, 79.224691579118371 ], [ -8.671140227144225, 41.149307282612746, 79.224613269791007 ], [ -8.671255853440169, 41.149306383379205, 79.275771105661988 ], [ -8.671256773380215, 41.149382117318169, 79.301509393379092 ], [ -8.67120635487537, 41.149382467128696, 79.301440436393023 ], [ -8.671207737460797, 41.149496214379191, 77.453098327852786 ], [ -8.671316620628181, 41.149533183621408, 76.152865306474268 ], [ -8.67147775299852, 41.14955092895552, 73.564844715408981 ], [ -8.671563517562015, 41.149421410327967, 73.564558548852801 ], [ -8.671633627425424, 41.149443090947166, 73.768723811022937 ], [ -8.671516700048604, 41.149654594523675, 75.783723250962794 ], [ -8.671677193942754, 41.149704524456943, 76.255902498029172 ], [ -8.671714509069936, 41.149663235633966, 76.306825131177902 ], [ -8.671713819610533, 41.149606557063336, 76.80384680069983 ], [ -8.671642782293999, 41.149603743719055, 76.918539294973016 ], [ -8.671645464380751, 41.149475190635414, 76.331640712916851 ], [ -8.671658744180444, 41.149403636457457, 74.648435235023499 ], [ -8.671690126952736, 41.149403418644383, 74.648478156886995 ], [ -8.671689654800842, 41.149364531501099, 74.648355804383755 ], [ -8.671472010487499, 41.149364194244974, 74.6480523487553 ], [ -8.671449760996831, 41.149491522790186, 73.156619910150766 ], [ -8.671377334578265, 41.149490858102254, 72.799517201259732 ], [ -8.671401087678243, 41.149296724244209, 73.86994266603142 ], [ -8.671275253922598, 41.149283305135803, 74.277725834399462 ], [ -8.671291298431394, 41.14915349180999, 74.545141879469156 ], [ -8.671409739856458, 41.14916200393403, 76.649033077992499 ], [ -8.671417518461849, 41.149156598183133, 90.521026974543929 ], [ -8.671672054142437, 41.149154929835511, 90.279175412841141 ], [ -8.671687483168594, 41.149164742722448, 77.401727550663054 ], [ -8.671784717866428, 41.149164068852166, 76.024860542267561 ], [ -8.67178520984479, 41.149289100376087, 74.316752506420016 ], [ -8.67187662866453, 41.149592981463265, 76.638330520130694 ], [ -8.67190873934784, 41.149769031394314, 78.678926089778543 ], [ -8.671918784592585, 41.149875814513486, 80.08177422452718 ], [ -8.671924458925888, 41.149961627566469, 80.413550660945475 ] ] ] } },
{ "type": "Feature", "properties": { "Layer": null, "Linetype": null, "LTScale": null, "Color": null, "RefName": null, "Elevation": null, "source": null, "Shape_Leng": null, "NAM": null, "WD2": null, "WD1": null, "FCO": null, "RRA": null, "BSN": null, "LEN": null, "NOS": null, "OHC": null, "SPL": null, "UBC": null, "BCC": null, "BSC": null, "MCC": null, "TRF": null, "Shape_Area": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -8.672519323169086, 41.150051743427461, 80.413550660945475 ], [ -8.672537546750286, 41.150403198207748, 80.413550660945475 ], [ -8.672157454913826, 41.150504729588725, 80.413550660945475 ], [ -8.671884101195825, 41.150358940939121, 80.413550660945475 ], [ -8.672003856157998, 41.150114224277289, 80.413550660945475 ], [ -8.672118404382683, 41.149827853715578, 80.413550660945475 ], [ -8.672324070513371, 41.149765372865744, 80.413550660945475 ], [ -8.672519323169086, 41.150051743427461, 80.413550660945475 ] ] ] } },
{ "type": "Feature", "properties": { "Layer": null, "Linetype": null, "LTScale": null, "Color": null, "RefName": null, "Elevation": null, "source": null, "Shape_Leng": null, "NAM": null, "WD2": null, "WD1": null, "FCO": null, "RRA": null, "BSN": null, "LEN": null, "NOS": null, "OHC": null, "SPL": null, "UBC": null, "BCC": null, "BSC": null, "MCC": null, "TRF": null, "Shape_Area": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -8.671600334002852, 41.150387577995296, 80.413550660945475 ], [ -8.671576903684166, 41.150720809194382, 80.413550660945475 ], [ -8.670905234548506, 41.150723412563124, 80.413550660945475 ], [ -8.670887010967306, 41.150262616295635, 80.413550660945475 ], [ -8.671350410603537, 41.150254806189409, 80.413550660945475 ], [ -8.671600334002852, 41.150387577995296, 80.413550660945475 ] ] ] } }
]
}

1 point, 1 line and 3 polygons

With viewerDragDropMixin, on viewer.dataSources.dataSourceAdded.addEventListener and console print I have this:

1 point as entity.billboard
1 line as nothing, is not a billboard or point or line or polygon
3 polygons as entity.polygon

if (Cesium.defined(entity.billboard)) {
    // catch the point... OK
} else if (Cesium.defined(entity.polyline)) {
    // ...
} else if (Cesium.defined(entity.point)) {
    // ...
} else if (Cesium.defined(entity.polygon)) {
    // catch the 3 polygons... OK

Dont catch the line... :frowning:

Thanks

If you look in the source code for GeoJsonDataSource you can see exactly how different types of data from the GeoJSON is mapped to entity properties.

Specifically you can see that a LineString creates either a Corridor or a Polyline, depending on whether clampToGround is true or false:

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/GeoJsonDataSource.js#L364