2024-09-20 15:02:50 +08:00
|
|
|
import POILayer2D from "./POILayer2D";
|
|
|
|
|
import Style from 'ol/style/Style';
|
|
|
|
|
import StrokeStyle from 'ol/style/Stroke';
|
|
|
|
|
import { zindex2d } from "../../zindex";
|
|
|
|
|
|
|
|
|
|
export default class BouaLayer2D extends POILayer2D {
|
|
|
|
|
static LayerName = 'BouaLayer';
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super({ ...props, rowKey: 'code' });
|
|
|
|
|
|
|
|
|
|
this._style0 = new Style({
|
|
|
|
|
zIndex: zindex2d.boua1,
|
|
|
|
|
stroke: new StrokeStyle({
|
|
|
|
|
color: 'rgba(22,227,200, 0.5)',
|
|
|
|
|
width: 3,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this._style1 = new Style({
|
|
|
|
|
zIndex: zindex2d.boua2,
|
|
|
|
|
stroke: new StrokeStyle({
|
|
|
|
|
color: 'rgb(91,123,188,0.4)',//'rgba(122,227,200, 0.1)',
|
|
|
|
|
lineDash: [15,10,5,10],
|
|
|
|
|
width: 3,
|
|
|
|
|
opacity:0.5,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
this._style1Highlight = new Style({
|
|
|
|
|
zIndex: zindex2d.bouahighlight,
|
|
|
|
|
stroke: new StrokeStyle({
|
|
|
|
|
color: 'rgb(255, 0, 0,1)',
|
|
|
|
|
width: 2.5,
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this._styleLabel = {};
|
|
|
|
|
|
|
|
|
|
this.highlights = this.getHighlightMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLayerName() {
|
|
|
|
|
return BouaLayer2D.LayerName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async dataPromise() {
|
|
|
|
|
const address = localStorage.getItem('address');
|
2024-09-29 16:24:07 +08:00
|
|
|
const a1 = await fetch(`${process.env.PUBLIC_URL}/data/geojson/macheng/县界.geojson`)
|
2024-09-20 15:02:50 +08:00
|
|
|
.then(resp => resp.json())
|
|
|
|
|
.then(data => data.features)
|
|
|
|
|
.then(features => features.map(o => ({
|
|
|
|
|
...o.properties,
|
|
|
|
|
geometry: o.geometry,
|
|
|
|
|
type: 'boua',
|
|
|
|
|
ADCD: `${o.properties.ADCD}000000000`.substr(0, 15)
|
|
|
|
|
})))
|
|
|
|
|
.catch(() => []);
|
|
|
|
|
//console.log("a1++++",a1);
|
|
|
|
|
|
|
|
|
|
return [...a1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
styleFunc = ({ props }) => {
|
|
|
|
|
if (this.highlights[props.code]) {
|
|
|
|
|
return this._style1Highlight;
|
|
|
|
|
}
|
|
|
|
|
if (!this.isVisible()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (props.type === 'label') {
|
|
|
|
|
return this._styleLabel[props.code];
|
|
|
|
|
}
|
|
|
|
|
if (props.type === 'xj') {
|
|
|
|
|
return this._style0;
|
|
|
|
|
}else {
|
|
|
|
|
return this._style1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSetting(setting) {
|
|
|
|
|
if (setting?.highlight?.BouaLayer !== this._setting?.highlight?.BouaLayer) {
|
|
|
|
|
this.highlights = this.getHighlightMap(setting?.highlight);
|
|
|
|
|
this.redrawLayer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._setting = setting;
|
|
|
|
|
}
|
|
|
|
|
}
|