This commit is contained in:
parent
f8b75b05b1
commit
75b8a11238
|
@ -179,6 +179,8 @@ const mapTownCount = reactive([
|
|||
|
||||
//默认龙游县灰色地块
|
||||
const mapTownDataDK = reactive([]);
|
||||
//社区地块
|
||||
const xkzDk = reactive([]);
|
||||
var map = null;
|
||||
const initMap = () => {
|
||||
map = new BMapGL.Map("map", { minZoom: 11, maxZoom: 20 });
|
||||
|
@ -238,6 +240,47 @@ const addPolygonCounty = () => {
|
|||
createCustomOverlayJd(item);
|
||||
});
|
||||
};
|
||||
//加载村社信息
|
||||
const loadCs = () => {
|
||||
for (let v of xkz.features) {
|
||||
if (v.geometry.coordinates.length > 1) {
|
||||
for (let w in v.geometry.coordinates) {
|
||||
if (v.geometry.coordinates[w][0].length < 60) continue;
|
||||
xkzDk.push({
|
||||
name: v.properties.name,
|
||||
point: v.geometry.coordinates[w][0],
|
||||
});
|
||||
}
|
||||
} else {
|
||||
xkzDk.push({
|
||||
name: v.properties.name,
|
||||
point: v.geometry.coordinates[0],
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
//添加村社区块
|
||||
const addPolygonCountyCs = () => {
|
||||
console.log(888888,xkzDk);
|
||||
let fillColor = "#red";
|
||||
xkzDk.map((item) => {
|
||||
//地区的坐标范围
|
||||
let points = [];
|
||||
item.point.map((p) => points.push(new BMapGL.Point(...p)));
|
||||
if (points.length) {
|
||||
//创建面
|
||||
let polygonCs = new BMapGL.Polygon(points, {
|
||||
strokeColor: "blue",
|
||||
strokeWeight: 2,
|
||||
strokeOpacity: 0.8,
|
||||
fillColor: fillColor,
|
||||
fillOpacity: 0.7,
|
||||
name: item.name,
|
||||
});
|
||||
map.addOverlay(polygonCs);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 添加地图上的街道名
|
||||
const createCustomOverlayJd = (polygon) => {
|
||||
function createLabelDOM() {
|
||||
|
@ -264,7 +307,14 @@ const createCustomOverlayJd = (polygon) => {
|
|||
div.appendChild(title);
|
||||
title.appendChild(document.createTextNode(this.properties.title));
|
||||
content.appendChild(div);
|
||||
|
||||
div.onclick = function () {
|
||||
console.log(11111111, polygon);
|
||||
if (polygon.name == "溪口镇") {
|
||||
loadCs();
|
||||
addPolygonCountyCs();
|
||||
console.log(2222);
|
||||
}
|
||||
};
|
||||
return content;
|
||||
}
|
||||
var customOverlay = new BMapGL.CustomOverlay(createLabelDOM, {
|
||||
|
|
Loading…
Reference in New Issue