English中文

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 类型 Type 说明 Description
name string 可选 optional 该数据源的名称。如果未定义,将从 GeoJSON 文件的名称中获取名称。 The name of this data source. If undefined, a name will be taken from the name of the GeoJSON file.
示例: Example:
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:

成员 Members

static Cesium.GeoJsonDataSource.clampToGround : boolean

获取或设置是否夹紧地面的默认值。 Gets or sets default of whether to clamp to the ground.
默认值: Default Value: false

static Cesium.GeoJsonDataSource.crsLinkHrefs : object

获取一个对象,该对象将 crs 链接的 href 属性映射到回调函数,该函数采用 crs 属性对象并返回一个 Promise,该 Promise 解析为采用 GeoJSON 坐标并将其转换为 WGS84 地球固定笛卡尔坐标的函数。该对象中的项目优先于中定义的项目 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

获取一个对象,该对象将 crs 链接的类型属性映射到回调函数,该回调函数采用 crs 属性对象并返回一个 Promise,该 Promise 解析为采用 GeoJSON 坐标并将其转换为 WGS84 地球固定笛卡尔坐标的函数。项目在 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

获取一个对象,该对象将 crs 的名称映射到回调函数,该函数采用 GeoJSON 坐标并将其转换为 WGS84 地球固定笛卡尔坐标。支持 EPSG 类型的旧版本 GeoJSON 也可以通过指定完整的 EPSG 名称(例如“EPSG:4326”)添加到此列表中。 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.
默认值: Default Value: Color.YELLOW

static Cesium.GeoJsonDataSource.markerColor : Color

获取或设置为每个点创建的地图图钉的默认颜色。 Gets or sets the default color of the map pin created for each point.
默认值: Default Value: Color.ROYALBLUE

static Cesium.GeoJsonDataSource.markerSize : number

获取或设置为每个点创建的地图图钉的默认大小(以像素为单位)。 Gets or sets the default size of the map pin created for each point, in pixels.
默认值: Default Value: 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.
默认值: Default Value: Color.BLACK

static Cesium.GeoJsonDataSource.strokeWidth : number

获取或设置折线和多边形轮廓的默认宽度。 Gets or sets the default width of polylines and polygon outlines.
默认值: Default Value: 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.

方法 Methods

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

创建一个 Promise 到加载了所提供的 GeoJSON 或 TopoJSON 数据的新实例。 Creates a Promise to a new instance loaded with the provided GeoJSON or TopoJSON data.
名称 Name 类型 Type 说明 Description
data Resource | string | object 要加载的 url、GeoJSON 对象或 TopoJSON 对象。 A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 optional 指定配置选项的对象 An object specifying configuration options
返回: Returns:
加载数据时将解决的承诺。 A promise that will resolve when the data is loaded.
异步加载提供的 GeoJSON 或 TopoJSON 数据,替换任何现有数据。 Asynchronously loads the provided GeoJSON or TopoJSON data, replacing any existing data.
名称 Name 类型 Type 说明 Description
data Resource | string | object 要加载的 url、GeoJSON 对象或 TopoJSON 对象。 A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 optional 指定配置选项的对象 An object specifying configuration options
返回: Returns:
加载 GeoJSON 时将解决的承诺。 a promise that will resolve when the GeoJSON is loaded.
异步加载提供的 GeoJSON 或 TopoJSON 数据,而不替换任何现有数据。 Asynchronously loads the provided GeoJSON or TopoJSON data, without replacing any existing data.
名称 Name 类型 Type 说明 Description
data Resource | string | object 要加载的 url、GeoJSON 对象或 TopoJSON 对象。 A url, GeoJSON object, or TopoJSON object to be loaded.
options GeoJsonDataSource.LoadOptions 可选 optional 指定配置选项的对象 An object specifying configuration options
返回: Returns:
加载 GeoJSON 时将解决的承诺。 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.
名称 Name 类型 Type 说明 Description
time JulianDate 模拟时间。 The simulation time.
返回: Returns:
如果此数据源已准备好在提供的时间显示,则为 true,否则为 false。 True if this data source is ready to be displayed at the provided time, false otherwise.

类型定义 Type Definitions

Cesium.GeoJsonDataSource.describe(properties, nameProperty)

此回调显示为 GeoJsonDataSource 类的一部分。 This callback is displayed as part of the GeoJsonDataSource class.
名称 Name 类型 Type 说明 Description
properties object 特征的属性。 The properties of the feature.
nameProperty string Cesium估计具有特征名称的属性键。 The property key that Cesium estimates to have the name of the feature.

Cesium.GeoJsonDataSource.LoadOptions

初始化选项 Initialization options for the load method.
属性: Properties:
名称 Name 类型 Type Attributes 默认值 Default 说明 Description
sourceUri string <可选> &lt;optional>
覆盖用于解析相对链接的 url。 Overrides the url to use for resolving relative links.
describe GeoJsonDataSource.describe <可选> &lt;optional>
GeoJsonDataSource.defaultDescribeProperty 返回 Property 对象(或只是字符串)的函数。 A function which returns a Property object (or just a string).
markerSize number <可选> &lt;optional>
GeoJsonDataSource.markerSize 为每个点创建的地图图钉的默认大小(以像素为单位)。 The default size of the map pin created for each point, in pixels.
markerSymbol string <可选> &lt;optional>
GeoJsonDataSource.markerSymbol 为每个点创建的地图图钉的默认符号。 The default symbol of the map pin created for each point.
markerColor Color <可选> &lt;optional>
GeoJsonDataSource.markerColor 为每个点创建的地图图钉的默认颜色。 The default color of the map pin created for each point.
stroke Color <可选> &lt;optional>
GeoJsonDataSource.stroke 折线和多边形轮廓的默认颜色。 The default color of polylines and polygon outlines.
strokeWidth number <可选> &lt;optional>
GeoJsonDataSource.strokeWidth 折线和多边形轮廓的默认宽度。 The default width of polylines and polygon outlines.
fill Color <可选> &lt;optional>
GeoJsonDataSource.fill 多边形内部的默认颜色。 The default color for polygon interiors.
clampToGround boolean <可选> &lt;optional>
GeoJsonDataSource.clampToGround true 如果我们希望几何特征(多边形或线串)固定在地面上。 true if we want the geometry features (polygons or linestrings) clamped to the ground.
credit Credit | string <可选> &lt;optional>
数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.