开发 室内地图 JS API 开发指南 其他功能 事件对象

事件对象 最后更新时间: 2021年01月22日

事件方法

示例

map.on('click', function(e) {
alert(e.latlng);
});

也可以传入处理函数名:

function onClick(e) { ... }
map.on('click', onClick);
map.off('click', onClick);

方法

Method

returns

Description

addEventListener( <String> type,

<Function> fn,<Object> context? )

this

注册事件(事件类型,处理函数,传递参数)

(e.g.'click dblclick').

addOneTimeEventListener( <String> type,

<Function> fn,<Object> context? )

this

注册只执行一次的事件.

addEventListener( <Object> eventMap,

<Object> context? )

this

注册事件(事件类型,对象)

e.g. {click: onClick, mousemove: onMouseMove}

removeEventListener( <String> type,

<Function> fn?,<Object> context? )

this

清除对象事件(事件,处理程序,传递参数).

removeEventListener( <Object> eventMap,

<Object> context? )

this

清除对象事件(事件,处理程序).

hasEventListeners( <String> type )

Boolean

判断事件是否已经注册.

fireEvent( <String> type,

<Object> data? )

this

触发事件(事件类型,对象,传递参数?).

on( … )

this

addEventListener的简写.

once( … )

this

addOneTimeEventListener的简写.

off( … )

this

removeEventListener的简写.

fire( … )

this

fireEvent的简写.

事件对象

示例

map.on('click', function(e) {
    alert(e.latlng); // e is an event object (MouseEvent in this case)
});

Event 事件

Property

Type

Description

type

String

事件类型 (e.g. 'click').

target

Object

触发的对象.

鼠标 事件

Property

Type

Description

latlng

LatLng

鼠标事件传递地理坐标.

layerPoint

Point

鼠标事件传递图层点坐标..

containerPoint

Point

鼠标事件传递相对于地图的点坐标.

originalEvent

DOMMouseEvent

触发浏览器原始的DOM事件.

DragEndEvent 事件

Property

Type

Description

distance

Number

拖拽事件.

商铺/设施 事件

Property

Type

Description

ft_sourceid

String

唯一id标识.

ft_typecode

String

分类id.

ft_amap_type

String

amap分类id.

ft_name_cn

String

中文名称.

floor

Number

所在楼层.

centroid

Array

中心点.[纬度,经度]

示例
中心
常见
问题
智能
客服