GeoJsonDataSource

new Cesium.GeoJsonDataSource(name)

A DataSource which processes both GeoJSON and TopoJSON data. simplestyle-spec properties will also be used if they are present.
参数名称 类型 描述信息
name string 可选 The name of this data source. If undefined, a name will be taken from the name of the GeoJSON file.
使用示例:
const 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:

成员(属性)

static Cesium.GeoJsonDataSource.clampToGround : boolean

Gets or sets default of whether to clamp to the ground.
默认值: false

static Cesium.GeoJsonDataSource.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.

static Cesium.GeoJsonDataSource.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.

static Cesium.GeoJsonDataSource.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'.

static Cesium.GeoJsonDataSource.fill : Color

Gets or sets default color for polygon interiors.
默认值: Color.YELLOW

static Cesium.GeoJsonDataSource.markerColor : Color

Gets or sets the default color of the map pin created for each point.
默认值: Color.ROYALBLUE

static Cesium.GeoJsonDataSource.markerSize : number

Gets or sets the default size of the map pin created for each point, in pixels.
默认值: 48

static Cesium.GeoJsonDataSource.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.

static Cesium.GeoJsonDataSource.stroke : Color

Gets or sets the default color of polylines and polygon outlines.
默认值: Color.BLACK

static Cesium.GeoJsonDataSource.strokeWidth : number

Gets or sets the default width of polylines and polygon outlines.
默认值: 2.0
Gets an event that will be raised when the underlying data changes.
This DataSource only defines static data, therefore this property is always undefined.
Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
Gets the credit that will be displayed for the data source
Gets the collection of Entity instances.
Gets an event that will be raised if an error is encountered during processing.
Gets a value indicating if the data source is currently loading data.
Gets an event that will be raised when the data source either starts or stops loading.
Gets or sets a human-readable name for this instance.
Gets whether or not this data source should be displayed.

方法

static Cesium.GeoJsonDataSource.load(data, options)Promise.<GeoJsonDataSource>

Creates a Promise to a new instance loaded with the provided GeoJSON or TopoJSON data.
参数名称 类型 描述信息
data Resource | string | object A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 An object specifying configuration options
返回值:
A promise that will resolve when the data is loaded.
Asynchronously loads the provided GeoJSON or TopoJSON data, replacing any existing data.
参数名称 类型 描述信息
data Resource | string | object A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 An object specifying configuration options
返回值:
a promise that will resolve when the GeoJSON is loaded.
Asynchronously loads the provided GeoJSON or TopoJSON data, without replacing any existing data.
参数名称 类型 描述信息
data Resource | string | object A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 An object specifying configuration options
返回值:
a promise that will resolve when the GeoJSON is loaded.
Updates the data source to the provided time. This function is optional and is not required to be implemented. It is provided for data sources which retrieve data based on the current animation time or scene state. If implemented, update will be called by DataSourceDisplay once a frame.
参数名称 类型 描述信息
time JulianDate The simulation time.
返回值:
True if this data source is ready to be displayed at the provided time, false otherwise.

定义的类型

Cesium.GeoJsonDataSource.describe(properties, nameProperty)

This callback is displayed as part of the GeoJsonDataSource class.
参数名称 类型 描述信息
properties object The properties of the feature.
nameProperty string The property key that Cesium estimates to have the name of the feature.

Cesium.GeoJsonDataSource.LoadOptions

Initialization options for the load method.
属性:
属性名称 类型 可选 默认值 描述信息
sourceUri string <可选>
Overrides the url to use for resolving relative links.
describe GeoJsonDataSource.describe <可选>
GeoJsonDataSource.defaultDescribeProperty A function which returns a Property object (or just a string).
markerSize number <可选>
GeoJsonDataSource.markerSize The default size of the map pin created for each point, in pixels.
markerSymbol string <可选>
GeoJsonDataSource.markerSymbol The default symbol of the map pin created for each point.
markerColor Color <可选>
GeoJsonDataSource.markerColor The default color of the map pin created for each point.
stroke Color <可选>
GeoJsonDataSource.stroke The default color of polylines and polygon outlines.
strokeWidth number <可选>
GeoJsonDataSource.strokeWidth The default width of polylines and polygon outlines.
fill Color <可选>
GeoJsonDataSource.fill The default color for polygon interiors.
clampToGround boolean <可选>
GeoJsonDataSource.clampToGround true if we want the geometry features (polygons or linestrings) clamped to the ground.
credit Credit | string <可选>
A credit for the data source, which is displayed on the canvas.