# Class: Service

Service 服务类.

# Table of contents

# Constructors

# Properties

# Methods

# Constructors

# constructor

+ new Service(url: string, token?: string, req?: IRequest): Service

构造函数

# Parameters
Name Type Description
url string 服务地址
token? string 访问凭证
req? IRequest 请求的方法实现(默认内部实现)

Returns: Service

# Properties

# accessToken

accessToken: string= ""

访问凭证


# serverUrl

serverUrl: string= ""

服务器地址

# Methods

# baseUrl

baseUrl(): string

服务根地址

Returns: string


# blankTileUrl

blankTileUrl(): string

空白瓦片地址

Returns: string


# checkFileHasUpload

checkFileHasUpload(filemd5: string): Promise<any>

检查文件是否上传过

# Parameters
Name Type Description
filemd5 string 文件md5值

Returns: Promise<any>


# clearCache

clearCache(prefix?: string): Promise<{}>

清空服务器缓存数据

# Parameters
Name Type Default value Description
prefix string "" key前缀

Returns: Promise<{}>


# cmdClearMapCache

cmdClearMapCache(mapid: string, version: string): Promise<any>

清空地图的几何和瓦片缓存数据

# Parameters
Name Type Description
mapid string 地图ID
version string 版本号

Returns: Promise<any>


# cmdClearTileCache

cmdClearTileCache(mapid: string, version: string): Promise<any>

清空地图的瓦片缓存数据

# Parameters
Name Type Description
mapid string 地图ID
version string 版本号

Returns: Promise<any>


# cmdDeleteCache

cmdDeleteCache(param: IDeleteCache): Promise<any>

删除地图缓存

# Parameters
Name Type Description
param IDeleteCache 缓存接口

Returns: Promise<any>


# cmdDeleteMap

cmdDeleteMap(mapid: string, version: string): Promise<any>

删除地图

# Parameters
Name Type Description
mapid string 地图ID
version string 版本号,如删除所有版本,输入"*"号

Returns: Promise<any>


# cmdDeleteStyle

cmdDeleteStyle(param: IDeleteStyle): Promise<any>

删除地图样式

# Parameters
Name Type Description
param IDeleteStyle 样式接口

Returns: Promise<any>


# cmdRunStatus

cmdRunStatus(bDetail?: boolean): Promise<any>

获取当前运行状态

# Parameters
Name Type Description
bDetail? boolean 是否需要细节 (默认false)

Returns: Promise<any>


# cmdSliceLayer

cmdSliceLayer(param: ISliceLayer): Promise<any>

对图层进行切片缓存

# Parameters
Name Type
param ISliceLayer

Returns: Promise<any>


# cmdSwitchLayers

cmdSwitchLayers(visibleLayers: string[]): Promise<any>

切换图层

# Parameters
Name Type Description
visibleLayers string[] 让可见的图层列表数组

Returns: Promise<any>


# cmdUpdateStyle

cmdUpdateStyle(param: IUpdateStyle): Promise<any>

更新样式

# Parameters
Name Type Description
param IUpdateStyle 样式参数

Returns: Promise<any>

Example:

const res = svc.cmdUpdateStyle({
    name: "style1",
    layeron: [0,1,2,4,5,6,7,8,9],
    layeroff: "",
    clipbounds: "",
    backcolor: 0,
    lineweight:[1,1,0]
    expression: "gOutColorRed := gInColorGreen;gOutColorGreen := gInColorBlue;gOutColorBlue := gInColorRed;gOutColorAlpha := gInColorAlpha;"
});
1
2
3
4
5
6
7
8
9

# composeNewMap

composeNewMap(param: IComposeNewMap | IComposeNewMap[]): Promise<any>

组合成新地图

# Parameters
Name Type Description
param IComposeNewMap | IComposeNewMap[] 组合参数

Returns: Promise<any>


# conditionQueryFeature

conditionQueryFeature(param: IConditionQueryFeatures): Promise<any>

条件查询实体

# Parameters
Name Type Description
param IConditionQueryFeatures 参数

Returns: Promise<any>


# createStyle

createStyle(style: IMapStyleParam, mapid?: string, version?: string, isGeomLayer?: boolean): Promise<any>

获取样式图层名

# Parameters
Name Type Description
style IMapStyleParam 样式参数
mapid? string 地图ID
version? string 版本号,为空,则获取最新的;
isGeomLayer? boolean 几何渲染图层优先(默认true)

Returns: Promise<any>


# currentMapParam

currentMapParam(): null | IOpenMapResponse

当前地图参数

Returns: null | IOpenMapResponse


