English中文

Google2DImageryProvider

new Cesium.Google2DImageryProvider(options)

该对象通常不直接实例化,使用 This object is normally not instantiated directly, use Google2DImageryProvider.fromIonAssetId or Google2DImageryProvider.fromUrl.
提供 2D 图像图块 Provides 2D image tiles from Google 2D Tiles。 Google 2D Tiles 只能与 Google 地理编码器一起使用。 . Google 2D Tiles can only be used with the Google geocoder.
名称 Name 类型 Type 说明 Description
options Google2DImageryProvider.ConstructorOptions 描述初始化选项的对象 Object describing initialization options
示例: Examples:
// Google 2D imagery provider
const googleTilesProvider = Cesium.Google2DImageryProvider.fromIonAssetId({
    assetId: 3830184
});
// Use your own Google api key
Cesium.GoogleMaps.defaultApiKey = "your-api-key";

const googleTilesProvider = Cesium.Google2DImageryProvider.fromUrl({
    mapType: "SATELLITE"
});
另见: See:

成员 Members

获取此图像提供程序处于活动状态时要显示的信用。通常,这用于证明图像的来源。 Gets the credit to display when this imagery provider is active. Typically this is used to credit the source of the imagery.
获取当图像提供程序遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。事件监听器传递一个实例 Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing to the event, you will be notified of the error and can potentially recover from it. Event listeners are passed an instance of TileProviderError.

readonly hasAlphaChannel : boolean

获取一个值,该值指示此图像提供程序提供的图像是否包含 Alpha 通道。如果此属性为 false,则 Alpha 通道(如果存在)将被忽略。如果此属性为 true,则任何没有 Alpha 通道的图像都将被视为其 Alpha 在任何地方都是 1.0。当此属性为 false 时,内存使用量和纹理上传时间都会减少。 Gets a value indicating whether or not the images provided by this imagery provider include an alpha channel. If this property is false, an alpha channel, if present, will be ignored. If this property is true, any images without an alpha channel will be treated as if their alpha is 1.0 everywhere. When this property is false, memory usage and texture upload time are reduced.

readonly maximumLevel : number|undefined

获取可以请求的最大详细程度。 Gets the maximum level-of-detail that can be requested.
获取可以请求的最低详细程度。通常,仅当图像的矩形足够小以致于最小级别的图块数量较小时才应使用最小级别。在最低级别上具有多个图块的图像提供程序将导致渲染问题。 Gets the minimum level-of-detail that can be requested. Generally, a minimum level should only be used when the rectangle of the imagery is small enough that the number of tiles at the minimum level is small. An imagery provider with more than a few tiles at the minimum level will lead to rendering problems.
获取此提供者使用的代理。 Gets the proxy used by this provider.
获取实例提供的图像的矩形(以弧度为单位)。 Gets the rectangle, in radians, of the imagery provided by the instance.
获取图块丢弃策略。如果未定义,则丢弃策略负责通过其 shouldDiscardImage 函数过滤掉“丢失”的图块。如果此函数返回未定义,则不会过滤任何图块。 Gets the tile discard policy. If not undefined, the discard policy is responsible for filtering out "missing" tiles via its shouldDiscardImage function. If this function returns undefined, no tiles are filtered.
获取每个图块的高度(以像素为单位)。 Gets the height of each tile, in pixels.
获取每个图块的宽度(以像素为单位)。 Gets the width of each tile, in pixels.
获取提供者使用的切片方案。 Gets the tiling scheme used by the provider.
获取 Google 2D 图像服务器的 URL。 Gets the URL of the Google 2D Imagery server.

方法 Methods

static Cesium.Google2DImageryProvider.fromIonAssetId(options)Promise.<Google2DImageryProvider>

