new HyMapBox(dom, options)
- Source:
初始化
Parameters:
| Name | Type | Description |
|---|---|---|
dom |
Document | dom对象 |
options |
Object | 参数 |
Extends
- baseClass
Members
analysisURL
- Source:
Methods
add3DModel(group, coord, preScale) → {*}
- Source:
添加three三维模型
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
group |
three三维模型组 |
||
coord |
经纬度 |
||
preScale |
1
|
缩放比例 |
Returns:
- Type
- *
addLayer(arrays)
- Source:
增加图层
Example
//样式遵守maobox规则
const series1 = [{
id: 1,
data: values,
type: 'circle',
symbolStyle: {
normal: {
'circle-radius': 3, //半径
'circle-opacity': 1,//透明度
'circle-blur': 0.2,//模糊
'circle-color': {//颜色
'property': 'NUM',//属性字段 区分大小写
'type': 'categorical',
'default': 'green',//如果该属性不存在
'stops': [
['A', 'green'],//值=1
['B', 'yellow'],//值=2
['C', 'red'],
['D', 'orange']
]
}
},
emphasis: {
'circle-radius': 10 //半径
}
}
}];
let layer1 = this.mapObj.addLayer(series1);
const series1 = [{
id: 2,
data: values,
type: 'symbol',
visible: true,
symbolStyle: {
normal: {
'visibility': 'visible',//'none'
'icon-image': 'icon:example/images/kakou.png',
'icon-size': 0.7
},
emphasis: {
'icon-image': 'icon:example/data/hk/icon/luggage1.png'
}
},
showPopup: false //显示气泡框
}];
let layer1 = this.mapObj.addLayer(series1);
// this.mapObj.on('click', e => {
//
// console.log(e);
//
// });
this.mapObj.on('click', 2, (data) => {
console.log(data)
})
Parameters:
| Name | Type | Description |
|---|---|---|
arrays |
Array | 参数 |
addMarker(id, coord, offset) → {marker}
- Source:
增加标记
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
coord |
Array | 坐标 |
offset |
Array | 偏移量 |
Returns:
marker
- Type
- marker
addRadar(center, radius, color)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
center |
Array | 中心点坐标 |
radius |
Number | 半径 |
color |
String | 颜色 |
clearTrack()
- Source:
清空路径
drawTool(callback)
- Source:
绘制查
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
requestCallback | 回调 |
drawTrack(start, end, callback, tooltipFun, isCustom, tbName)
- Source:
绘制轨迹(依赖路网数据,目前仅提供济宁市的测试数据。)
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Array | 起始点 |
end |
Array | 结束点 |
callback |
function | 结果回调 |
tooltipFun |
function | 弹出气泡框回调 |
isCustom |
Boolean | 是否通用气泡框 |
tbName |
String | 表名 |
flyTo(center, zoom, callback, pitch)
- Source:
飞到
Parameters:
| Name | Type | Description |
|---|---|---|
center |
Array | 坐标数组 |
zoom |
Number | 地图级别 |
callback |
function | 回调方法 |
pitch |
Number |
getFeatureById(layerId, id) → {Array}
- Source:
根据id获取数据
Parameters:
| Name | Type | Description |
|---|---|---|
layerId |
图层id |
|
id |
数据id |
Returns:
features features数组
- Type
- Array
getFeaturesByProperty(layerId, key, value) → {Array}
- Source:
根据属性获取features
Parameters:
| Name | Type | Description |
|---|---|---|
layerId |
String | 图层id |
key |
String | 属性 |
value |
String | 值 |
Returns:
features features数组
- Type
- Array
getOption() → {Object}
- Source:
获取option
Returns:
地图参数
- Type
- Object
getSerie(layerId) → {Object}
- Source:
获取图层配置信息
Parameters:
| Name | Type | Description |
|---|---|---|
layerId |
String | 图层id |
Returns:
图层信息
- Type
- Object
getSeries() → {*}
- Source:
Returns:
- Type
- *
getServerUrl()
- Source:
获取服务器地址
hasLayer(id) → {boolean}
- Source:
判断图层是否存在
Parameters:
| Name | Type | Description |
|---|---|---|
id |
Returns:
- Type
- boolean
hideLayer(id)
- Source:
隐藏图层
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
hideMarker(id)
- Source:
隐藏标记
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
init(dom)
- Source:
初始化
Parameters:
| Name | Type | Description |
|---|---|---|
dom |
dom | 容器 |
isDebug(flag) → {Boolean}
- Source:
开启debug模式
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
flag |
Boolean |
false
|
开启|关闭 |
Returns:
- Type
- Boolean
moveModelToCoordinate(group, coord, preScale)
- Source:
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
group |
Object | three模型对象 |
|
coord |
Array | 模型放置坐标 |
|
preScale |
Number |
1
|
模型缩放比例 |
off(type, id, listener)
- Source:
移除事件
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | 类型 |
id |
function | String | id为layerid时移除为图层事件,否则为map事件 |
listener |
function | 回调 |
on(type, id, listener)
- Source:
注册事件
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String | 类型 |
id |
function | String | id为layerid时注册为图层事件,否则为map事件 |
listener |
function | 回调 |
panTo(meter, direction)
- Source:
平移
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
meter |
Number |
0
|
距离 单位 米 |
direction |
String |
right
|
朝向:up,down,left,right上下左右 |
project(Number, Number)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
Number |
x | 经度 |
Number |
y | 纬度 |
remove()
- Source:
移除所有信息
remove3DModel(model)
- Source:
移除三维模型
Parameters:
| Name | Type | Description |
|---|---|---|
model |
Object |
removeControl(controls)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
controls |
Array | 控件数组 |
removeLayer(id)
- Source:
移除指定id的图层
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
removeLayers(id)
- Source:
移除图层
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id不填写则移除所有图层 |
removeMarker(id)
- Source:
移除标记
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
removeRotate()
- Source:
移除旋转动画
removeSpatialQuery()
- Source:
移除空间查询结果
Returns:
null
removeThreeBoxScene()
- Source:
resize()
- Source:
重绘地图
rotate(speed, time, mouseControl) → {rotate}
- Source:
旋转动画效果
Parameters:
| Name | Type | Description |
|---|---|---|
speed |
Number | 旋转速度 |
time |
Number | 旋转时长(小于0代表一直旋转下去) |
mouseControl |
Boolean | 是否响应鼠标事件(鼠标移动则动画停止) |
Returns:
- Type
- rotate
setCenter(center)
- Source:
设置中心点
Parameters:
| Name | Type | Description |
|---|---|---|
center |
Array | 中心点 |
setOption(options)
- Source:
设置地图参数
Example
mapObj = map.init(document.getElementById('map'))
let options = {
serverUrl: 'http://192.168.1.50:8080/geoserver',
show: true, //地图的显示状态 true为显示 false 为不显示
roam: 'true', //地图是否开启缩放、平移功能
center: [118.62778784888256, 36.58892145091036], //当前视角中心: [经度, 纬度]
// theme: {
// type: 'tile',
// url: 'http://mape.shanghai-map.net/ArcGIS/rest/services/SHMAP_DZJ/MapServer'
// url: 'http://192.168.4.35:6080/arcgis/rest/services/MZL/MapServer'
// url: 'http://localhost:8080/all'
// }, //地图风格
// center: [117.52359952545166, 49.52355306224895], //当前视角中心: [经度, 纬度]
zoom: 3, //当前地图缩放比例
scaleLimit: [2, 18], //滚轮缩放的边界
// string('dark','blue','white')|mapObjectr{mapId,key} 对应maobox中的mapid和access_token
theme: {
type: 'mapbox',
mapId: 'zhangyujie.a80cdc83',
key: 'sk.eyJ1Ijoiemhhbmd5dWppZSIsImEiOiJkTEp6WDZrIn0.nY5bsQlZegBbb2uGgJ5jEA'
// type: 'arcgis',
// type: 'satellite',
// url: 'http://192.168.1.201/MapTileDownload/googlemaps/satellite'
// url: 'http://192.168.4.35:8080/QingHai/'
// url: 'http://192.168.4.35:6080/arcgis/rest/services/TianJin/MapServer'
// url: 'http://192.168.4.35:6080/a/arcgisserver/directories/arcgiscache/TianJin/%E5%9B%BE%E5%B1%82/_alllayers'
}, //地图风格
};
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | 参数 |
setRoam(roam)
- Source:
设置地图响应模式
Parameters:
| Name | Type | Description |
|---|---|---|
roam |
true|false|drag(只拖拽)|scale|roate |
setSceneBearing(value, status)
- Source:
设置场景旋转
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
value |
Number | 旋转速度 |
|
status |
Boolean |
true
|
是否旋转 |
setServerUrl(url)
- Source:
设置请求服务器地址
Parameters:
| Name | Type | Description |
|---|---|---|
url |
String | 服务器地址ip |
setSpatialRadius(radius, relative)
- Source:
设置空间查询半径
Parameters:
| Name | Type | Description |
|---|---|---|
radius |
Number | 半径 |
relative |
Boolean | 是否相对位置,默认为相对位置 |
setTheme(theme)
- Source:
设置底图风格
Parameters:
| Name | Type | Description |
|---|---|---|
theme |
String | setTheme('url'); |
setView(geo)
- Source:
设置可视参数
Parameters:
| Name | Type | Description |
|---|---|---|
geo |
Object | 地图参数 |
showLayer(id)
- Source:
显示图层
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
showMarker(id)
- Source:
显示标记
Parameters:
| Name | Type | Description |
|---|---|---|
id |
String | id |
spatialQuery(obj)
- Source:
空间查询
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
* |
unproject(Number, Number)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
Number |
x | 屏幕像素x |
Number |
y | 屏幕像素y |
updateLayer(arrays)
- Source:
更新图层
Parameters:
| Name | Type | Description |
|---|---|---|
arrays |
Object | serie对象 |
updateThreeBoxScene()
- Source:
zoomTo(num, relative)
- Source:
缩放到指定级别
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
num |
Number |
1
|
级别 |
relative |
Boolean |
false
|
是否相对级别 |