Map(param)

new Map(param)

构造函数

Parameters:
Name Type Description
param Object 参数列表
Properties
Name Type Attributes Default Description
terrain Terrain <optional>
地形对象
sceneMode THING.EARTH.SceneMode <optional>
THING.EARTH.SceneMode.EarthView 地图场景类型 三维地球 or 2.5维平面地图
projectionType THING.EARTH.MapProjectionType <optional>
THING.EARTH.MapProjectionType.Geographic 2.5维平面地图时 创建平面使用的投影类型 经纬度直投 or Web墨卡托投影
style Object <optional>
地图样式 主要是指大气 雾效等地球级别的样式 数据结构可参考THING.EARTH.MapStyle
baseMaps Object | Array.<Object> <optional>
瓦片配置 数据结构可参考THING.EARTH.TileLayer
lights Object | Array.<Object> <optional>
灯光配置 数据结构可参考THING.EARTH.MapLightGroup
postEffects Object | Array.<Object> <optional>
后期配置 数据结构可参考THING.EARTH.MapPostEffects
background Object | Array.<Object> <optional>
背景配置 数据结构可参考THING.EARTH.MapBackground
restrictedLevel Array.<Number> <optional>
地图最大最小缩放级别 默认全级别显示
attribution String <optional>
右下角地图的版权信息
minPitch Number <optional>
8 相机最小倾角
maxPitch Number <optional>
89.9 相机最大倾角
onComplete function <optional>
创建完成的回调函数
Author:
  • caihuimin

Extends

  • THING.Object3D

Members

active :Boolean

设置地图的显示/隐藏状态 不会影响图层的显示隐藏状态

Default Value:
  • true

readonly allLayers :LayerCollection

地图上全部图层对象

attribution :String

设置/获取 地图的attribution

Author:
Example
map.attribution = '高德';//设置高德地图的版权信息
		map.attribution = 'My Attribution'; //自定义版权信息 右下角会展示ThingJS|My Attribuition
		map.attribution = 'none'; //不显示版权信息

readonly background :MapBackground

地图背景配置

readonly baseLayers :LayerCollection

获取基础地图集合

clippingArea :Array

地图挖洞区域

符合Polygon类型的坐标
Example
map.clippingArea = [[[116,39],[116,40],[117,40],[117,39],[116,39]]];

readonly currentLevel :Number

获取地图当前层级

depthMode :Boolean

设置深度模式 1 (DepthMode.DepthGlobe)采用深度球,深度球的半径要比地球半径小一些,这样地球背面的东西会被遮挡 但地球上的面和线仍然会显示 默认采用这种模式 2 (DepthMode.Earth)采用地球瓦片真实深度,这样可能地球上直连的线和大面会被遮挡或者撕面,但是如果有地形或者有半地下的场景,需要采用这种模式 应用时可以根据应用场景切换深度模式

Example
map.depthMode = DepthMode.DepthGlobe;//采用深度球的深度
map.depthMode = DepthMode.Earth;//采用地球瓦片真实深度

readonly layers :LayerCollection

业务图层的集合

readonly lights :MapLightGroup

地图灯光配置

maxPitch :Number

设置/获取地图相机的最大倾角 默认89.9

Example
map.maxPitch = 80

minPitch :Number

设置/获取地图相机的最小倾角 默认8

Example
map.minPitch = 10

readonly mode :THING.EARTH.SceneMode

地图场景类型 三维地球 or 2.5维平面地图

Default Value:
  • THING.EARTH.SceneMode.EarthView

readonly postEffects :MapPostEffect

地图后期配置

readonly projectionType :THING.EARTH.MapProjectionType

2.5维平面地图时 创建平面使用的投影类型 经纬度直投 or Web墨卡托投影

Default Value:
  • THING.EARTH.MapProjectionType.Geographic

restrictedLevel :Array.<Number>

设置/获取地图缩放层级 默认为[0,23]

Example
map.restrictedLevel = [0,18]; //设置地图默认缩放层级为最小0最大18