创建一个 Creates an ImageryProvider 它提供 2D 全局平铺图像 which provides 2D global tiled imagery from Google 2D Tiles,使用Cesium离子 REST API 进行流式传输。 , streamed using the Cesium ion REST API.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
assetId string Cesium离子资产 ID。 The Cesium ion asset id.
mapType "satellite" | "terrain" | "roadmap" "satellite" 可选 optional Google 地图图像的地图类型。有效选项包括卫星、地形和路线图。如果设置了overlayLayerType,则忽略mapType并返回透明叠加层。如果overlayMapType未定义,则返回mapType的底图。图层路线图overlayLayerType包含在地形和路线图mapTypes中。 The map type of the Google map imagery. Valid options are satellite, terrain, and roadmap. If overlayLayerType is set, mapType is ignored and a transparent overlay is returned. If overlayMapType is undefined, then a basemap of mapType is returned. layerRoadmap overlayLayerType is included in terrain and roadmap mapTypes.
language string "en_US" 可选 optional IETF 语言标签,指定用于在图块上显示信息的语言 an IETF language tag that specifies the language used to display information on the tiles
region string "US" 可选 optional 表示用户物理位置的公共区域设置数据存储库区域标识符(两个大写字母)。 A Common Locale Data Repository region identifier (two uppercase letters) that represents the physical location of the user.
overlayLayerType "layerRoadmap" | "layerStreetview" | "layerTraffic" 可选 optional 返回具有指定图层类型的透明叠加图。如果未提供值,则返回 mapType 的底图。使用 Google2DImageryProvider 的多个实例将多个 Google 地图叠加层添加到场景中。 layerRoadmap 包含在地形和路线图的 mapTypes 中,因此作为叠加层添加到地形或路线图没有任何效果。 Returns a transparent overlay map with the specified layerType. If no value is provided, a basemap of mapType is returned. Use multiple instances of Google2DImageryProvider to add multiple Google Maps overlays to a scene. layerRoadmap is included in terrain and roadmap mapTypes, so adding as overlay to terrain or roadmap has no effect.
styles object 可选 optional 一组 JSON 样式对象,用于指定地图要素(例如道路、公园和建筑区域)的外观和详细程度。样式用于自定义标准 Google 底图。仅当mapType为roadmap时,styles参数才有效。有关完整的样式语法,请参阅 ( An array of JSON style objects that specify the appearance and detail level of map features such as roads, parks, and built-up areas. Styling is used to customize the standard Google base map. The styles parameter is valid only if the mapType is roadmap. For the complete style syntax, see the (Google Style Reference).
ellipsoid Ellipsoid Ellipsoid.default 可选 optional 椭球体。如果未指定,则使用默认椭球体。 The ellipsoid. If not specified, the default ellipsoid is used.
minimumLevel number 0 可选 optional 图像提供商支持的最低细节级别。指定此选项时请注意,最低级别的图块数量较小,例如四个或更少。数量过多可能会导致渲染问题。 The minimum level-of-detail supported by the imagery provider. Take care when specifying this that the number of tiles at the minimum level is small, such as four or less. A larger number is likely to result in rendering problems.
maximumLevel number 22 可选 optional 图像提供商支持的最大细节级别。 The maximum level-of-detail supported by the imagery provider.
rectangle Rectangle Rectangle.MAX_VALUE 可选 optional 图像覆盖的矩形(以弧度表示)。 The rectangle, in radians, covered by the image.
credit Credit | string 可选 optional 数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas.
返回: Returns:
解析为创建的 Google2DImageryProvider 的承诺。 A promise that resolves to the created Google2DImageryProvider.
示例: Examples:
// Google 2D imagery provider
const googleTilesProvider = Cesium.Google2DImageryProvider.fromIonAssetId({
    assetId: 3830184
});
// Google 2D roadmap overlay with custom styles
const googleTilesProvider = Cesium.Google2DImageryProvider.fromIonAssetId({
    assetId: 3830184,
    overlayLayerType: "layerRoadmap",
    styles: [
        {
            stylers: [{ hue: "#00ffe6" }, { saturation: -20 }],
        },
        {
            featureType: "road",
            elementType: "geometry",
            stylers: [{ lightness: 100 }, { visibility: "simplified" }],
        },
    ],
});

static Cesium.Google2DImageryProvider.fromUrl(options)Promise.<Google2DImageryProvider>

创建一个 Creates an ImageryProvider 它提供 2D 全局平铺图像 which provides 2D global tiled imagery from Google 2D Tiles.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
key string GoogleMaps.defaultApiKey 可选 optional 您用于访问 Google 2D Tiles 的 API 密钥。参见 Your API key to access Google 2D Tiles. See https://developers.google.com/maps/documentation/javascript/get-api-key 有关如何创建您自己的密钥的说明。 for instructions on how to create your own key.
mapType "satellite" | "terrain" | "roadmap" "satellite" 可选 optional Google 地图图像的地图类型。有效选项包括卫星、地形和路线图。如果设置了overlayLayerType,则忽略mapType并返回透明叠加层。如果overlayMapType未定义,则返回mapType的底图。图层路线图overlayLayerType包含在地形和路线图mapTypes中。 The map type of the Google map imagery. Valid options are satellite, terrain, and roadmap. If overlayLayerType is set, mapType is ignored and a transparent overlay is returned. If overlayMapType is undefined, then a basemap of mapType is returned. layerRoadmap overlayLayerType is included in terrain and roadmap mapTypes.
language string "en_US" 可选 optional IETF 语言标签,指定用于在图块上显示信息的语言 an IETF language tag that specifies the language used to display information on the tiles
region string "US" 可选 optional 表示用户物理位置的公共区域设置数据存储库区域标识符(两个大写字母)。 A Common Locale Data Repository region identifier (two uppercase letters) that represents the physical location of the user.
overlayLayerType "layerRoadmap" | "layerStreetview" | "layerTraffic" 可选 optional 返回具有指定图层类型的透明叠加图。如果未提供值,则返回 mapType 的底图。使用 Google2DImageryProvider 的多个实例将多个 Google 地图叠加层添加到场景中。 layerRoadmap 包含在地形和路线图的 mapTypes 中,因此作为叠加层添加到地形或路线图没有任何效果。 Returns a transparent overlay map with the specified layerType. If no value is provided, a basemap of mapType is returned. Use multiple instances of Google2DImageryProvider to add multiple Google Maps overlays to a scene. layerRoadmap is included in terrain and roadmap mapTypes, so adding as overlay to terrain or roadmap has no effect.
styles object 可选 optional 一组 JSON 样式对象,用于指定地图要素(例如道路、公园和建筑区域)的外观和详细程度。样式用于自定义标准 Google 底图。仅当mapType为roadmap时,styles参数才有效。有关完整的样式语法,请参阅 ( An array of JSON style objects that specify the appearance and detail level of map features such as roads, parks, and built-up areas. Styling is used to customize the standard Google base map. The styles parameter is valid only if the mapType is roadmap. For the complete style syntax, see the (Google Style Reference).
ellipsoid Ellipsoid Ellipsoid.default 可选 optional 椭球体。如果未指定,则使用默认椭球体。 The ellipsoid. If not specified, the default ellipsoid is used.
minimumLevel number 0 可选 optional 图像提供商支持的最低细节级别。指定此选项时请注意,最低级别的图块数量较小,例如四个或更少。数量过多可能会导致渲染问题。 The minimum level-of-detail supported by the imagery provider. Take care when specifying this that the number of tiles at the minimum level is small, such as four or less. A larger number is likely to result in rendering problems.
maximumLevel number 22 可选 optional 图像提供商支持的最大细节级别。 The maximum level-of-detail supported by the imagery provider.
rectangle Rectangle Rectangle.MAX_VALUE 可选 optional 图像覆盖的矩形(以弧度表示)。 The rectangle, in radians, covered by the image.
credit Credit | string 可选 optional 数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas.
返回: Returns:
解析为创建的 Google2DImageryProvider 的承诺。 A promise that resolves to the created Google2DImageryProvider.
示例: Examples:
// Use your own Google api key
Cesium.GoogleMaps.defaultApiKey = "your-api-key";

const googleTilesProvider = Cesium.Google2DImageryProvider.fromUrl({
    mapType: "satellite"
});
// Google 2D roadmap overlay with custom styles
Cesium.GoogleMaps.defaultApiKey = "your-api-key";

const googleTilesProvider = Cesium.Google2DImageryProvider.fromUrl({
    overlayLayerType: "layerRoadmap",
    styles: [
        {
            stylers: [{ hue: "#00ffe6" }, { saturation: -20 }],
        },
        {
            featureType: "road",
            elementType: "geometry",
            stylers: [{ lightness: 100 }, { visibility: "simplified" }],
        },
    ],
});

getTileCredits(x, y, level)Array.<Credit>|undefined

获取显示给定图块时要显示的积分。 Gets the credits to be displayed when a given tile is displayed.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖水平; The tile level;
返回: Returns:
显示图块时要显示的制作人员名单。 The credits to be displayed when the tile is displayed.

pickFeatures(x, y, level, longitude, latitude)undefined

该图像提供程序当前不支持选取要素,因此该函数仅返回 undefined。 Picking features is not currently supported by this imagery provider, so this function simply returns undefined.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖级别。 The tile level.
longitude number 选择要素的经度。 The longitude at which to pick features.
latitude number 选择特征的纬度。 The latitude at which to pick features.
返回: Returns:
未定义,因为不支持挑选。 Undefined since picking is not supported.

requestImage(x, y, level, request)Promise.<ImageryTypes>|undefined

请求给定图块的图像。 Requests the image for a given tile.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖级别。 The tile level.
request Request 可选 optional 请求对象。仅供内部使用。 The request object. Intended for internal use only.
返回: Returns:
对图像的承诺,该承诺将在图像可用时解析,或者如果对服务器的活动请求太多,则未定义,并且应稍后重试该请求。 A promise for the image that will resolve when the image is available, or undefined if there are too many active requests to the server, and the request should be retried later.

类型定义 Type Definitions

Cesium.Google2DImageryProvider.ConstructorOptions

Google2DImageryProvider 构造函数的初始化选项 Initialization options for the Google2DImageryProvider constructor
属性: Properties:
名称 Name 类型 Type Attributes 默认值 Default 说明 Description
key string 与图块请求一起发送的 Google api 密钥。 The Google api key to send with tile requests.
session string 用于跟踪地图和视口当前状态的 Google 会话令牌。 The Google session token that tracks the current state of your map and viewport.
url string | Resource | IonResource Google 2D 地图端点。 The Google 2D maps endpoint.
tileWidth string 每个图块的宽度(以像素为单位)。 The width of each tile in pixels.
tileHeight string 每个图块的高度(以像素为单位)。 The height of each tile in pixels.
ellipsoid Ellipsoid <可选> &lt;optional>
Ellipsoid.default 椭球体。如果未指定,则使用默认椭球体。 The ellipsoid. If not specified, the default ellipsoid is used.
minimumLevel number <可选> &lt;optional>
0 图像提供商支持的最低细节级别。指定此选项时请注意,最低级别的图块数量较小,例如四个或更少。数量过多可能会导致渲染问题。 The minimum level-of-detail supported by the imagery provider. Take care when specifying this that the number of tiles at the minimum level is small, such as four or less. A larger number is likely to result in rendering problems.
maximumLevel number <可选> &lt;optional>
22 图像提供商支持的最大细节级别。 The maximum level-of-detail supported by the imagery provider.
rectangle Rectangle <可选> &lt;optional>
Rectangle.MAX_VALUE 图像覆盖的矩形(以弧度表示)。 The rectangle, in radians, covered by the image.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.