GeoJsonDataSource

new GeoJsonDataSource(name)

A DataSource which processes both GeoJSON and TopoJSON data.
Name Type Description
name String optional The name of this data source. If undefined, a name will be taken from the name of the GeoJSON file.
Example:
var viewer = new Cesium.Viewer('cesiumContainer');
var dataSource = new Cesium.GeoJsonDataSource();
viewer.dataSources.add(dataSource);
dataSource.loadUrl('sample.geojson');
Demo:

Members

staticGeoJsonDataSource.crsLinkHrefs :Object

An object that maps the href property of a crs link to a callback function which takes the crs properties object and returns a Promise that resolves to a function that takes a GeoJSON coordinate and transforms it into a WGS84 Earth-fixed Cartesian. Items in this object take precedence over those defined in crsLinkHrefs, assuming the link has a type specified.

staticGeoJsonDataSource.crsLinkTypes :Object

An object that maps the type property of a crs link to a callback function which takes the crs properties object and returns a Promise that resolves to a function that takes a GeoJSON coordinate and transforms it into a WGS84 Earth-fixed Cartesian. Items in crsLinkHrefs take precedence over this object.

staticGeoJsonDataSource.crsNames :Object

An object that maps the name of a crs to a callback function which takes a GeoJSON coordinate and transforms it into a WGS84 Earth-fixed Cartesian. Older versions of GeoJSON which supported the EPSG type can be added to this list as well, by specifying the complete EPSG name, for example 'EPSG:4326'.

changedEvent :Event

Gets an event that will be raised when the underlying data changes.
This DataSource only defines static data, therefore this property is always undefined.

entities :EntityCollection

Gets the collection of Entity instances.

errorEvent :Event

Gets an event that will be raised if an error is encountered during processing.

isLoading :Boolean

Gets a value indicating if the data source is currently loading data.

loadingEvent :Event

Gets an event that will be raised when the data source either starts or stops loading.

name :String

Gets a human-readable name for this instance.

Methods

load(geoJson, sourceUri)Promise

Asynchronously loads the provided GeoJSON object, replacing any existing data.
Name Type Description
geoJson Object The object to be processed.
sourceUri String optional The base URI of any relative links in the geoJson object.
Returns:
a promise that will resolve when the GeoJSON is loaded.
Throws:

loadUrl(url)Promise

Asynchronously loads the GeoJSON at the provided url, replacing any existing data.
Name Type Description
url Object The url to be processed.
Returns:
a promise that will resolve when the GeoJSON is loaded.