mcfxkh-Web/src/views/Home/MapCtrl/mapstyle/adcdlayer.js

151 lines
2.8 KiB
JavaScript
Raw Normal View History

2025-05-19 14:26:18 +08:00
import { openRecordPop } from "../_";
import BaseLayer from "./baselayer";
const SHAPE3 = {
id: '县名称',
type: 'symbol',
source: 'adcd',
filter: ['==', 'level', 4],
minzoom: 1,
maxzoom: 12,
layout: {
'icon-allow-overlap': true,
'text-allow-overlap': true,
'icon-image': 'adcd4',
'icon-size': 0.6,
'text-size': 16,
'text-font': ['Roboto Black'],
'text-field': ['get', 'NAME'],
'text-offset': [0, 0.6],
'text-anchor': 'top',
'text-max-width': 6,
},
paint: {
'text-color': '#fffab8',
'text-halo-color': 'hsl(0, 0%, 20%)',
'text-halo-width': 0.5
}
};
const SHAPE4 = {
'id': '乡镇名称',
'type': 'symbol',
'source': 'adcd',
filter: ['==', 'level', 5],
'minzoom': 1,
'maxzoom': 14,
'layout': {
2025-06-13 14:23:34 +08:00
// 'icon-allow-overlap': true,
// 'text-allow-overlap': true,
2025-05-19 14:26:18 +08:00
'icon-image': 'adcd5',
'icon-size': 0.4,
'text-size': 13,
'text-font': ['Roboto Black'],
'text-field': ['get', 'NAME'],
'text-offset': [0, 0.6],
'text-anchor': 'top',
'text-max-width': 6,
},
'paint': {
'text-color': '#fffab8',
'text-halo-color': '#062040',
'text-halo-width': 1
}
};
const SHAPE5 = {
'id': '村名称',
'type': 'symbol',
'source': 'adcd',
filter: ['==', 'level', 6],
'minzoom': 12,
'maxzoom': 18,
'layout': {
'icon-image': 'adcd6',
'icon-size': 0.4,
'text-size': 12,
'text-font': ['Roboto Black'],
'text-field': ['get', 'NAME'],
'text-offset': [0, 0.6],
'text-anchor': 'top',
'text-max-width': 6
},
'paint': {
'text-color': '#fff',
'text-halo-color': '#062040',
'text-halo-width': 1
}
};
const SHAPE6 = {
'id': '组名称',
'type': 'symbol',
'source': 'adcd',
filter: ['==', 'level', 7],
'minzoom': 13,
'maxzoom': 18,
'layout': {
'icon-image': 'adcd7',
'icon-size': 0.4,
'text-size': 11,
'text-font': ['Roboto Black'],
'text-field': ['get', 'NAME'],
'text-offset': [0, 0.6],
'text-anchor': 'top',
'text-max-width': 6
},
'paint': {
'text-color': '#fff',
'text-halo-color': '#062040',
'text-halo-width': 1
}
};
export default class AdcdLayer extends BaseLayer {
getStyle(index) {
let shp;
if (index === 1) {
shp = SHAPE4;
} else if (index === 2) {
shp = SHAPE5;
} else if (index === 3) {
shp = SHAPE6;
} else {
shp = SHAPE3;
}
this._setStyleVisibility(shp);
return shp;
}
getName() {
return 'AdcdLayer';
}
getSubLayers() {
return [SHAPE3.id, SHAPE4.id, SHAPE5.id, SHAPE6.id];
}
getRefreshInterval() {
return 0;
}
async doRefreshLayer() {
return true;
}
getFeatureTip() {
return null;
}
featureClicked(properties, dispatch) {
console.log(properties);
openRecordPop(dispatch, 'adcd', properties)
}
}