Class: FMNavigation

FMNavigation

FMNavigation 是导航相关的功能类, 可用于模拟导航和真实导航使用。

new fengmap.FMNavigation(options)

Name Type Description
options json
Name Type Description
map fengmap.FMMap

导航类关联地图对象, 必要参数, 不可缺失。

naviLanguage fengmap.FMLanguageType

导航结果文字描述内容的语言类型参数, 目前支持中英文。参考FMLanguaeType。

naviMode fengmap.FMNaviMode

导航中路径规划模式, 支持最短路径、最优路径两种。默认为MODULE_SHORTEST, 最短路径。

naviPriority fengmap.FMNaviPriority

导航中的路线规划梯类优先级, 默认为PRIORITY_DEFAULT, 详情参考FMNaviPriority。

autoRoute boolean

设置起点或终点, 是否自动进行路径规划计算。默认为true, 在路径较复杂的情况下, 可以设置为false, 调用route方法主动进行路径计算。

speed number

模拟导航定位图标行进的速度, 单位m/s。默认5m/s。

followPosition boolean

模拟导航中在位置发生变化时, 地图是否跟随位置居中显示。默认true。

followAngle boolean

模拟导航中在方向发生变化时, 地图是否跟随方向变化, 保持路线朝向屏幕上方。 默认false。

changeTiltAngle boolean

模拟导航中楼层发生变化时是否改变地图的倾斜角度, 并执行动画。默认为true。

scale number

模拟导航开始时地图的显示比例尺, 默认值为282, 表示1:282的地图比例尺。对应比例尺级别21。

minScale number

模拟导航开始时地图的显示最小比例尺, 默认值为141, 表示1:141的地图比例尺。防止视角过近。

imageMarkerHeight number

图片标注的与楼层之间的高度偏移设置。默认是6。

locationMarkerUrl number

模拟导航定位标注使用的图片资源URL。

locationMarkerSize number

模拟导航定位标注的大小。默认是100。

locationMarkerHeight number

定位标注与楼层之间的高度偏移设置。默认是3。

lineStyle json

路径线线型设置, 详细内容参照FMMap.drawLineMark参数中的设置fengmap.FMMap#drawLineMark

lineMarkerHeight number

导航线与楼层之间的高度偏移设置, 默认为1。

autoClearNaviLine boolean

调用drawNaviLine绘制导航线时, 是否清除上次调用drawNaviLine绘制的导航线, 默认为true。 如果设置为false并多次调用drawNaviLine时, FMNavigaiton只负责管理最后一次绘制的线对象, 其余调用drawNaviLine返回的线对象开发者需要自行存储并管理。

Members

endMarker

结束点所使用的FMImageMarker对象

Properties:
Name Type Description
endMarker fengmap.FMImageMarker

locationMarker

导航所用到的FMLocationMarker对象

Properties:
Name Type Description
locationMarker fengmap.FMLocationMarker

得到此本次导航路径的文字描述字符串集合。

Properties:
Name Type Description
naviDescriptions array

路径描述的json数组, 用户可以根据里面的数据, 自己组织描述语言。

Properties:
Name Type Description
naviDescriptionsData array.<json>
naviDescriptionsData[].distance number

当前路段的距离。

naviDescriptionsData[].startDirection number

起点的地理方向。

naviDescriptionsData[].startGID number

起点的楼层。

naviDescriptionsData[].startIndex number

起点路线节点索引。

naviDescriptionsData[].startPoint json

起点坐标。

naviDescriptionsData[].endDirection number

终点行进方向。

naviDescriptionsData[].endGID number

终点楼层。

naviDescriptionsData[].endIndex number

终点路线节点索引。

naviDescriptionsData[].endPoint json

终点坐标。

得到此导航路径的总距离

Properties:
Name Type Description
naviDistance number

路径所经过层对应在各楼层的距离, 按照起终点路径顺序存储。

Properties:
Name Type Description
naviGroupsDistance array.<json>

json数组。

naviDescriptionDatas[].groupID number

楼层ID。

naviDescriptionDatas[].distance number

路线距离。

导航是否到达门点停止

Properties:
Name Type Description
naviToDoor boolean

startMarker

起始点所使用的FMImageMarker对象

Properties:
Name Type Description
startMarker fengmap.FMImageMarker

Methods

