Map

三维地图管理器。


三维地图初始化效果图

new CooWasm.Map(container, props)

Name Type Description
container String optional

绑定的canvas标签id。

props Object optional

包含如下属性的Object:

Name Type Default Description
dataThreadNum Number 2 optional

数据线程数量,自动根据电脑CPU线程数配置,理论核心-5为其推荐值。

nodeNum Number 3000 optional

数据节点加载上限数,数值越大,节点可驻留显存数量越多。

initCallback CallbackNull null optional

初始回调函数,可在初始化时调用外部传入的函数。

Example:
var xxx = new CooWasm.Map({
    container:"canvas"
})
Demo:

Members

ServiceWorkerCache

Service Worker 缓存助手 仅在 HTTPS 下使用

bCache : Boolean

是否缓存数据。

Default Value: true

bProgress : Boolean

是否展示进度。

Default Value: true

basePath : String

cooWasmApi库相对调用网页位置。

dataThreadNum : Number

数据线程数。

Default Value: 4

elevationLayers : Array.<ElevationLayer>

地形高程图层数组。

featureLayers : Array.<FeatureLayer>

矢量图层数组。

getObjects

获取已加载在地图中的对象,通过各类对象数组返回。

Example:
// 获取对象
map.getObjects()

imageLayers : Array.<ImageLayer>

地形影像图层数组。

licIp : String

授权服务ip地址。

Default Value: ""

licPort : Number

授权服务端口号。

Default Value: -1

meshLayers : Array.<MeshLayer>

倾斜摄影图层数组。

modelLayers : Array.<ModelLayer>

人工模型图层数组。

nodeNum : Number

节点数量上限。

Default Value: 3000

parentNode : Object

canvas的父亲节点。

progressDiv : Object

进度div。

progressStyle : Object

进度div样式。

protocol : Number

网络协议,默认0,代表Http。

Default Value: 0

Methods

asyncclearCache()Promise.<void>

清除三维地图缓存(支持 IndexedDB 和 Service Worker)。

Returns:

这个方法不返回任何值

Example:
map.clearCache()

destroy()

从场景中销毁自身。

Returns:

null 空值。

Example:
// 销毁对象
xxx = xxx.destroy()

enableKeyboardShortcuts(enabled)

启用或禁用键盘快捷键

Name Type Description
enabled Boolean

是否启用快捷键

enableMousePosition(state, func)

开启或者关闭鼠标位置回调。

Name Type Description
state Boolean

开关状态。

func CallbackObj

返回经纬度位置信息的回调函数。

Example:
map.enableMousePosition(true, position=>{
     console.log(position)
})

enableMouseScale(state, func)

开启或者关闭鼠标位置对应比例尺回调。

Name Type Description
state Boolean

开关状态。

func CallbackString

返回鼠标位置对应比例尺信息的回调函数,字符串格式: 像素值/米。

Example:
map.enableMouseScale(true, str=>{
     console.log(str)
})

enableRoam(state)

开启或者关闭三维地图漫游。

Name Type Description
state Boolean

开关状态。

Example:
// 禁用漫游
map.enableRoam(false)

fadeOutProgress(callback)

渐变移除加载动画

Name Type Description
callback function

渐变完成后的回调函数

getActiveNodes()Number

获取当前激活调度节点数。

Returns:

当前激活调度节点数。

getDataRequest()Number

获取当前请求节点数。

Returns:

当前请求节点个数。

getNodes()Number

获取当前调度节点总数。

Returns:

当前调度节点总数。

memoryTest(step, times)

测试内存极限。

Name Type Description
step Number

步长。

times Number

测试次数。

Example:
// 测试内存极限
map.memoryTest()

memoryUsage()Number

获取内存使用情况。

Returns:

已使用内存(MB)。

setLodScale(lodScale)

设置相机LodScale

Name Type Description
lodScale Number

调度比例值。

Example:
// 设置相机LodScale
map.setLodScale(1.0)

visible(state)

显隐三维地图本身。

Name Type Description
state Boolean

显隐状态。

Example:
// 显隐三维地图
map.visible(false)