Map

Map

地图Map对象实例

Constructor

new Map(containerID, options)

Parameters:
Name Type Description
containerID string

容器 id, 可设置为空, 后续用init方法设置

options StateProperty

地图初始化状态

Properties
Name Type Attributes Default Description
center Array <optional>

中心点坐标

zoom number <optional>

当前层级

minZoom number <optional>
1

最小层级

maxZoom number <optional>
18

最大层级

_ Config <optional>

配置项

Fires/事件:

Extends

Members

status

描述:
  • 获取地图状态

获取地图状态

Methods

addControl(ctl) → {this}

描述:
  • 添加控件

Parameters:
Name Type Description
ctl *
Returns:
Type
this

addLayer(obj) → {this}

描述:
  • 添加图层

Parameters:
Name Type Description
obj BaseLayer
Returns:
Type
this

callWhenReady(cb) → {Map}

描述:
  • 在地图准备好后触发

Parameters:
Name Type Description
cb function

需要触发的任务

Returns:

this

Type
Map

clearLayer() → {this}

描述:
  • 清空图层

Returns:
Type
this

createPattern(image, repetition) → {CanvasPattern}

描述:
  • 创建填充图案

Parameters:
Name Type Description
image *

Image对象

repetition *

repeat / repeat-x / repeat-y / no-repeat

Returns:
Type
CanvasPattern

destory()

描述:
  • 销毁画布

dilute(coords, threshold) → {Array}

描述:
  • 抽稀

Parameters:
Name Type Description
coords Array

经纬度坐标,二维数组

threshold Number

阈值 px

Returns:

结果

Type
Array

fitView(bounds, scaleopt, optionsopt)

描述:
  • 自适应区域

Parameters:
Name Type Attributes Default Description
bounds Array.<Array.<Array>>

边界坐标

scale Boolean <optional>
false

是否缩放

options Object <optional>
{}

选项

Properties
Name Type Attributes Default Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

reverse Boolean <optional>

缩放反转

zoomStep Number <optional>
0.2

回退层级

getActivateEditor() → {Object}

描述:
  • 获取当前激活的编辑器对象

Returns:
Type
Object

getAllLayer() → {Array}

描述:
  • 获取所有图层

Returns:
Type
Array

getLayer(id)

描述:
  • 获取图层

Parameters:
Name Type Description
id *

getProjection() → {Object}

描述:
  • 获取当前坐标系

Returns:
Type
Object

init(containerID) → {Map}

描述:
  • 初始化地图

Parameters:
Name Type Description
containerID string

容器id

Returns:

this

Type
Map

lngLat2px(lng, lat) → {Array}

描述:
  • 经纬度转像素

Parameters:
Name Type Description
lng Number
lat Number
Returns:

px

Type
Array

measureArea(coords) → {Number}

描述:
  • 测量面积

Parameters:
Name Type Description
coords Array

经纬度坐标

Returns:

平方米

Type
Number

measureRule(coords) → {Number}

描述:
  • 测量距离

Parameters:
Name Type Description
coords Array

经纬度坐标

Returns:

Type
Number

measureText(font, text) → {Number}

描述:
  • 字体宽度

Parameters:
Name Type Description
font String

字体样式

text String

字体内容

Returns:

宽度

Type
Number

meter2px(m) → {Number}

描述:
  • 米当前层级转换成像素

Parameters:
Name Type Description
m *
Returns:

px

Type
Number

off(type, listener)

描述:
  • 取消监听事件

Overrides:
Parameters:
Name Type Description
type Array | string

事件类型

listener function

回调函数

on(type, listener, once)

描述:
  • 绑定事件监听

Overrides:
Parameters:
Name Type Description
type Array | string
listener function

回调函数

once boolean

一次

once(type, listener)

描述:
  • 绑定一次事件监听

Overrides:
Parameters:
Name Type Description
type Array | string

事件类型

listener function

回调函数

panBy(px, zoom, options) → {Object}

描述:
  • 偏移像素

Parameters:
Name Type Description
px Array

[x, y]

zoom Number | Null

层级

options Object

选项

Properties
Name Type Attributes Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

Returns:

当前动画对象, 可调用 stop()

Type
Object

panTo(center, zoom, options) → {Object}

描述:
  • 移动到

Parameters:
Name Type Description
center Array

中心点

zoom Number | Null

层级

options Object

选项

Properties
Name Type Attributes Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

Returns:

当前动画对象, 可调用 stop()

Type
Object

playback(options) → {Object}

描述:
  • 动画播放

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
data Array <optional>