AdaptiveLineOverview()

自适应路线全览

clearAll()

清空导航类中的起始点标注, 定位标注及当前路线标注。

clearLocationMarker()

清除定位标注。

clearMarkers()

清空导航类中的起始点标注。

clearNaviLine()

清除上次调用drawNaviLine绘制的导航线。

dispose()

释放fengmap.Map对象引用和内存占用。

drawNaviLine(){fengmap.FMLineMarker}

设置完起始点后, 如果路径规划成功, 调用此方法画出导航线。autoRoute为false时, 需要在画线之前主动调用route方法。autoClearNaviLine为true, 清除上次绘制的导航线。

Returns:
Type Description
fengmap.FMLineMarker 返回当前绘制的线对象

focusNaviLineSegment(index, options)

地图显示范围聚焦到索引为值等于index的路段, 路段信息来至于naviDescriptionsData。

Name Type Description
index int

路段下标

options json

聚焦参数

Name Type Description
duration number

聚焦时的过渡动画效果设置

extendScale number

聚焦范围的比例尺放大缩小比例, 默认为1.3, 当数字大于1时比例尺变大, 聚焦后地图显示会缩小。小于1地图则会看起来更大。

callback function

聚焦完成后的事件回调

getRouteDescriptions(navResults, params){json}

得到路径规划后的文字描述

Name Type Description
navResults array.<fengmap.FMNaviResult>

路径计算结果FMNaviResult数组, 可以不传入该参数。如果未传入该参数, 则使用上次analyzeNavi计算结果进行计算。

params json

路径描述信息计算参数。

Name Type Description
directionAssert number

正方向的断定阀值, 默认为10。表示路段前行方向的方位角如果落在八个地理方向中某个的左右10度范围内, 则路段的正方向为这个方向。方向有: "东"、"西"、"南"、"北"、"东南"、"东北"、"西南"、"西北"。

combineAsset number

相邻路段是否存在拐角的判断阈值, 默认值为5。表示如果相邻路段的夹角小于5度, 那么不认为存在拐角, 会合并为一段路段。

naviLanguage fengmap.FMLanguageType

文字描述内容的语言类型参数, 默认为中文。 目前支持中英文。

