Re: [cesium-dev] Problems with GeoJsonDataSource.load

648 views
Skip to first unread message

Scott Hunter

unread,
Oct 10, 2013, 1:19:21 PM10/10/13
to cesiu...@googlegroups.com
Your testGeoJson variable is wrapped inside extra array brackets: [ ], making it invalid GeoJSON.  If you remove those, it should load correctly.


On Wed, Oct 9, 2013 at 8:21 AM, <jason.l...@gmail.com> wrote:
I am seeing an issue that I can't explain loading GeoJson using the GeoJson.load prototype.  I am using the GeoJson provided in the cesium distro - Specs/Data/test.geojson.  I am only seeing an error when using the load prototype:

var testGeoJson=[ {
                    "type" : "FeatureCollection",
                    "features" : [{
                        "type" : "Feature",
                        "geometry" : {
                            "type" : "Point",
                            "coordinates" : [102.0, 0.5]
                        },
                        "properties" : {
                            "prop0" : "value0"
                        }
                    }, {
                        "type" : "Feature",
                        "geometry" : {
                            "type" : "LineString",
                            "coordinates" : [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]
                        },
                        "properties" : {
                            "prop0" : "value0",
                            "prop1" : 0.0
                        }
                    }, {
                        "type" : "Feature",
                        "geometry" : {
                            "type" : "Polygon",
                            "coordinates" : [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]]
                        },
                        "properties" : {
                            "prop0" : "value0",
                            "prop1" : {
                                "this" : "that"
                            }
                        }
                    }, {
                        "type" : "Feature",
                        "geometry" : {
                            "type" : "Topology",
                            "transform" : {
                                "scale" : [1, 1],
                                "translate" : [0, 0]
                            },
                            "objects" : {
                                "polygon" : {
                                    "type" : "Polygon",
                                    "arcs" : [[0, 1, 2, 3]]
                                }
                            },
                            "arcs" : [[[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1]], [[0, 0], [1, 0], [0, 1]], [[1, 1], [-1, 0], [0, -1]], [[1, 1]], [[0, 0]]]
                        }
                    }]
                }];

var viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.removeAll();
var jsonDataSource = new Cesium.GeoJsonDataSource();
jsonDataSource.load(testGeoJson, 'Test GeoJSON');

The exception returned when loading the GeoJson is:
uncaught exception: DeveloperError: Unsupported GeoJSON object type: undefined
at Cesium/Cesium.js:406

When I load the same GeoJSON using the loadUrl prototype, everything works properly.

- Jason

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages