master
loveflow 7 months ago
parent 3b3a6b98bd
commit c8deafe9b2

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

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

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

Loading…
Cancel
Save