# execCommand

execCommand(cmdname: string, param?: Record<string, any>, mapid?: string, version?: string, useGet?: boolean): Promise<any>

执行命令

# Parameters
Name Type
cmdname string
param? Record<string, any>
mapid? string
version? string
useGet? boolean

Returns: Promise<any>


# exprQueryFeature

exprQueryFeature(param: IExprQueryFeatures): Promise<any>

表达式查询实体

# Parameters
Name Type Description
param IExprQueryFeatures 参数

Returns: Promise<any>


# fileMd5

fileMd5(file: File): Promise<any>

获取文件的Md5值

# Parameters
Name Type
file File

Returns: Promise<any>


# getConstData

getConstData(): Promise<any>

获取服务后台常量设置

Returns: Promise<any>


# getFontsCapacity

getFontsCapacity(): Promise<{}>

得到所有矢量字体名称

Returns: Promise<{}>


# getMapLayers

getMapLayers(): IMapLayer[]

得到地图图层集合,调用前请确保地图已打开,否则会抛异常

Returns: IMapLayer[]


# getSliceCacheZoom

getSliceCacheZoom(param: ISliceCacheZoom): Promise<any>

获取已缓存的切片级别

# Parameters
Name Type Description
param ISliceCacheZoom 参数

Returns: Promise<any>


# getStyleLayerName

getStyleLayerName(mapid: string, version?: string, isGeomLayer?: boolean, name?: string): Promise<any>

获取样式图层名

# Parameters
Name Type Description
mapid string 地图ID
version? string 版本号,为空,则获取最新的;
isGeomLayer? boolean 几何渲染图层优先(默认true)
name? string 有名称时,根据名称来查找;

Returns: Promise<any>


# glyphsUrl

glyphsUrl(): string

字体地址

Returns: string


# listMaps

listMaps(mapid?: string, version?: string): Promise<any>

获取所有地图信息

# Parameters
Name Type Default value Description
mapid string "_" 地图ID,为空,则获取所有的
version string "_" 版本号,为空,则获取最新的; * 则获取所有的版本

Returns: Promise<any>


# metadata

metadata(mapid?: string, version?: string): Promise<any>

获取地图元数据

# Parameters
Name Type Description
mapid? string 地图ID ,为空, 则为当前打开的图形
version? string 版本号,为空 则为当前打开的版本;

Returns: Promise<any>


# openMap

openMap(param: IOpenMapParam, isWaitFinish?: boolean): Promise<any>

打开图

# Parameters
Name Type Default value Description
param IOpenMapParam -
isWaitFinish boolean true 是否等待打开完成

Returns: Promise<any>


# pointQueryFeature

pointQueryFeature(param: IPointQueryFeatures): Promise<any>

点查询实体

# Parameters
Name Type Description
param IPointQueryFeatures 参数

Returns: Promise<any>


# rasterBlankStyle

rasterBlankStyle(minzoom?: number, maxzoom?: number, prefix?: string): Style

空白栅格style

# Parameters
Name Type Description
minzoom? number 最小级别,缺省0
maxzoom? number 最大级别,缺省24
prefix? string 前缀,缺省rasterBlank

Returns: Style


# rasterLayerId

rasterLayerId(prefix?: string): string

获取栅格图层ID

# Parameters
Name Type
prefix? string

Returns: string


# rasterSourceId

rasterSourceId(prefix?: string): string

获取栅格源ID

# Parameters
Name Type
prefix? string

Returns: string


# rasterStyle

rasterStyle(tileUrl?: string, minzoom?: number, maxzoom?: number, prefix?: string): Style

栅格style

# Parameters
Name Type Description
tileUrl? string 栅格瓦片地址
minzoom? number 最小级别,缺省0
maxzoom? number 最大级别,缺省24
prefix? string 前缀,缺省raster

Returns: Style


# rasterTileUrl

rasterTileUrl(param?: ITileUrlParam): string

栅格瓦片地址

# Parameters
Name Type Default value
param ITileUrlParam {}

Returns: string


# rectQueryFeature

rectQueryFeature(param: IRectQueryFeatures): Promise<any>

矩形查询实体

# Parameters
Name Type Description
param IRectQueryFeatures 参数

Returns: Promise<any>


# serviceUrl

serviceUrl(u: string): string

得到服务地址

# Parameters
Name Type Description
u string 要拼接的地址

Returns: string

string


# setCurrentMapParam

setCurrentMapParam(param: IOpenMapResponse): null | IOpenMapResponse

设置打开地图参数

# Parameters
Name Type
param IOpenMapResponse

