# viewer拓展

viewer实例化完成后,会扩展 viewer.mars.*, 该类是静态类,包含坐标转换、popup、tooltip、定位等方法或对象

# 方法

方法名 返回值 说明
getLayer(String key, String keyname?) BaseLayer 根据指定字段值(默认名称name)获取指定图层,keyname可以定义id等,为配置信息的字段名,默认是name
centerAt(Object centeropt,Number duration?) 地球定位至指定区域,duration为播放动画时长(秒),默认3秒
openFlyAnimation(Function endfun,Object centeropt?) 开场动画,动画播放地球飞行定位指指定区域(默认为config.josn中配置的视域)
viewer.mars.openFlyAnimation(function () {
//动画播放完成后回调
});
hasTerrain() Boolean 是否有地形数据
updateTerrainProvider(Boolean isStkTerrain) 更新地形,参数传入是否显示地形
getCrs() String 获取当前地图坐标系,值为gcj时表示是国测局偏移坐标
point2map({x:经度,y:纬度}) {x:经度,y:纬度} 在不同坐标系情况下,转换“目标坐标值”至“地图坐标系”一致的坐标
point2wgs({x:经度,y:纬度}) {x:经度,y:纬度} 在不同坐标系情况下 ,获取地图上的坐标后,转为wgs标准坐标系坐标值

#

方法名 返回值 说明
popup popup 鼠标单击信息框处理类
tooltip tooltip 鼠标悬浮提示信息框处理类

viewer.mars.popup,该类是静态类。鼠标单击信息框处理类

方法名 返回值 说明
show(Entity entity, Cartesian3 cartesian) 弹出popup信息框(entity需要有popup对象,其信息为绑定信息框内容的html信息)
entityentity.popup = {
html: 'html', //可以是任意html
anchor: [0, -25]
};
viewer.mars.popup.show(entity, entity.position._value);
close(String entityid) 关闭popup信息框,多弹窗模式,关闭指定id的弹窗,默认关闭所有
isOnly(Boolean value) 是否唯一弹窗模式,默认true,传入false可以启用多弹窗
getPopupForConfig(Object config,Object attr) String 根据配置信息构造popup通用处理方法

# tooltip

viewer.mars.tooltip,该类是静态类。鼠标悬浮提示信息框处理类

方法名 返回值 说明
show(Entity entity, Cartesian3 cartesian) 弹出tooltip信息框(entity需要有tooltip对象,其信息为绑定信息框内容的html信息)
entityentity.tooltip = {
html: 'html', //可以是任意html
anchor: [0, -25]
};
viewer.mars.popup.show(entity, entity.position._value);
close() 关闭popup信息框,多弹窗模式,关闭指定id的弹窗,默认关闭所有
Last Updated: 6/21/2024, 5:48:01 PM