Skip to content

@indoor-map/fmap-jsDocs


地图要素统一抽象类

将搜索结果、点击拾取等场景返回的原始数据统一封装为 FMapModel 实例, 提供 highlight / moveTo / focus 等常用操作方法。

通过 FID 缓存机制,同一要素始终返回同一实例。

Example

ts
// 通过搜索获取 model
const models = await search.searchByKeyword('星巴克');
models[0].highlight('#ff0000');
models[0].moveTo({ animate: true, zoomValue: 20 });

// 或直接 focus(高亮 + 移动一步到位)
models[0].focus({ highlightColor: '#00ff00' });

Implements

Constructors

new FMapModel()

new FMapModel(fmap, data): FMapModel

构造 FMapModel 建议通过 FMapModel.resolve() 创建以启用缓存复用

Parameters

fmap: FMap

地图实例

data: SearchResultItem

搜索结果数据

Returns

FMapModel

Properties

bound

readonly bound: unknown

范围

Implementation of

SearchResultItem.bound


center

readonly center: object

中心点坐标

x

x: number

y

y: number

Implementation of

SearchResultItem.center


ename

readonly ename: string

要素英文名

Implementation of

SearchResultItem.ename


FID

readonly FID: string

要素ID(唯一标识)

Implementation of

SearchResultItem.FID


floorName

readonly floorName: string

楼层名称

Implementation of

SearchResultItem.floorName


level

readonly level: number

楼层级别

Implementation of

SearchResultItem.level


name

readonly name: string

要素名称

Implementation of

SearchResultItem.name


raw

readonly raw: unknown

原始数据

Implementation of

SearchResultItem.raw


type

readonly type: number

要素类型

Implementation of

SearchResultItem.type


typeName

readonly typeName: string

类型名称

Implementation of

SearchResultItem.typeName

Accessors

isHighlighted

Get Signature

get isHighlighted(): boolean

是否处于高亮状态

Returns

boolean


typeID

Get Signature

get typeID(): number

要素分类类型ID(SDK 数据的 typeID,如洗手间=200002;无则回退到 FMType)

Returns

number


cacheSize

Get Signature

get static cacheSize(): number

获取当前缓存数量

Returns

number

Methods

focus()

focus(options): void

聚焦此 model(高亮 + 移动一步到位)

Parameters

options: ModelFocusOptions = {}

聚焦选项

Returns

void


getFMap()

getFMap(): FMap

Internal

获取内部地图实例引用

Returns

FMap


getInfo()

getInfo(): ModelInfo

获取 model 的结构化信息

Returns

ModelInfo

ModelInfo 对象


highlight()

highlight(color?): void

高亮此 model 通过 map.getNodes() 定位节点后 setColor 上色(与 FMapHighlighter 同一机制, 不再使用 pickFilterFunction —— 那是拾取过滤器,会干扰地图正常拾取)

Parameters

color?: string

高亮颜色,默认 #ff7949

Returns

void


moveTo()

moveTo(options): void

地图移动到此 model 位置

Parameters

options: ModelMoveToOptions = {}

移动选项

Returns

void


toScreenCoord()

toScreenCoord(): object

将 model 中心点转为屏幕坐标

Returns

object

屏幕坐标,如果楼层不匹配可能返回异常值

x

x: number

y

y: number


toSearchResultItem()

toSearchResultItem(): SearchResultItem

转为纯数据对象(兼容 SearchResultItem)

Returns

SearchResultItem

SearchResultItem 对象


unhighlight()

unhighlight(): void

取消高亮(复位节点颜色,不影响地图正常拾取)

Returns

void


clearCache()

static clearCache(fid?): void

清除指定 FID 的缓存

Parameters

fid?: string

要素ID,不传则清除全部

Returns

void


get()

static get(fid, fmap?): undefined | FMapModel

根据 FID 获取已缓存的 model(不创建新实例)

Parameters

fid: string

要素ID

fmap?: FMap

地图实例(用于隔离不同地图的缓存;不传则无法定位带 mapID 前缀的 key)

Returns

undefined | FMapModel

FMapModel 或 undefined


highlightAll()

static highlightAll(models, color?): void

批量高亮多个 model

Parameters

models: FMapModel[]

要高亮的 model 列表

color?: string

高亮颜色(可选)

Returns

void


resolve()

static resolve(fmap, data): FMapModel

通过 FID 从缓存获取或创建新实例 保证同一地图内同一 FID 始终返回同一个 FMapModel 实例

Parameters

fmap: FMap

地图实例

data: SearchResultItem

搜索结果数据

Returns

FMapModel

FMapModel 实例


resolveAll()

static resolveAll(fmap, items): FMapModel[]

批量 resolve

Parameters

fmap: FMap

地图实例

items: SearchResultItem[]

搜索结果数组

Returns

FMapModel[]

FMapModel 数组


unhighlightAll()

static unhighlightAll(models): void

批量取消高亮多个 model

Parameters

models: FMapModel[]

要取消高亮的 model 列表

Returns

void

基于蜂鸟视图 Fengmap SDK 构建