Returns: null | IOpenMapResponse


# setSprite

setSprite(name: string): string

设置精灵图片名称

# Parameters
Name Type Description
name string 精灵名称

Returns: string


# spriteUrl

spriteUrl(name: string): string

精灵图片名称

# Parameters
Name Type Description
name string 精灵名称

Returns: string


# strMd5

strMd5(str: string): string

获取字符串的Md5值

# Parameters
Name Type
str string

Returns: string


# styleVersion

styleVersion(): number

得到style的版本号

Returns: number


# thumbnailUrl

thumbnailUrl(mapid?: string, version?: string, width?: number, height?: number): string

获取图的缩略图

# Parameters
Name Type
mapid? string
version? string
width? number
height? number

Returns: string


# toLayerIndex

toLayerIndex(layernames: string[], layers: any[]): number[]

把图层名称数组转成图层索引数组

# Parameters
Name Type Description
layernames string[] 图层名称数组
layers any[] 图层列表

Returns: number[]


# updateMap

updateMap(param: IUpdateMapParam, isWaitFinish?: boolean): Promise<any>

更新地图

# Parameters
Name Type Default value Description
param IUpdateMapParam -
isWaitFinish boolean true 是否等待打开完成

Returns: Promise<any>


# uploadMap

uploadMap(file: File): Promise<any>

上传地图

# Parameters
Name Type
file File

Returns: Promise<any>


# uploadUrl

uploadUrl(): string

返回上传文件的url地址

Returns: string


# vectorStyle

vectorStyle(tileUrl?: string | Record<string, any>, minzoom?: number, maxzoom?: number, prefix?: string, hoverColor?: string, hoverOpacity?: number, hoverLineWidth?: number, customColorCaseExpr?: any[], customOpacityCaseExpr?: any[], customLineWidthCaseExpr?: any[]): Style

矢量style

# Parameters
Name Type Description
tileUrl? string | Record<string, any> 矢量瓦片地址 或者为一个Object,为Object时,设置项为参数的每个项值,做为一个参数传入
minzoom? number 最小级别,缺省0
maxzoom? number 最大级别,缺省24
prefix? string 前缀,缺省vector
hoverColor? string 高亮时颜色,缺省rgba(0,0,255,255)
hoverOpacity? number 高亮时透明度,缺省0.5
hoverLineWidth? number 高亮时线宽,缺省3
customColorCaseExpr? any[] 自定义颜色表达式,必须为数组,如[['==', ['feature-state', 'status'], 'alarm'], '#ff0000', ['==', ['feature-state', 'status'], 'normal'], '#00ff00'],缺省默认
customOpacityCaseExpr? any[] 自定义透明度表达式,必须为数组,缺省默认
customLineWidthCaseExpr? any[] 自定义线宽表达式,必须为数组,缺省默认

Returns: Style


# vectorTileUrl

vectorTileUrl(param?: ITileUrlParam): string

矢量瓦片地址

# Parameters
Name Type Default value
param ITileUrlParam {}

Returns: string


# waitMapOpenFinish

waitMapOpenFinish(mapid: string, version: string, tryTime?: number, maxTryTimes?: number): Promise<any>

等待地图打开完成

# Parameters
Name Type Default value Description
mapid string - 地图ID
version string - 地图版本号
tryTime number 5 每次尝试时间间隔(秒)
maxTryTimes number 120 最大尝试次数

Returns: Promise<any>


# webMapUrl

webMapUrl(tileProvider: { FourParameterAfter?: string ; FourParameterBefore?: string ; MapBounds?: string ; Srs?: string ; tileCrs?: "gcj02" | "wgs84" ; tileFlipY?: boolean ; tileMaxZoom?: number ; tileRetina?: number ; tileShards?: string ; tileSize?: number ; tileToken?: string | string[] ; tileUrl: string | string[] }): string

获取服务器地图服务地址

# Parameters
Name Type
tileProvider object
tileProvider.FourParameterAfter? string
tileProvider.FourParameterBefore? string
tileProvider.MapBounds? string
tileProvider.Srs? string
tileProvider.tileCrs? "gcj02" | "wgs84"
tileProvider.tileFlipY? boolean
tileProvider.tileMaxZoom? number
tileProvider.tileRetina? number
tileProvider.tileShards? string
tileProvider.tileSize? number
tileProvider.tileToken? string | string[]
tileProvider.tileUrl string | string[]

Returns: string


# wmsTileUrl

wmsTileUrl(param: IWmsTileUrl): string

# Parameters
Name Type
param IWmsTileUrl

Returns: string

vjmap / Exports / SkyLayer