readonly style :MapStyle

获取地图样式 如需要修改可以使用map.style.xxx = value;

terrain :Terrain

获取/设置地形

Example
map.terrain = new THING.EARTH.Terrain({url:'http://data.marsgis.cn/terrain'});

useDepthStencilRenderBufferWhenUseMSAA :Boolean

当开启MSAA时,是否使用深度模板作为帧缓冲区的附件,默认为false,只有深度附件 注意:如果开启MSAA且加载贴地面和一部分倾斜摄影数据时,该参数应设置为true,否则效果会有问题

Default Value:
  • false

visible :Boolean

设置/获取地图是否可见

Example
map.visible = false;//设置地球不可见 会隐藏地球上所有物体

Methods

addBaseLayer(layer) → {Promise.<Object>}

添加基础底图

Parameters:
Name Type Description
layer Layer
Returns:
Promise.<Object>
Example
const layer = new TileLayer({
			url:"http://webst01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}"
		});
			map.addBaseLayer(layer);//将瓦片图层作为底图加入地球

addLayer(layer, renderOrder) → {Promise.<Layer>}

添加图层到地图上

Parameters:
Name Type Description
layer Layer 待添加图层
renderOrder Number 渲染顺序 渲染顺序越大越后渲染
Returns:
Promise.<Layer>
Example
const layer = new FeatureLayer({
			url:"data.geojson",
			geoObjectType: "GeoPoint",
			style: {
				pointType: "Image",
				url: "../texture/pop.png",
				size: 4,
				useSpriteMaterial: true,
				keepSize: true,
				pivot: [0, -1], //不生效
				azimuth: 100, //不生效
				angles: [90, 0, 1],
				rotateSpeed: 20,
				effect:true,
				glowStrength:2
			},
		});   //要素图层
		map.addLayer(layer).then(()=>{
			console.log('layer loaded!')
		});

destroy() → {Boolean}

销毁地图

销毁地图时,会卸载所有图层,卸载大气,修改相机锚点矩阵为单位矩阵,同时也会卸载所有注册事件
Returns:
Boolean - - 销毁成功

getCenter() → {Array.<Number>}

获取地图中心点

Returns:
Array.<Number>

getExtent() → {Extent}

获取当前可视范围

Returns:
Extent

getLayerById(id) → {Layer}

根据id获取图层

Parameters:
Name Type Description
id String 图层的id
Returns:
Layer
Example
map.getLayerById(1) //获取id为1的图层

getLayerByName(name) → {Selector}

根据名称获取图层

Parameters:
Name Type Description
name String 图层的name
Returns:
Selector
Example
map.getLayerByName('layerName') //获取name为layerName的图层集合

removeBaseLayer(layer) → {Boolean}

移除基础底图

Parameters:
Name Type Description
layer Layer
Returns:
Boolean
Example
const layer = map.baseLayer[0] //瓦片图层
			map.removeBaseLayer(layer);     //移除瓦片图层

removeLayer(layer) → {Boolean}

移除地图上的图层

Parameters:
Name Type Description
layer Layer 待添加图层
Returns:
Boolean
Example
const layer = map.layers[0];
map.removeLayer(layer);        //删除第一个图层

removeLayerById(id) → {Boolean}

根据id移除图层

Parameters:
Name Type Description
id String
Returns:
Boolean
Example
map.removeLayerById(1);

rotate(param)

地球旋转

Parameters:
Name Type Description
param Object 参数列表
Properties
Name Type Description
angle Number 旋转角度
speed Number 旋转速度 单位:(度/秒)
complete function 旋转完毕后的回调函数
Example
map.rotate({angle:360}); //地球自传360度

updateByMapConfig(config, resourceConfig)

给地图应用效果模板 支持1.0的配置与2.0的配置

Parameters:
Name Type Description
config Object 效果模板的配置参数
resourceConfig Object 资源配置

Events

Load

LoadError

LoadStart