Map


    Map用于创建地图实例。

构造函数
new TMap.Map(dom, options);
参数名 类型 说明
dom String | HTMLDIVElement 地图DOM容器,创建地图需要在页面中创建一个空div元素,传入该div元素或者该元素的id
options MapOptions 地图参数
方法名 返回值 说明
setCenter(center: LatLng) this 设置地图中心点
setZoom(zoom:Number) this 设置地图缩放级别
setRotation(rotation:Number) this 设置地图水平面上的旋转角度
setPitch(pitch:Number) this 设置地图俯仰角
setMapStyleId(mapStyleId:String) this 动态设置个性化地图样式
setWeather(weather: String) this 设置天气,支持’rain’和’snow’,也可以传入null来取消
panTo(latLng: LatLng, opts: EaseOptions) this 将地图中心平滑移动到指定的经纬度坐标
zoomTo(zoom:Number, opts: EaseOptions) this 平滑缩放到指定级别
rotateTo(rotation:Number, opts: EaseOptions) this 平滑旋转到指定角度
pitchTo(pitch:Number, opts: EaseOptions) this 平滑变化到指定俯仰角度
easeTo(mapStatus:Object, opts: EaseOptions) this 平滑过渡到指定状态,mapStatus为key-value格式,可以设定centerzoomrotationpitch,参数要求可参考 MapOptions 中同名参数
getCenter() LatLng 获取地图中心
getZoom() Number 获取地图缩放级别
getRotation() Number 获取地图水平面上的旋转角度
getPitch() Number 获取地图俯仰角度
enableAreaHighlight(opts: HighlightOptions) this 启用地图区域高亮功能
freeze() this 冻结地图数据加载及渲染
unfreeze() this 解除冻结
on(eventName:String, listener:Function) this 添加listenereventName事件的监听器数组中
off(eventName:String, listener:Function) this eventName事件的监听器数组中移除指定的listener
事件名 回调参数 说明
move 当地图移动时会触发此事件



MapOptions 对象规范


地图配置参数。

属性名称 类型 说明
center LatLng 地图中心点经纬度
zoom Number 地图缩放级别,支持3~20
rotation Number 地图在水平面上的旋转角度,顺时针方向为正,默认为0
pitch Number 地图俯仰角度,取值范围为0~80,默认为0
mapStyleId String 地图样式id,目前支持拟真写实(realistic)、蓝调极简(simple), 默认为拟真写实(realistic)



EaseOptions 对象规范


地图缓动参数规范。

属性名称 类型 说明
duration Number 缓动动画时长,单位为ms,默认为500。



HighlightOptions


    地图高亮区域配置参数。

属性名称                             类型                             说明
paths LatLng[] 高亮区域轮廓坐标点串
highlightColor String 高亮色,区域内地图元素将与该色进行混合,支持rgb(),rgba(),#RRGGBB等形式,默认为rgba(0, 0, 0, 0)
shadeColor String 阴影色,区域外地图元素将与该色进行混合,支持rgb(),rgba(),#RRGGBB等形式,默认为rgba(0, 0, 0, 0.4)