路径坐标

duration Number <optional>

持续时间

parseData function <optional>

解析data数据,返回object

onUpdate function <optional>

更新时回调

onComplete function <optional>

结束时回调

onDuration function <optional>

每帧计算时间时回调

Returns:

动画停止函数 { stop: function }

Type
Object

polygon_centroid(coords, intersect) → {Array}

描述:
  • 多边形质心

Parameters:
Name Type Description
coords *

坐标点

intersect boolean

在屏幕可见部分计算

Returns:
Type
Array

polyline_centroid(coords, intersect) → {Array}

描述:
  • 折线质心

Parameters:
Name Type Description
coords Array

坐标点

intersect boolean

在屏幕可见部分计算

Returns:
Type
Array

px2lngLat(x, y) → {Array}

描述:
  • 像素转经纬度

Parameters:
Name Type Description
x Number
y Number
Returns:

lnglat

Type
Array

px2meter(px) → {Number}

描述:
  • 像素当前层级转换米

Parameters:
Name Type Description
px *
Returns:

m

Type
Number

redraw()

描述:
  • 重绘所有图层

refresh()

描述:
  • 刷新所有图层

removeControl(ctl) → {this}

描述:
  • 删除控件

Parameters:
Name Type Description
ctl *
Returns:
Type
this

removeLayer(obj) → {this}

描述:
  • 删除图层

Parameters:
Name Type Description
obj BaseLayer
Returns:
Type
this

repeat(options) → {Object}

描述:
  • 重复动画

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
from Number <optional>

初始值

to Number <optional>

终点值

onUpdate function <optional>

更新时回调

Returns:

动画停止函数 { stop: function }

Type
Object

resize()

描述:
  • 重置画布大小

描述:
  • 在范围内搜索覆盖物

Parameters:
Name Type Description
part Object
Properties
Name Type Attributes Default Description
type String <optional>

类型 circle/ path

coords Array <optional>

坐标 circle: [lng,lat] / path: [[lng,lat], ]

radius Number <optional>

半径 circle: m 单位米

full Boolean <optional>
false

覆盖物需全处于范围内 Polygon Polyline

Returns:
Type
Array

setLimitArea(bounds) → {this}

描述:
  • 设置显示范围

Parameters:
Name Type Description
bounds Array

边界坐标[[left,top],[right,bottom]]

Returns:
Type
this

setMask(options) → {this}

描述:
  • 设置遮罩

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
coords Array <optional>

遮罩坐标

style StyleProperty <optional>

遮罩样式

Returns:
Type
this

setSpatialReference(ref)

描述:
  • 设置坐标系

Parameters:
Name Type Description
ref Object
Properties
Name Type Attributes Default Description
projection String <optional>
'EPSG:3857'

setZoom(zoom, options)

描述:
  • 设置层级

Parameters:
Name Type Description
zoom Number

层级

options Object

选项

Properties
Name Type Attributes Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

toDataURL() → {String}

描述:
  • 导出图片

Returns:
Type
String

tryPickObj(x, y) → {Array}

描述:
  • 拾取所有可拾取覆盖物

Parameters:
Name Type Description
x Number
y Number
Returns:
Type
Array

zoomIn(step, options)

描述:
  • 放大

Parameters:
Name Type Description
step number

层级

options Object

选项

Properties
Name Type Attributes Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

zoomOut(step, options)

描述:
  • 缩小

Parameters:
Name Type Description
step number

层次

options Object

选项

Properties
Name Type Attributes Description
duration Number <optional>

动画时间

onComplete function <optional>

动画结束回调

Events

blankfocus

描述:
  • 空白处点击事件

Properties:
Name Type Description
type String

blankfocus

target Map
Type:
  • Object

click

描述:
  • 地图点击

Properties:
Name Type Description
type String

click

target Map
Type:
  • Object

complete

描述:
  • 地图加载完成

Properties:
Name Type Description
type String

complete

target Map
Type:
  • Object

dblclick

描述:
  • 地图双击

Properties:
Name Type Description
type String

dblclick

target Map
Type:
  • Object

destory

描述:
  • 地图销毁

Properties:
Name Type Description
type String

destory

target Map
Type:
  • Object

move

描述:
  • 地图移动

Properties:
Name Type Description
type String

move

target Map
Type:
  • Object

out

描述:
  • 移出地图

Properties:
Name Type Description
type String

out

target Map
Type:
  • Object

over

描述:
  • 移入地图

Properties:
Name Type Description
type String

over

target Map
Type:
  • Object