Returns:
Type Description
json { naviDescriptions: // 路径的文字描述数组 [str, str , ...] naviDescriptionsData: // 路径的描述数据,用户可以用此数据自己组织描述文字 [json, json, ...] naviDistance: // 路径总长度, 单位米。 naviGroupsDistance: // 每一层的路径长度。 }

locate(coord, angle)

用于真实导航, 设置定位系统所返回的真实定位坐标, 内部自动路径约束, 同时触发walking事件, walking事件中返回如下结果: {remain: 到终点的剩余距离, walk: 已经走过的距离, distanceToNext: 是下一个转角处的距离, angle: 当前路线与正北方向的角度, index: 当前路段的索引, point: 路径约束后的点, groupID, 当前的楼层id}

Name Type Description
coord json

定位系统返回并经过坐标转换后的地图坐标点如:{x:,y:,groupID:1}

angle number optional

角度值, 如:45,可选

locateNoConstraint(coord, angle)

用于真实导航, 设置定位系统所返回的真实定位坐标, 内部无路径约束, 同时触发walking事件, walking事件中返回如下结果: {remain: 到终点的剩余距离, walk: 已经走过的距离, distanceToNext: 是下一个转角处的距离, angle: 当前路线与正北方向的角度, index: 当前路段的索引, point: 路径约束后的点, groupID, 当前的楼层id} 此方法与locate的区别为使用未约束的定位原始坐标显示定位位置, 内部仍会进行约束计算。

Name Type Description
coord json

定位系统返回并经过坐标转换后的地图坐标点如:{x:,y:,groupID:1}

angle number optional

角度值, 如: 45,可选参数。

在路径规划完成后,得到当前实际的定位点与路径上的最近点及与这个点之间的距离

Name Type Description
coord json

{x: ,y: , groupID: }

Returns:
Type Description
json {coord: , distance:, index:, remain, angle} coord: 垂点的坐标 {x:, y:, groupID}, distance: 指定点与垂点的距离, index: 当前的点所在的线段索引,返回-1时表示约束失败,位置点无法正确到达规划路线。 remain: 导航的剩余距离, angle: 所在路段与正北方向的角度值

off(type, callback)

导航事件销毁

Name Type Description
type string

支持'walking'、'crossGroup'、'complete'。

callback function

事件回调函数

on(type, callback)

导航事件注册 同一事件支持多次绑定

Name Type Description
type string

支持'walking'、'crossGroup'、'complete'。

callback function

事件回调函数

pathConstraint(coord){json}

全路网路径约束

Name Type Description
coord json

{x: ,y: , groupID: }

Returns:
Type Description
json {coord: , distance:, road:, angle} coord: 垂点的坐标 {x:, y:, groupID}, distance: 指定点与垂点的距离, road: 当前的点所在路段, angle: 所在路段与正北方向的角度值

pause()

暂停模拟导航

resume()

恢复模拟导航

route(mode, priority)

路径规划计算方法, 在autoRoute为false时, 设置起终点后需要调用该方法进行路径规划计算。

Name Type Description
mode fengmap.FMNaviMode

导航中路径规划模式, 支持最短路径、最优路径两种。默认为MODULE_SHORTEST, 最短路径。

priority fengmap.FMNaviPriority

导航中的路线规划梯类优先级, 默认为PRIORITY_DEFAULT, 详情参考FMNaviPriority。

setEndPoint(data, noMarker){fengmap.FMImageMarker}

设置终点

Name Type Description
data json

导航终点参数对象。

Name Type Description
x number

终点地图坐标X。

y number

终点地图坐标Y。

groupID number

终点楼层groupID。

height number

终点地图坐标距离楼层地面的高度. 如果不设置该属性, 使用FMNavigaiton的属性imageMarkerHeight。

url string

终点标注图片路径, 如不设置, 且使用之前设置的图片, 只是设置其位置。

size number

终点标注图片大小。

callback fuction

终点图片标注添加成功回调。

noMarker bool

是否不生成Marker对象, 不设置或者为true时, 设置起点不会生成图片标注。

Returns:
Type Description
fengmap.FMImageMarker 返回添加成功的imageMarker对象, noMarker不设置或者为true时, 返回null。

setLineStyle(路径线线型设置,)

设置当前绘制的导航线样式

Name Type Description
路径线线型设置, json

详细内容参照 fengmap.FMMap#drawLineMark 参数lineStyle 说明。

setNaviLanguage(lan)

设置当前导航中的文字描述语言类型。

Name Type Description
lan fengmap.FMLanguageType

目前支持中英文。如果路径规划成功, 会自动更新naviDescriptions和naviDescriptionDatas数据。

setStartPoint(data, noMarker){fengmap.FMImageMarker}

设置起点

Name Type Description
data json

导航起点参数对象。

Name Type Description
x number

起点地图坐标X。

y number

起点地图坐标Y。

groupID number

起点楼层groupID。

height number

起点地图坐标距离楼层地面的高度. 如果不设置该属性, 使用FMNavigaiton的属性imageMarkerHeight。

url string

起点标注图片路径, 如不设置, 且使用之前设置的图片, 只是设置其位置。

size number

起点标注图片大小。

callback fuction

起点图片标注添加成功回调。

noMarker bool

是否不生成Marker对象, 不设置或者为true时, 设置起点不会生成图片标注。

Returns:
Type Description
fengmap.FMImageMarker 返回添加成功的FMImageMarker对象, noMarker不设置或者为true时, 返回null。

simulate()

设置完起始点后, 开始模拟导航, 调用此方法会自动画线, 不需要在调用drawNaviLine方法。

stop()

停止模拟导航

Events

complete

模拟导航结束事件, 真实导航不会触发该事件。需要开发者根据waliking事件的返回内容, 进行业务处理。

Type:
  • void

crossGroup

模拟导航中的跨层事件

Type:
  • number
Properties:
Name Type Description
groupId number

当前楼层goupID.

walking

导航过程中位置发生变化时触发的事件, 模拟导航与真实导航调用locate后都都会触发。

Type:
  • json
Properties:
Name Type Description
walk number

已经走过的距离。

remain number

到终点的剩余距离。

distance number

定位点的路线偏移距离。

distanceToNext number

到下一个转角处的距离。

angle number

当前路线与正北方向的角度。

point json

导航约束后的点。

groupID number

当前的楼层id。

index number

当前路段的索引。