mirror of https://gitee.com/xiaonuobase/snowy
【更新】地图 方法注释优化
parent
a396426aa5
commit
2ce089c7aa
|
@ -65,9 +65,7 @@
|
|||
head.appendChild(script)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 地图
|
||||
*/
|
||||
// 初始化 地图
|
||||
window.initMap = () => {
|
||||
baiduMap.value = new BMapGL.Map(`container-${props.mid}`)
|
||||
// 滚轮放大缩小
|
||||
|
@ -98,9 +96,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 控制控件
|
||||
*/
|
||||
// 初始化 控制控件
|
||||
const initControlPlugin = () => {
|
||||
// 比例尺
|
||||
props.plugins.includes('BMap.ScaleControl') && baiduMap.value.addControl(new BMapGL.ScaleControl())
|
||||
|
@ -112,10 +108,7 @@
|
|||
props.plugins.includes('BMap.NavigationControl3D') && baiduMap.value.addControl(new BMapGL.NavigationControl3D())
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 点标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 点标记
|
||||
const renderMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const point = new BMapGL.Point(d.position[0], d.position[1])
|
||||
|
@ -138,10 +131,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 图标标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 图标标记
|
||||
const renderIconMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const point = new BMapGL.Point(d.position[0], d.position[1])
|
||||
|
@ -166,10 +156,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 3D圆点标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 3D圆点标记
|
||||
const render3DCircleMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const point = new BMapGL.Point(d.position[0], d.position[1])
|
||||
|
@ -201,10 +188,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 3D图标标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 3D图标标记
|
||||
const render3DIconMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const point = new BMapGL.Point(d.position[0], d.position[1])
|
||||
|
@ -232,11 +216,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 线
|
||||
* @param dataArr
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 线
|
||||
const renderPolyline = (dataArr, option = {}) => {
|
||||
dataArr.forEach((d) => {
|
||||
baiduMapPointArr.value.push(new BMapGL.Point(d.position[0], d.position[1]))
|
||||
|
@ -253,12 +233,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 圆
|
||||
* @param position
|
||||
* @param radius
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 圆
|
||||
const renderCircle = (position, radius, option = {}) => {
|
||||
const point = new BMapGL.Point(position[0], position[1])
|
||||
baiduMapPointArr.value.push(point)
|
||||
|
@ -273,11 +248,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 面
|
||||
* @param dataArr
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 面
|
||||
const renderPolygon = (dataArr, option = {}) => {
|
||||
dataArr.forEach((d) => {
|
||||
baiduMapPointArr.value.push(new BMapGL.Point(d.position[0], d.position[1]))
|
||||
|
@ -296,10 +267,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 视图级别
|
||||
* @param point
|
||||
*/
|
||||
// 设置 视图级别
|
||||
const setFitView = (point) => {
|
||||
if (!point) {
|
||||
const viewPort = baiduMap.value.getViewport(baiduMapPointArr.value)
|
||||
|
@ -316,10 +284,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 信息窗体
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 信息窗体
|
||||
const renderInfoWindow = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
baiduMapInfoWindowObj.value[d.position] = new BMapGL.InfoWindow(d.content.join('<br>'), {
|
||||
|
@ -330,10 +295,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开 信息窗体
|
||||
* @param position
|
||||
*/
|
||||
// 打开 信息窗体
|
||||
const openInfoWindow = (position) => {
|
||||
const infoWindow = baiduMapInfoWindowObj.value[position]
|
||||
if (infoWindow) {
|
||||
|
@ -341,9 +303,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 覆盖物
|
||||
*/
|
||||
// 清理 覆盖物
|
||||
const clearOverlay = () => {
|
||||
baiduMap.value.clearOverlays()
|
||||
}
|
||||
|
|
|
@ -80,9 +80,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 地图
|
||||
*/
|
||||
// 初始化 地图
|
||||
const initMap = () => {
|
||||
gaodeMap.value = new AMap.Map(`container-${props.mid}`, {
|
||||
viewMode: props.viewMode,
|
||||
|
@ -106,9 +104,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 控制控件
|
||||
*/
|
||||
// 初始化 控制控件
|
||||
const initControlPlugin = () => {
|
||||
// 工具条,控制地图的缩放、平移等
|
||||
props.plugins.includes('AMap.ToolBar') && gaodeMap.value.addControl(new AMap.ToolBar({}))
|
||||
|
@ -122,10 +118,7 @@
|
|||
props.plugins.includes('AMap.Geolocation') && gaodeMap.value.addControl(new AMap.Geolocation({}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 点标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 点标记
|
||||
const renderMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const marker = new AMap.Marker({
|
||||
|
@ -149,10 +142,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 圆点标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 圆点标记
|
||||
const renderCircleMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const marker = new AMap.CircleMarker({
|
||||
|
@ -182,11 +172,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 简单点标记
|
||||
* @param dataArr
|
||||
* @param theme
|
||||
*/
|
||||
// 渲染 简单点标记
|
||||
const renderSimpleMarker = (dataArr, theme = 'default') => {
|
||||
dataArr.forEach((d) => {
|
||||
const marker = new AMapUI.SimpleMarker({
|
||||
|
@ -218,10 +204,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 字体点标记
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 字体点标记
|
||||
const renderAwesomeMarker = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
const marker = new AMapUI.AwesomeMarker({
|
||||
|
@ -250,9 +233,7 @@
|
|||
setFitView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 视图级别
|
||||
*/
|
||||
// 设置 视图级别
|
||||
const setFitView = () => {
|
||||
// 点聚合
|
||||
props.markerCluster && new AMap.MarkerCluster(gaodeMap.value, gaodeMapMarkerArr.value)
|
||||
|
@ -261,11 +242,7 @@
|
|||
gaodeMap.value.setFitView(gaodeMapMarkerArr.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 线
|
||||
* @param dataArr
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 线
|
||||
const renderPolyline = (dataArr, option = {}) => {
|
||||
const path = []
|
||||
dataArr.forEach((d) => {
|
||||
|
@ -287,12 +264,7 @@
|
|||
gaodeMap.value.setFitView([polyline])
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 圆
|
||||
* @param position
|
||||
* @param radius
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 圆
|
||||
const renderCircle = (position, radius, option) => {
|
||||
const circle = new AMap.Circle({
|
||||
center: new AMap.LngLat(position[0], position[1]),
|
||||
|
@ -309,11 +281,7 @@
|
|||
gaodeMap.value.setFitView([circle])
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 面
|
||||
* @param dataArr
|
||||
* @param option
|
||||
*/
|
||||
// 渲染 面
|
||||
const renderPolygon = (dataArr, option = {}) => {
|
||||
const path = []
|
||||
dataArr.forEach((d) => {
|
||||
|
@ -334,10 +302,7 @@
|
|||
gaodeMap.value.setFitView([polygon])
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 信息窗体
|
||||
* @param dataArr
|
||||
*/
|
||||
// 渲染 信息窗体
|
||||
const renderInfoWindow = (dataArr) => {
|
||||
dataArr.forEach((d) => {
|
||||
gaodeMapInfoWindowObj.value[d.position] = new AMap.InfoWindow({
|
||||
|
@ -351,10 +316,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开 信息窗体
|
||||
* @param position
|
||||
*/
|
||||
// 打开 信息窗体
|
||||
const openInfoWindow = (position) => {
|
||||
const infoWindow = gaodeMapInfoWindowObj.value[position]
|
||||
if (infoWindow) {
|
||||
|
@ -362,9 +324,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 覆盖物
|
||||
*/
|
||||
// 清理 覆盖物
|
||||
const clearOverlay = () => {
|
||||
gaodeMap.value.clearMap()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue