master
loveflow 7 months ago
parent 3b3a6b98bd
commit c8deafe9b2

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<script src="<%= BASE_URL %>baiduapi.js"></script>
<script src="<%= BASE_URL %>TextIconOverlay_min.js"></script>
<script src="<%= BASE_URL %>MarkerClusterer_min.js"></script>
@ -13,8 +13,8 @@
<title>vue</title>
</head>
<style>
body{
margin:0;
body {
margin: 0;
padding: 0;
}
</style>
@ -24,5 +24,9 @@
</noscript> -->
<div id="app"></div>
<!-- built files will be auto injected -->
<script src="./static/config.js"></script>
<script>
console.log(window.mapCfg);
</script>
</body>
</html>

@ -0,0 +1,8 @@
window.mapCfg = {
type: "onLine",//离线地图;地图类型 onLine:在线地图
lgt: "", //经度
lat: "", //纬度
center: [],
zoom: 12,
tiles_dir: "" + "/static/newTiles/{z}/{x}/{y}.png", //瓦片地址
};

@ -1,9 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
#container {
@ -14,78 +13,75 @@
/* 去除百度地图logo */
.anchorBL {
display: none
display: none;
}
</style>
<!-- <script src="https://unpkg.com/mapv-three@1.0.10/dist/mapvthree.umd.js"></script> -->
<script src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=CSfWwqFqSVkQaqcAAMxKyXg6Moe9UUqA"></script>
</head>
<!-- <script
src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=CSfWwqFqSVkQaqcAAMxKyXg6Moe9UUqA"
></script> -->
</head>
<body>
<body>
<div id="container"></div>
<script>
let mapCfg = window.parent.mapCfg;
if (mapCfg.type === "offLine") {
}
if (mapCfg.type === "onLine") {
loadScript();
}
// map.setHeading(64.5);
// map.setTilt(73);
// 禁止地图旋转和倾斜可以通过配置项进行设置
// var map = new BMapGL.Map("allmap", {
// enableRotate: false,
// enableTilt: false
// });
function initMap() {
// 创建地图实例
var map = new BMapGL.Map("container"); // 创建地图实例
var point = new BMapGL.Point(121.619992, 30.025703); // 创建点坐标
window.addEventListener('message', function (event) {
let company_list = event.data
window.addEventListener("message", function (event) {
let company_list = event.data;
//console.log('data01', company_list);
company_list.forEach((item) => {
let company_point = new BMapGL.Point(item.longitude, item.latitude);
let myIcon = {};
// 根据公司排名打点
if (item.areaRank == '1') {
myIcon = new BMapGL.Icon(
'./top01.png',
new BMapGL.Size(40, 60),
{
imageOffset: new BMapGL.Size(0, 0, 5)
}
)
if (item.areaRank == "1") {
myIcon = new BMapGL.Icon("./top01.png", new BMapGL.Size(40, 60), {
imageOffset: new BMapGL.Size(0, 0, 5),
});
var marker = new BMapGL.Marker(company_point, { icon: myIcon }); // 创建点位
marker.disableMassClear();
map.addOverlay(marker);
} else if (item.areaRank == '2') {
myIcon = new BMapGL.Icon(
'./top02.png',
new BMapGL.Size(40, 60),
{
imageOffset: new BMapGL.Size(0, 0, 5)
}
)
} else if (item.areaRank == "2") {
myIcon = new BMapGL.Icon("./top02.png", new BMapGL.Size(40, 60), {
imageOffset: new BMapGL.Size(0, 0, 5),
});
var marker = new BMapGL.Marker(company_point, { icon: myIcon }); // 创建点位
marker.disableMassClear();
map.addOverlay(marker);
} else if (item.areaRank == '3') {
myIcon = new BMapGL.Icon(
'./top03.png',
new BMapGL.Size(40, 60),
{
imageOffset: new BMapGL.Size(0, 0, 5)
}
)
} else if (item.areaRank == "3") {
myIcon = new BMapGL.Icon("./top03.png", new BMapGL.Size(40, 60), {
imageOffset: new BMapGL.Size(0, 0, 5),
});
var marker = new BMapGL.Marker(company_point, { icon: myIcon }); // 创建点位
marker.disableMassClear();
map.addOverlay(marker);
} else if (item.areaRank == '4') {
myIcon = new BMapGL.Icon(
'./top04.png',
new BMapGL.Size(40, 60),
{
imageOffset: new BMapGL.Size(0, 0, 5)
}
)
} else if (item.areaRank == "4") {
myIcon = new BMapGL.Icon("./top04.png", new BMapGL.Size(40, 60), {
imageOffset: new BMapGL.Size(0, 0, 5),
});
var marker = new BMapGL.Marker(company_point, { icon: myIcon }); // 创建点位
marker.disableMassClear();
map.addOverlay(marker);
} else if (item.areaRank == '5') {
myIcon = new BMapGL.Icon(
'./top05.png',
new BMapGL.Size(40, 60),
{
imageOffset: new BMapGL.Size(0, 0, 5)
}
)
} else if (item.areaRank == "5") {
myIcon = new BMapGL.Icon("./top05.png", new BMapGL.Size(40, 60), {
imageOffset: new BMapGL.Size(0, 0, 5),
});
var marker = new BMapGL.Marker(company_point, { icon: myIcon }); // 创建点位
marker.disableMassClear();
map.addOverlay(marker);
@ -95,7 +91,7 @@
let label = new BMapGL.Label(content, {
position: company_point, // 设置标注的地理位置
offset: new BMapGL.Size(-20, -50), // 设置标注的偏移量
})
});
label.setStyle({
backgroundColor: "#f9d2e4",
border: "0",
@ -106,7 +102,7 @@
label.disableMassClear();
map.addOverlay(label);
// 文本点击
label.addEventListener('click', function () {
label.addEventListener("click", function () {
map.clearOverlays(); // 为保证始终只有一个文本覆盖物弹出,每次创造文本覆盖物时,先清楚所有的文本覆盖物
// 注意 clearOverlays会清除地图所有的覆盖物所以要给不想清除的覆盖物加上disableMassClear以做到禁止删除
var point_text = new BMapGL.Label(); // 创建公司详情文本覆盖物
@ -148,20 +144,21 @@
closebtn.addEventListener("click", () => {
map.removeOverlay(point_text);
});
})
})
})
});
});
});
map.centerAndZoom(point, 14); // 初始化地图,设置中心点坐标和地图级别
map.enableScrollWheelZoom();
map.setMapType(BMAP_SATELLITE_MAP); // 卫星地图模式
// map.setHeading(64.5);
// map.setTilt(73);
// 禁止地图旋转和倾斜可以通过配置项进行设置
// var map = new BMapGL.Map("allmap", {
// enableRotate: false,
// enableTilt: false
// });
</script>
</body>
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src =
"//api.map.baidu.com/api?type=webgl&v=1.0&ak=CSfWwqFqSVkQaqcAAMxKyXg6Moe9UUqA&callback=initMap";
document.body.appendChild(script);
}
</script>
</body>
</html>

@ -35,9 +35,9 @@ const router = new VueRouter({
});
router.beforeEach((to, from, next) => {
console.log(to);
/* console.log(to);
console.log(from);
console.log(getToken());
console.log(getToken()); */
if (getToken() || to.path === "/login") {
if (to.path == "/") {
router.push({

@ -20,11 +20,11 @@ request.interceptors.request.use(
(config) => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false;
console.log("isToken:", isToken);
// 是否需要防止数据重复提交
if (getToken() && !isToken) {
config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
//console.log(config)
}
//防止重复提交

Loading…
Cancel
Save