Class: FMMap

FMMap

FMMap 是加载、显示、操作地图的主类,一个页面中至少需要包含一个FMMap对象

new fengmap.FMMap(options)

构造FMMap类

Name Type Description
options Object

FMMap可配置参数

Name Type Description
appName string

appName 必填

key string

key 必填

mapID string

mapID 必填

container Dom

地图容器 必填

mapURL string

地图数据资源路径

themeURL string

地图主题资源路径

themeID string

地图默认主题ID,默认值:'2001'

themeExtension json

主题扩展

backgroundColor int

地图背景色

backgroundAlpha number

地图背景透明度

nonFocusAlphaMode boolean

非聚焦楼层的透明模式,默认值:true

nonFocusAlpha number

非聚集楼层的透明度,默认值:0.1

tiltAngle number

地图默认的倾斜角度

maxTiltAngle number

地图默认最大倾斜角度

minTiltAngle number

地图默认最小倾斜角度

highlightColor int

模型高亮的颜色,默认值:0xF76232

zoomRange Array

比例尺缩放级别(可调范围为1-29),默认值:[16,23]

mapZoom number

地图默认缩放级别,默认值:20

visibleLevels Array

地图默认显示楼层可多层显示,默认值:[1]

level number

地图默认聚焦楼层,默认值:1

logarithmicDepthBuffer boolean

是否开启对数深度缓存,用以解决较大场景下的闪面问题,但可能导致性能下降,默认值:false

tile boolean

是否分层加载,默认值:true

preLoad boolean

是否预加载,默认值:true

floorSpace number

默认的层间距 默认值:50

viewMode fengmap.FMViewMode

视图模式 默认值:fengmap.FMViewMode.MODE_3D

highlightMode fengmap.FMHighlightMode

高亮模式

lock boolean

true 锁定交互(不可交互) false 不锁定交互(可以交互) 默认 false

Methods

autoRotate(){fengmap.FMAnimation}

地图自动旋转

Name Type Description
options.duration number

地图旋转一周所需时间

Returns:
Type Description
fengmap.FMAnimation 动画单元

clearThemeExtension()

清空主题扩展

dispose()

废置地图对象

getBound(){Object}

获取地图界限

Returns:
Name Type Description
bound Object 界限
Name Type Description
max Object 最大坐标
Name Type Description
x number 最大x坐标
y number 最大y坐标
min Object 最小坐标
Name Type Description
x number 最小x坐标
y number 最小y坐标
center Object 中心坐标
Name Type Description
x number 中心x坐标
y number 中心y坐标
size Object 尺寸
Name Type Description
x number x方向尺寸
y number y方向尺寸

getCenter(){Object}

获取视图中心的地图坐标

Returns:
Type Description
Object 地图坐标

getFloor(level){fengmap.FMFloor}

获取楼层

Name Type Description
level int

楼层等级

Returns:
Type Description
fengmap.FMFloor 楼层

getFloorSpace(){number}

获取楼层间距

Returns:
Type Description
number 楼层间距

getInteracations(){Object}

获取地图交互控制器

Returns:
Type Description
Object 交互控制器

getLevel(){number}

获取地图聚焦楼层等级

Returns:
Type Description
number 楼层等级

getLevels(){Array}

获取地图所有楼层等级

Returns:
Type Description
Array 楼层等级

getMarkerGroup(){Object}

获取地图覆盖物组

Returns:
Type Description
Object 地图覆盖物组

getNodes(results){Object}

获取地图节点

Name Type Description
results Object
Returns:
Type Description
Object 地图节点

getRenderOrder(){Array}

获取部分覆盖物的渲染顺序

Returns:
Type Description
Array 渲染顺序

getRotation(){int}

获取地图旋转角度

Returns:
Type Description
int 地图旋转角度

getState(){Object}

获取地图状态

Returns:
Name Type Description
state Object 地图状态
Name Type Description
center Object 视图中心的地图坐标
Name Type Description
x number 视图中心的地图 x 坐标
y number 视图中心的地图 y 坐标
zoom number 地图缩放级别
rotation number 地图旋转角度
tilt number 地图倾斜角度
viewMode int 视图模式
level int 聚焦楼层等级
floorSpace number 楼层间距

getTilt(){int}

获取地图倾斜角度

Returns:
Type Description
int 地图倾斜角度

getViewMode(){int}

获取视图模式

Returns:
Type Description
int 视图模式

getVisibleLevels(){Array}

获取显示楼层

Returns:
Type Description
Array 显示楼层数组

getZoom(){number}

获取地图当前缩放级别

Returns:
Type Description
number 缩放级别

getZoomRange(){Array}

获取地图缩放级别范围

