Class: Util

Util

Util类,放置一些常用的方法

new Util()

utils/Util.js, line 37

Classes

Util

Methods

staticUtil.calculateExtent(points){Array}

utils/Util.js, line 324

根据坐标串数组计算其矩形边界坐标

Name Type Description
points Array

坐标串数组[[lng1,lat1],[lng2,lat2],...]

Returns:
Type Description
Array 边界坐标数组 [xMin, yMin, xMax, yMax]

staticUtil.calculateExtentCenter(points){Array}

utils/Util.js, line 347

根据坐标串数组计算其几何中心

Name Type Description
points Array

坐标串数组[[lng1,lat1],[lng2,lat2],...]

Returns:
Type Description
Array 几何中心坐标

staticUtil.clipLayer(layer, bounds, map)

utils/Util.js, line 103

使用指定的边界坐标裁剪图层

Name Type Description
layer Layer

需要裁剪的图层对象,注意如果图层没有指定className,则会裁切所有默认className的图层

bounds Array

指定裁剪的边界坐标,[[lng1, lat1], [lng2, lat2]...]

map Map

图层所在的map对象

staticUtil.defineBaiduProjection(){Projection}

utils/Util.js, line 142

自定义百度坐标系,其中包含百度经纬度和百度墨卡托

Returns:
Type Description
Projection projection 新百度坐标系

staticUtil.defineProjection(projCode, proj4def){proj}

utils/Util.js, line 129

自定义坐标系

Name Type Description
projCode String

// 查找坐标系定义得到 http://epsg.io/ ,如:"EPSG:4490"

proj4def String

// 查找坐标系定义得到 http://epsg.io/,如: "+proj=longlat +ellps=GRS80 +no_defs"

Returns:
Type Description
proj projection 新坐标系

staticUtil.getAMapAPI(plugin, ak){Promise.<AMap>}

utils/Util.js, line 215

获取高德API

Name Type Default Description
plugin String "AMap.CitySearch,AMap.Geolocation" optional

高德地图插件

ak String 6972df398c90eb2344b101589ddf718d

高德Web端开发秘钥,有默认值

Returns:
Type Description
Promise.<AMap> 返回AMap对象

staticUtil.getBMapAPI(ak){Promise.<BMap>}

utils/Util.js, line 186

获取百度API

Name Type Default Description
ak String sDgF8hpW3e91kCBkKxb1l4rHSOuOoqXg

百度API开发秘钥

Returns:
Type Description
Promise.<BMap> 返回BMap对象

staticUtil.getDistance(c1, c2, opt_radius){number}

utils/Util.js, line 300

根据两个地理坐标求取大圆距离(单位:米)

Name Type Description
c1 Array

起点

c2 Array

终点

opt_radius number

使用的大圆半径 默认使用WGS84椭球体的平均半径

Returns:
Type Description
number 返回两点的大圆距离 (单位:米).

staticUtil.getTMapAPI(tk){Promise.<TMap>}

utils/Util.js, line 246

获取天地图API

Name Type Default Description
tk String fc499b3b4c71b6e0495ae7b3f98f337e

天地图API开发秘钥,有默认值

Returns:
Type Description
Promise.<TMap> 返回TMap对象

staticUtil.idw_GridFeatureCollection(lngs, lats, values, options){geojson}

utils/Util.js, line 76

使用反距离插值算法生成格点数据,用于绘制等值面

Name Type Description
lngs Array

经度数组

lats Array

纬度数组

values Array

数值数组

options Object

其他可选属性

Name Type Default Description
extent Array

网格范围 [xMin,yMin,xMax,yMax]

divide Number 190 optional

xy 方向切分网格数

count Number 12 optional

插值点数/按距离插值时作为最小点数

radius Number optional

插值距离,传值就采用按距离插值

Returns:
Type Description
geojson 格点数据

staticUtil.loadJS(src, callback)

utils/Util.js, line 273

异步加载一个js文件/js API

Name Type Description
src String

js资源路径

callback function

js资源加载完的回调函数

staticUtil.setFeatureStyle(feature, options)

utils/Util.js, line 360

设置要素的样式

Name Type Description
feature Feature

要素

options Object

样式参数

Name Type Description
stroke strokeOptions

边界样式

fill FillOptions

填充样式