GeoJsonDataSource - Cesium Documentation

# GeoJsonDataSource

#### new GeoJsonDataSource(name)

  A `DataSource` which processes both GeoJSON and TopoJSON data. simplestyle-spec properties will also be used if they are present.

  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');
      viewer.dataSources.add(Cesium.GeoJsonDataSource.load('../../SampleData/ne_10m_us_states.topojson', {
        stroke: Cesium.Color.HOTPINK,
        fill: Cesium.Color.PINK,
        strokeWidth: 3,
        markerSymbol: '?'
      }));

  ##### Demo:

  - Cesium Sandcastle GeoJSON and TopoJSON Demo
  - Cesium Sandcastle GeoJSON simplestyle Demo
  Source: DataSources/GeoJsonDataSource.js, line 493

### Members

#### staticGeoJsonDataSource.crsLinkHrefs :Object

  Gets 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.
  Source: DataSources/GeoJsonDataSource.js, line 636

#### staticGeoJsonDataSource.crsLinkTypes :Object

  Gets 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.
  Source: DataSources/GeoJsonDataSource.js, line 650

#### staticGeoJsonDataSource.crsNames :Object

  Gets 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'.
  Source: DataSources/GeoJsonDataSource.js, line 621

#### staticGeoJsonDataSource.fill :Color

  Gets or sets default color for polygon interiors.
  Default Value: `Color.YELLOW`
  Source: DataSources/GeoJsonDataSource.js, line 603

#### staticGeoJsonDataSource.markerColor :Color

  Gets or sets the default color of the map pin created for each point.
  Default Value: `Color.ROYALBLUE`
  Source: DataSources/GeoJsonDataSource.js, line 559

#### staticGeoJsonDataSource.markerSize :Number

  Gets or sets the default size of the map pin created for each point, in pixels.
  Default Value: `48`
  Source: DataSources/GeoJsonDataSource.js, line 530

#### staticGeoJsonDataSource.markerSymbol :String

  Gets or sets the default symbol of the map pin created for each point. This can be any valid Maki identifier, any single character, or blank if no symbol is to be used.
  Source: DataSources/GeoJsonDataSource.js, line 545

#### staticGeoJsonDataSource.stroke :Color

  Gets or sets the default color of polylines and polygon outlines.
  Default Value: `Color.BLACK`
  Source: DataSources/GeoJsonDataSource.js, line 573

#### staticGeoJsonDataSource.strokeWidth :Number

  Gets or sets the default width of polylines and polygon outlines.
  Default Value: `2.0`
  Source: DataSources/GeoJsonDataSource.js, line 588

#### changedEvent :Event

  Gets an event that will be raised when the underlying data changes.
  Source: DataSources/GeoJsonDataSource.js, line 702

#### clock :DataSourceClock

  This DataSource only defines static data, therefore this property is always undefined.
  Source: DataSources/GeoJsonDataSource.js, line 673

#### entities :EntityCollection

  Gets the collection of `Entity` instances.
  Source: DataSources/GeoJsonDataSource.js, line 682

#### errorEvent :Event

  Gets an event that will be raised if an error is encountered during processing.
  Source: DataSources/GeoJsonDataSource.js, line 712

#### isLoading :Boolean

  Gets a value indicating if the data source is currently loading data.
  Source: DataSources/GeoJsonDataSource.js, line 692

#### loadingEvent :Event

  Gets an event that will be raised when the data source either starts or stops loading.
  Source: DataSources/GeoJsonDataSource.js, line 722

#### name :String

  Gets a human-readable name for this instance.
  Source: DataSources/GeoJsonDataSource.js, line 663

### Methods

#### staticGeoJsonDataSource.load(data, options) → Promise.<GeoJsonDataSource>

  Creates a Promise to a new instance loaded with the provided GeoJSON or TopoJSON data.

  Name | Type | Description
  --- | --- | ---
  `data` | String | Object | A url, GeoJSON object, or TopoJSON object to be loaded.

  `options`

  Object

  optional An object with the following properties:

  Name | Type | Default | Description
  --- | --- | --- | ---
  `sourceUri` | String |  | optional Overrides the url to use for resolving relative links.
  `markerSize` | Number | `GeoJsonDataSource.markerSize` | optional The default size of the map pin created for each point, in pixels.
  `markerSymbol` | String | `GeoJsonDataSource.markerSymbol` | optional The default symbol of the map pin created for each point.
  `markerColor` | Color | `GeoJsonDataSource.markerColor` | optional The default color of the map pin created for each point.
  `stroke` | Color | `GeoJsonDataSource.stroke` | optional The default color of polylines and polygon outlines.
  `strokeWidth` | Number | `GeoJsonDataSource.strokeWidth` | optional The default width of polylines and polygon outlines.
  `fill` | Color | `GeoJsonDataSource.fill` | optional The default color for polygon interiors.

  ##### Returns:

  A promise that will resolve when the data is loaded.
  Source: DataSources/GeoJsonDataSource.js, line 519

#### load(data, options) → Promise.<GeoJsonDataSource>

  Asynchronously loads the provided GeoJSON or TopoJSON data, replacing any existing data.

  Name | Type | Description
  --- | --- | ---
  `data` | String | Object | A url, GeoJSON object, or TopoJSON object to be loaded.

  `options`

  Object

  optional An object with the following properties:

  Name | Type | Default | Description
  --- | --- | --- | ---
  `sourceUri` | String |  | optional Overrides the url to use for resolving relative links.
  `markerSize` | Number | `GeoJsonDataSource.markerSize` | optional The default size of the map pin created for each point, in pixels.
  `markerSymbol` | String | `GeoJsonDataSource.markerSymbol` | optional The default symbol of the map pin created for each point.
  `markerColor` | Color | `GeoJsonDataSource.markerColor` | optional The default color of the map pin created for each point.
  `stroke` | Color | `GeoJsonDataSource.stroke` | optional The default color of polylines and polygon outlines.
  `strokeWidth` | Number | `GeoJsonDataSource.strokeWidth` | optional The default width of polylines and polygon outlines.
  `fill` | Color | `GeoJsonDataSource.fill` | optional The default color for polygon interiors.

  ##### Returns:

  a promise that will resolve when the GeoJSON is loaded.
  Source: DataSources/GeoJsonDataSource.js, line 744