MapView
Extends:
地图控件类
注意: 底图需要特定的比例尺和投影(google)
Example:
var mapView = new KQ.Map.MapView({
  center: [ 30.56, 113.66 ],
  zoom: 10,
  maxZoom: 16,
}, 'osm', 'vector');ss
mapView.initAsync(function () {
  // do something
});Static Method Summary
| Static Public Methods | ||
| public static | 获取地图的key | |
| public static | setMapToken(token: String): Object 设置地图的token | |
Constructor Summary
| Public Constructor | ||
| public | constructor(options: Object) 构造函数 | |
Method Summary
| Public Methods | ||
| public | addControl(control: Control): Null 给地图添加控件 | |
| public | Call the control function | |
| public | clearDrawGeoJSON(): Null 移除所有绘制的图形 | |
| public | closePopup(popup: MapPopup): Null 关闭指定的弹出框 | |
| public | closeTooltip(tooltip: MapTooltip): Null 关闭指定的提示框 | |
| public | compareThreeMap(options: Object): Object 比较地图 | |
| public | compareTwoMap(options: Object): Object 比较地图 | |
| public | createPane(zIndex: Integer, name: String): null 创建地图Pane,用于控制图层叠加顺序 | |
| public | 获取地图鼠标类型 | |
| public | 设置地图中心点和比例尺 | |
| public | flyToBounds(bounds: LatLngBounds): Null 设置地图范围 | |
| public | geoFitBounds(latlngbound: *) | |
| public | 获取地图范围 | |
| public | 获取地图中心点 | |
| public | getControlByType(type: String): Object 根据类型获取控件 | |
| public | getDrawGeoJSON(isDestProjection: Boolean): GeoJSON 获取绘制的图形数据 | |
| public | getDrawnItems(): Object[] 获取地图上绘制的图形 | |
| public | 获取输入控件,如果输入控件不存在,则返回null。 | |
| public | 获取地图Pane | |
| public | getPermission(): String[] 获取地图设置的权限 | |
| public | getSidebar(): Object 获取主侧栏控件,如果输入不被输出,返回null。 | |
| public | 获取树控件,如果树控件不存在,则返回null | |
| public | 获取地图比例尺索引 | |
| public | 初始化地图 | |
| public | latLngToLayerPoint(latlng: LatLng): Point 将 地图坐标 转换为 屏幕坐标 | |
| public | layerPointToLatLng(point: Point): LatLng 将屏幕坐标转换为地图坐标 | |
| public | 打开指定的弹出框 | |
| public | openTooltip(tooltip: MapTooltip): Null 打开指定的提示框 | |
| public | 移动地图,基于偏移 | |
| public | 移动地图中心点 | |
| public | 将WGS84投影到地图目标投影 | |
| public | removeControl(control: Control): Null 从地图移除控件 | |
| public | resetCursor(): null 恢复地图鼠标类型 | |
| public | 恢复地图投影信息 | |
| public | setBackgroundColor(color: Color): }null 设置地图背景色 | |
| public | 设置地图鼠标类型 | |
| public | setTempCRS(crs_options: Object) 设置临时的投影信息 | |
| public | 设置地图视口 | |
| public | toggleDrawControl(): Null 打开或关闭绘图面板 | |
| public | 将地图目标投影的坐标投影到WGS84 | |
| public | 设置底图比例尺 | |
| public | 增加地图的比例尺 | |
| public | 减小底图的比例尺 | |
| public | zoomToMap(): Null 缩放到全图 | |
Static Public Methods
Public Constructors
public constructor(options: Object) source
构造函数
Emit:
| click | 当用户点击地图时被触发。 | 
| dblclick | 当用户双击地图时被触发。 | 
| mousedown | 当用户在地图上按下鼠标按钮时被触发。 | 
| mouseup | 当用户在地图上释放鼠标按钮时被触发。 | 
| mouseover | 当鼠标进入地图时被触发。 | 
| mouseout | 当鼠标移出地图时被触发。 | 
| mousemove | 当鼠标移动到地图上时触发。 | 
| contextmenu | 当用户在地图上按下鼠标右键时,就会被触发。 | 
| resize | 当地图尺寸改变时触发。 | 
| load | 当地图被初始化时触发。(当第一次设置中心点和比例尺时) | 
| zoomend | 当地图比例尺改变了之后触发。 | 
| moveend | 当地图的中心停止改变时触发。(例如,用户停止拖动地图) | 
| draw:created | 当在地图上绘制了一个图形时触发 | 
Public Methods
public addControl(control: Control): Null source
给地图添加控件
Params:
| Name | Type | Attribute | Description | 
| control | Control | 地图控件对象 | 
Return:
| Null | 
public callApi(name: String): Null source
Call the control function
Params:
| Name | Type | Attribute | Description | 
| name | String | the control's name, contain ['zoom_in', 'zoom_out', 'roaming', 'forward-map', 'backward-map', 'full-map', 'drawing', 'info-query', 'measureseparate-length', 'measureseparate-area', 'setlocation', 'sidebyside-h', 'sidebyside-v', 'searchlight', 'searchlight-length', 'screenshot', 'screenshot-show', 'print', 'compare', 'styleeditor', 'zoom-in', 'zoom-out', 'fullscreen', 'draw-polyline', 'draw-polygon', 'draw-rectangle', 'leaflet-draw-draw-circle', 'draw-marker', 'draw-circlemarker', 'edit-edit', 'edit-remove']; | 
Return:
| Null | 
public closePopup(popup: MapPopup): Null source
关闭指定的弹出框
Params:
| Name | Type | Attribute | Description | 
| popup | MapPopup | 弹出框对象 | 
Return:
| Null | 
public closeTooltip(tooltip: MapTooltip): Null source
关闭指定的提示框
Params:
| Name | Type | Attribute | Description | 
| tooltip | MapTooltip | 提示框对象 | 
Return:
| Null | 
public compareThreeMap(options: Object): Object source
比较地图
Params:
| Name | Type | Attribute | Description | 
| options | Object | 设置参数 | |
| options.win | Object | 父窗口对象 | |
| options.parentID | String | 父DOM对象的ID | |
| options.leftLayerInfos | Object[] | 左边的图层信息数组,元素格式:{ src_name: "abc", id: "1" } | |
| options.rightLayerInfos | Object[] | 右边的图层信息数组,元素格式:{ src_name: "abc", id: "1" } | |
| options.midLayerInfos | Object[] | 中间的图层信息数组,元素格式:{ src_name: "abc", id: "1" } | |
| options.center | LatLng | 地图中心点 | |
| options.zoom | Number | 地图比例尺索引 | 
Return:
| Object | options.left_layerManager和options.right_layerManager,options.mid_layerManager分别表示左右中图层管理。options.mapView_left和mapView_right,mapView_mid分别表示左右中地图控件。 | 
public compareTwoMap(options: Object): Object source
比较地图
Params:
| Name | Type | Attribute | Description | 
| options | Object | 设置参数 | |
| options.win | Object | 父窗口对象 | |
| options.parentID | String | 父DOM对象的ID | |
| options.leftLayerInfos | Object[] | 左边的图层信息数组,元素格式:{ src_name: "abc", id: "1" } | |
| options.rightLayerInfos | Object[] | 右边的图层信息数组,元素格式:{ src_name: "abc", id: "1" } | |
| options.leftGeoJSON | Object | 左图添加的图形数据对象 | |
| options.rightGeoJSON | Object | 右图添加的图形数据对象 | |
| options.leftQueryLayerInfo | Object | 左边查询的图层信息,元素格式:{ src_name: "abc", id: "1" } | |
| options.rightQueryLayerInfo | Object | 右边查询的图层信息,元素格式:{ src_name: "abc", id: "1" } | |
| options.center | LatLng | 地图中心点 | |
| options.zoom | Number | 地图比例尺索引 | 
Return:
| Object | options.left_layerManager和options.right_layerManager分别表示左右图层管理。options.mapView_left和mapView_right分别表示左右地图控件。 | 
public createPane(zIndex: Integer, name: String): null source
创建地图Pane,用于控制图层叠加顺序
Params:
| Name | Type | Attribute | Description | 
| zIndex | Integer | 地图Pane的zIndex | |
| name | String | 地图Pane的名称 | 
public flyToBounds(bounds: LatLngBounds): Null source
设置地图范围
Params:
| Name | Type | Attribute | Description | 
| bounds | LatLngBounds | 地理范围(wgs84) | 
Return:
| Null | 
public geoFitBounds(latlngbound: *) source
Params:
| Name | Type | Attribute | Description | 
| latlngbound | * | 
public getControlByType(type: String): Object source
根据类型获取控件
Params:
| Name | Type | Attribute | Description | 
| type | String | 地图控件的名称('tree', 'zoom', 'zoomslider', 'attribution', 'coordinates', 'scale', 'input', 'measure', 'setlocation', 'plotting', 'searchbar', 'draw', 'styleeditor', 'compare', 'sidebyside', 'searchlight', 'screenshot', 'basemap', 'print', 'historyview', 'mini', 'toolbar', 'sidebar') | 
public getDrawGeoJSON(isDestProjection: Boolean): GeoJSON source
获取绘制的图形数据
Params:
| Name | Type | Attribute | Description | 
| isDestProjection | Boolean | 如果为true,则返回目标投影的坐标 | 
Return:
| GeoJSON | 
public getPane(name: String): Object source
获取地图Pane
Params:
| Name | Type | Attribute | Description | 
| name | String | 地图Pane的名称 | 
public latLngToLayerPoint(latlng: LatLng): Point source
将 地图坐标 转换为 屏幕坐标
Params:
| Name | Type | Attribute | Description | 
| latlng | LatLng | 经纬度 (地图坐标) | 
public layerPointToLatLng(point: Point): LatLng source
将屏幕坐标转换为地图坐标
Params:
| Name | Type | Attribute | Description | 
| point | Point | 屏幕坐标 | 
public openPopup(popup: MapPopup): Null source
打开指定的弹出框
Params:
| Name | Type | Attribute | Description | 
| popup | MapPopup | 弹出框对象 | 
Return:
| Null | 
public openTooltip(tooltip: MapTooltip): Null source
打开指定的提示框
Params:
| Name | Type | Attribute | Description | 
| tooltip | MapTooltip | 提示框对象 | 
Return:
| Null | 
public panBy(offset: Point): Null source
移动地图,基于偏移
Params:
| Name | Type | Attribute | Description | 
| offset | Point | 偏移,单位像素 | 
Return:
| Null | 
public panTo(latlng: LatLng): Null source
移动地图中心点
Params:
| Name | Type | Attribute | Description | 
| latlng | LatLng | 地理点(wgs84) | 
Return:
| Null | 
public project(latlng: LatLng): Point source
将WGS84投影到地图目标投影
Params:
| Name | Type | Attribute | Description | 
| latlng | LatLng | 经纬度 | 
public removeControl(control: Control): Null source
从地图移除控件
Params:
| Name | Type | Attribute | Description | 
| control | Control | 地图控件对象 | 
Return:
| Null | 
public setBackgroundColor(color: Color): }null source
设置地图背景色
Params:
| Name | Type | Attribute | Description | 
| color | Color | 地图背景色 | 
Return:
| }null | 
public setCursor(cursor: String): null source
设置地图鼠标类型
Params:
| Name | Type | Attribute | Description | 
| cursor | String | 鼠标类型,参考:https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | 
public setTempCRS(crs_options: Object) source
设置临时的投影信息
Example:
var crs_options = {
  "origin": [-20037508.3427892, 20037508.3427892],
  "resolutions": [305.748124978916, 152.874062489458, 76.437031244729, 38.2185156223645, 19.10925781118225, 9.554628905591125, 4.777314452795562, 2.388657226397781, 1.1943286131988906, 0.5971643065994453, 0.29858215329972265, 0.14929107664986133, 0.07464553832493066],
  "bounds": L.bounds([-20037508.3427892, -20037508.3427892], [20037508.3427892, 20037508.3427892]),
  "prj": KQ.Common.CommonValues.defaltPrj_EPSG3857,
  "proj4": KQ.Common.CommonValues.defaltProj4_EPSG3857,
};public unproject(point: Point): LatLng source
将地图目标投影的坐标投影到WGS84
Params:
| Name | Type | Attribute | Description | 
| point | Point | 目标投影坐标 | 
public zoom(scale_id: Number): Null source
设置底图比例尺
Params:
| Name | Type | Attribute | Description | 
| scale_id | Number | 底图比例尺id | 
Return:
| Null | 
public zoomIn(delta: Number): Null source
增加地图的比例尺
Params:
| Name | Type | Attribute | Description | 
| delta | Number | 比例尺增量 | 
Return:
| Null | 
 Reference
  Source
  
  Reference
  Source
  
  