瓦片地图动态引入
This commit is contained in:
parent
dba5d7ca8b
commit
03ceb1d226
@ -95,7 +95,8 @@
|
|||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"postcss": "^8.4.20",
|
"postcss": "^8.4.20",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"sass": "^1.53.0",
|
"sass": "^1.66.0",
|
||||||
|
"sass-loader": "^13.3.0",
|
||||||
"tailwindcss": "^3.2.4",
|
"tailwindcss": "^3.2.4",
|
||||||
"typescript": "^4.7.4",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^4.0.3",
|
"vite": "^4.0.3",
|
||||||
|
@ -2,6 +2,7 @@ window.webConfig = {
|
|||||||
"webApiBaseUrl": "https://edu.mmhyvision.com:8445",
|
"webApiBaseUrl": "https://edu.mmhyvision.com:8445",
|
||||||
"VITEAPPBASEWEB": "https://edu.mmhyvision.com/vision",
|
"VITEAPPBASEWEB": "https://edu.mmhyvision.com/vision",
|
||||||
"webApiBaseApp": "https://edu.mmhyvision.com/parent",
|
"webApiBaseApp": "https://edu.mmhyvision.com/parent",
|
||||||
|
"mapUrl":"http://192.168.1.208",
|
||||||
|
|
||||||
"title": "文档与数据管理系统",
|
"title": "文档与数据管理系统",
|
||||||
"bgImg": "beijing.jpg",
|
"bgImg": "beijing.jpg",
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
import { onMounted, watch, nextTick, onUnmounted } from 'vue'
|
import { onMounted, watch, nextTick, onUnmounted } from 'vue'
|
||||||
import L from 'leaflet'
|
import L from 'leaflet'
|
||||||
import 'leaflet/dist/leaflet.css'
|
import 'leaflet/dist/leaflet.css'
|
||||||
|
import { useUserStore } from '@/store/modules/user';
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const url = userStore.mapUrl;
|
||||||
// 类型定义
|
// 类型定义
|
||||||
interface PointProp {
|
interface PointProp {
|
||||||
points?: Array<[number, number]>;
|
points?: Array<[number, number]>;
|
||||||
@ -53,10 +55,10 @@ function initMap() {
|
|||||||
* 添加离线瓦片图层
|
* 添加离线瓦片图层
|
||||||
*/
|
*/
|
||||||
function addTileLayer() {
|
function addTileLayer() {
|
||||||
L.tileLayer('/tiles/{z}/{y}/{x}.jpg', {
|
L.tileLayer(url+'/{z}/{y}/{x}.jpg', {
|
||||||
attribution: 'Offline Map', // 图层属性说明
|
attribution: 'Offline Map',
|
||||||
tileSize: 256, // 瓦片尺寸
|
tileSize: 256,
|
||||||
noWrap: true // 禁止重复瓦片
|
noWrap: true
|
||||||
}).addTo(map!)
|
}).addTo(map!)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ function createPolyline(latlngs: L.LatLng[]) {
|
|||||||
* @returns 标记实例数组
|
* @returns 标记实例数组
|
||||||
*/
|
*/
|
||||||
function createMarkers(latlngs: L.LatLng[]) {
|
function createMarkers(latlngs: L.LatLng[]) {
|
||||||
return latlngs.map(latlng =>
|
return latlngs.map(latlng =>
|
||||||
L.marker(latlng).addTo(map!)
|
L.marker(latlng).addTo(map!)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -103,12 +105,12 @@ function createMarkers(latlngs: L.LatLng[]) {
|
|||||||
* 主绘制函数
|
* 主绘制函数
|
||||||
* @param points 原始坐标数组
|
* @param points 原始坐标数组
|
||||||
*/
|
*/
|
||||||
function drawTrajectory(points: Array<[number, number]>) {
|
function drawTrajectory(points: Array<[number, number]>) {
|
||||||
if (!map) return
|
if (!map) return
|
||||||
|
|
||||||
// 始终执行清理(无论是否有新坐标)
|
// 始终执行清理(无论是否有新坐标)
|
||||||
clearLayers()
|
clearLayers()
|
||||||
|
|
||||||
// 仅在有有效坐标时创建新元素
|
// 仅在有有效坐标时创建新元素
|
||||||
if (points?.length > 0) {
|
if (points?.length > 0) {
|
||||||
const latlngs = points.map(convertToLatLng)
|
const latlngs = points.map(convertToLatLng)
|
||||||
|
@ -19,6 +19,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
const badgeval = ref('')
|
const badgeval = ref('')
|
||||||
const webApiBaseUrl: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_API : window.webConfig.webApiBaseUrl
|
const webApiBaseUrl: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_API : window.webConfig.webApiBaseUrl
|
||||||
const webApiBaseHttp: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_WEB : window.webConfig.VITEAPPBASEWEB
|
const webApiBaseHttp: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_WEB : window.webConfig.VITEAPPBASEWEB
|
||||||
|
const mapUrl: any = window.webConfig.mapUrl
|
||||||
const webApiBaseApp: any = window.webConfig.webApiBaseApp
|
const webApiBaseApp: any = window.webConfig.webApiBaseApp
|
||||||
const title = window.webConfig.title
|
const title = window.webConfig.title
|
||||||
const content1 = window.webConfig.content1
|
const content1 = window.webConfig.content1
|
||||||
@ -116,6 +117,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
resetToken,
|
resetToken,
|
||||||
badgeval,
|
badgeval,
|
||||||
webApiBaseUrl,
|
webApiBaseUrl,
|
||||||
|
mapUrl,
|
||||||
webApiBaseHttp,
|
webApiBaseHttp,
|
||||||
webApiBaseApp,
|
webApiBaseApp,
|
||||||
title,
|
title,
|
||||||
|
Loading…
Reference in New Issue
Block a user