This commit is contained in:
姚宇浩 2024-07-24 11:44:17 +08:00
parent d9fdca24b3
commit 79101c745b
1 changed files with 259 additions and 46 deletions

View File

@ -240,6 +240,84 @@ const mapTownCount = reactive([
const mapTownDataDK = reactive([]); const mapTownDataDK = reactive([]);
// //
const xkzDk = reactive([]); const xkzDk = reactive([]);
//
const xkzCenter = reactive([
{
name: "溪口村",
center: [119.204344, 28.862394],
number: "50",
},
{
name: "扁石村",
center: [119.183549, 28.858],
number: "50",
},
{
name: "大垅村",
center: [119.170309, 28.862776],
number: "50",
},
{
name: "枫林村",
center: [119.205442, 28.862981],
number: "50",
},
{
name: "双港口村",
center: [119.211353, 28.869576],
number: "50",
},
{
name: "灵上村",
center: [119.177185, 28.874582],
number: "50",
},
{
name: "灵下村",
center: [119.175233, 28.878677],
number: "50",
},
{
name: "下徐村",
center: [119.177544, 28.882818],
number: "50",
},
{
name: "大沃口村",
center: [119.17661, 28.880171],
number: "50",
},
{
name: "寺下村",
center: [119.1718, 28.89816],
number: "50",
},
{
name: "大阳家村",
center: [119.176573, 28.898746],
number: "50",
},
{
name: "石角村",
center: [119.141602, 28.919005],
number: "50",
},
{
name: "红罗村",
center: [119.206318, 28.913218],
number: "50",
},
{
name: "冷水村",
center: [119.213226, 28.93395],
number: "50",
},
{
name: "新溪社区",
center: [119.184555, 28.853068],
number: "50",
},
]);
var map = null; var map = null;
const initMap = () => { const initMap = () => {
map = new BMapGL.Map("map", { minZoom: 11, maxZoom: 20 }); map = new BMapGL.Map("map", { minZoom: 11, maxZoom: 20 });
@ -299,11 +377,9 @@ const addPolygonCounty = () => {
}; };
// //
const addJd = () => { const addJd = () => {
mapTownCount.map((item) => { mapTownCount.map((item) => {
createCustomOverlayJd(item); createCustomOverlayJd(item);
}); });
}; };
//2 //2
const addJd2 = () => { const addJd2 = () => {
@ -354,7 +430,7 @@ const addPolygonCountyCs = () => {
} }
}); });
}; };
// //
const createCustomOverlayJd = (polygon) => { const createCustomOverlayJd = (polygon) => {
function createLabelDOM() { function createLabelDOM() {
var content = document.createElement("div"); var content = document.createElement("div");
@ -392,6 +468,7 @@ const createCustomOverlayJd = (polygon) => {
jdCenter = item.center; jdCenter = item.center;
} }
}); });
addCs();
goMapCenter(jdCenter, 14); goMapCenter(jdCenter, 14);
} }
}; };
@ -408,7 +485,7 @@ const createCustomOverlayJd = (polygon) => {
}); });
map.addOverlay(customOverlay); map.addOverlay(customOverlay);
}; };
// +(,) // +(,)
const createCustomOverlayJd2 = (polygon) => { const createCustomOverlayJd2 = (polygon) => {
function createLabelDOM() { function createLabelDOM() {
var content = document.createElement("div"); var content = document.createElement("div");
@ -454,6 +531,7 @@ const createCustomOverlayJd2 = (polygon) => {
jdCenter = item.center; jdCenter = item.center;
} }
}); });
addCs2();
goMapCenter(jdCenter, 14); goMapCenter(jdCenter, 14);
} }
}; };
@ -471,6 +549,140 @@ const createCustomOverlayJd2 = (polygon) => {
}); });
map.addOverlay(customOverlay); map.addOverlay(customOverlay);
}; };
//
const addCs = () => {
xkzCenter.map((item) => {
createCs(item);
});
};
//
const addCs2 = () => {
xkzCenter.map((item) => {
createCs2(item);
});
};
//+(,)
const createCs2 = (polygon) => {
function createLabelDOM() {
var content = document.createElement("div");
content.style.display = "flex";
content.style.flexDirection = "column";
content.style.alignItems = "center";
content.style.zIndex = BMapGL.Overlay.getZIndex(this.point.lat);
var div = document.createElement("div");
div.style.color = "#333";
div.style.whiteSpace = "nowrap";
div.style.MozUserSelect = "none";
div.style.display = "flex";
div.style.justifyContent = "center";
div.style.alignItems = "center";
div.style.cursor = "pointer";
div.style.padding="10px"
div.style.backgroundColor = "red";
div.style.borderRadius = "20%";
div.style.transform = "translateY(50px)";
div.setAttribute("name", this.properties.title);
var title = document.createElement("div");
title.style.fontSize = "16px";
title.style.fontWeight = "600";
title.style.color = "#000000";
div.appendChild(title);
title.appendChild(document.createTextNode(this.properties.title));
content.appendChild(div);
var number = document.createElement("div");
number.style.fontSize = "16px";
number.style.fontWeight = "600";
number.style.color = "rgba(0, 255, 189, 1)";
div.appendChild(number);
number.appendChild(document.createTextNode(this.properties.number));
content.appendChild(div);
let img2 = document.createElement("img");
img2.style.width = "20px";
img2.style.height = "20px";
img2.src = this.properties.imgSrc2;
content.appendChild(div);
content.appendChild(img2);
// div.onclick = function () {
// let jdCenter = [];
// if (polygon.name == "") {
// title_choose.value = title_choose.value + `>${polygon.name}`;
// console.log(title_choose.value);
// loadCs();
// addPolygonCountyCs();
// mapTownCount.map((item) => {
// if (item.name == "") {
// jdCenter = item.center;
// }
// });
// goMapCenter(jdCenter, 14);
// }
// };
return content;
}
var customOverlay = new BMapGL.CustomOverlay(createLabelDOM, {
point: new BMapGL.Point(...polygon.center),
opacity: 0.5,
offsetY: 0,
properties: {
title: polygon.name,
number: polygon.number,
imgSrc2: dwd,
type: "customOverlay",
},
});
map.addOverlay(customOverlay);
};
//
const createCs = (polygon) => {
function createLabelDOM() {
var content = document.createElement("div");
content.style.display = "flex";
content.style.flexDirection = "column";
content.style.alignItems = "center";
content.style.zIndex = BMapGL.Overlay.getZIndex(this.point.lat);
var div = document.createElement("div");
div.style.color = "#333";
div.style.whiteSpace = "nowrap";
div.style.MozUserSelect = "none";
div.style.display = "flex";
div.style.justifyContent = "center";
div.style.alignItems = "center";
div.style.cursor = "pointer";
div.setAttribute("name", this.properties.title);
var title = document.createElement("div");
title.style.fontSize = "16px";
title.style.fontWeight = "600";
title.style.color = "#000000";
div.appendChild(title);
title.appendChild(document.createTextNode(this.properties.title));
content.appendChild(div);
let img2 = document.createElement("img");
img2.style.width = "20px";
img2.style.height = "20px";
img2.src = this.properties.imgSrc2;
content.appendChild(div);
content.appendChild(img2);
return content;
}
var customOverlay = new BMapGL.CustomOverlay(createLabelDOM, {
point: new BMapGL.Point(...polygon.center),
opacity: 0.5,
offsetY: 0,
properties: {
title: polygon.name,
imgSrc2: dwd,
type: "customOverlay",
},
});
map.addOverlay(customOverlay);
};
// //
const addggfwq = () => { const addggfwq = () => {
fwqList.value.map((item) => { fwqList.value.map((item) => {
@ -553,6 +765,7 @@ const createCustomOverlay = (polygon) => {
// }); // });
map.addOverlay(customOverlay); map.addOverlay(customOverlay);
}; };
// //
const goMapCenter = (point, zoom) => { const goMapCenter = (point, zoom) => {
map.centerAndZoom(new BMapGL.Point(point[0], point[1]), zoom); map.centerAndZoom(new BMapGL.Point(point[0], point[1]), zoom);