Returns:
Type Description
Array 缩放级别范围

off(type, callback)

地图事件注销

Name Type Description
type string

事件类型

callback function

回调函数

on(type, callback)

地图事件注册

Name Type Description
type string

事件类型

callback function

回调函数

pickFilterFunction(){boolean}

过滤设置可点击拾取函数。可通过过滤设置模型的可点击拾取和不可点击拾取。

Returns:
Type Description
boolean 该方法返回true表示支持点击拾取,false表示不可点击拾取
Example
//过滤不允许点击的地图元素,设置为true为允许点击,设置为false为不允许点击
map.pickFilterFunction = function (event) {
   return event.type !== fengmap.FMType.MODEL;
}

setBackgroundColor(color, alpha)

设置地图背景颜色

Name Type Description
color int | string

颜色值0xFF0000 | '#FF0000'

alpha number

透明度,取值范围:0.0 - 1.0

setCenter(options)

设置视图中心的地图坐标

Name Type Description
options Object

地图移动参数

Name Type Description
x number

地图x坐标

y number

地图y坐标

animate boolean

是否开启动画,true:开启;false:不开启.默认不开启

duration number

动画持续时间

finish function

动画完成回调函数

setFitView(bound)

设置合适的视图

Name Type Description
bound Object

setFloorSpace(value)

楼层间距

Name Type Description
value number

间距

setLabelField(labelField)

设置label显示的字段

Name Type Description
labelField fengmap.FMLabelField

label显示的字段,默认 fengmap.FMLabelField.NAME

setLevel(options)

设置地图聚焦楼层等级

Name Type Description
options Object

设置聚焦楼层参数

Name Type Description
level int

楼层等级

animate boolean

是否开启动画,true:开启;false:不开启.默认开启

duration number

动画持续时间

finish function

动画完成回调函数

setRenderOrder(array)

设置渲染顺序(只能调整部分覆盖物的顺序)

Name Type Description
array Array

setRotation(options)

旋转地图到指定角度

Name Type Description
options Object

旋转参数

Name Type Description
rotation int

旋转角度

animate boolean

是否开启动画,true:开启;false:不开启.默认不开启

duration number

动画持续时间

finish function

动画完成回调函数

setState(state)

设置地图状态

Name Type Description
state Object

地图状态

Name Type Description
center Object

视图中心的地图坐标

Name Type Description
x number

视图中心的地图 x 坐标

y number

视图中心的地图 y 坐标

zoom number

地图缩放级别

rotation number

地图旋转角度

tilt number

地图倾斜角度

viewMode int

视图模式

level int

聚焦楼层等级

floorSpace number

楼层间距

setTheme(themeID)

设置主题

Name Type Description
themeID string

setThemeExtension(json)

设置主题扩展

Name Type Description
json data

主题数据

setTilt(options)

倾斜地图到指定角度

Name Type Description
options Object

倾斜参数

Name Type Description
tilt int

倾斜角度

animate boolean

是否开启动画,true:开启;false:不开启.默认不开启

duration number

动画持续时间

finish function

动画完成回调函数

setViewMode(options)

设置视图模式

Name Type Description
options Object
Name Type Description
mode int

视图模式

animate int

是否开启动画,默认 true

finish int

完成回调

Example
setViewMode({mode:fengmap.FMViewMode.MODE_3D})

setVisibleLevels(levels, callback)

设置显示楼层

Name Type Description
levels Array

楼层id数组

callback function

回调函数

Example
setVisibleFloors([1,2]);

setZoom(options)

缩放地图到指定级别

Name Type Description
options Object

地图缩放参数

Name Type Description
zoom number

地图缩放级别

animate boolean

是否开启动画,true:开启;false:不开启.默认不开启

duration number

动画持续时间

finish function

动画完成回调函数

setZoomRange(缩放级别范围)

设置地图缩放级别范围

Name Type Description
缩放级别范围 Array
Example
setZoomRange([16,20]);

zoomIn()

放大地图

zoomOut()

缩小地图

Events

click

鼠标点击事件

Example
{
 type:'click', // 事件类型
 coords:{x:12619616.66,y:2621878.60}, // 点击到的地图坐标
 mouseEvent:{}, // MouseEvent 鼠标事件
 targets:[], // 所有点击到的地图节点(按距离排序)
}

hover

鼠标划过事件

levelChanged

聚焦楼层改变事件

loaded

地图加载完成事件

move

地图移动事件

update

地图更新事件

viewChanged

视图改变事件

viewModeChanged

视图模式改变事件

visibleLevelsChanged

地图可见楼层改变事件

visibleLevelsLoaded

地图可见楼层加载完成事件

zoom

地图缩放事件