Newer
Older
KaiFengPC / src / views / sponeScreen / gisMF / changeMapStyle.js
@wudi wudi on 26 Jun 2 KB 1
import blue_vector from './mapStyle.js';
import white_vector from './whiteMapStyle.js';
export default class changeMapStyle {
  //地图白色风格
  static mapSetWhiteStyle(newfiberMap) {
    let removedLayers = newfiberMap
      .getMap()
      .imageryLayers._layers.filter(
        layer =>
          layer.imageryProvider.newfiberId == 'blackMap' || (layer.imageryProvider.url && layer.imageryProvider.url.includes('webst0'))
      );
    let selectedLayer = newfiberMap.getMap().imageryLayers._layers.filter(layer => layer.imageryProvider.newfiberId == 'whiteMap');
    removedLayers.forEach(layer => {
      layer.show = false;
    });
    if (!selectedLayer[0]) {
      var layer = new NewFiberMap.Layer.MVTImageryProvider({
        style: white_vector,
        tileSize: 1024,
      });
      layer.newfiberId = 'whiteMap';
      newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(238,251,255,1)');
      newfiberMap.getMap().imageryLayers.addImageryProvider(layer);
    } else {
      newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(238,251,255,1)');
      selectedLayer[0].show = true;
    }
  }
  //地图深色风格
  static mapSetBlueStyle(newfiberMap) {
    let removedLayers = newfiberMap
      .getMap()
      .imageryLayers._layers.filter(
        layer =>
          layer.imageryProvider.newfiberId == 'whiteMap' || (layer.imageryProvider.url && layer.imageryProvider.url.includes('webst0'))
      );
    let selectedLayer = newfiberMap.getMap().imageryLayers._layers.filter(layer => layer.imageryProvider.newfiberId == 'blackMap');
    removedLayers.forEach(layer => {
      layer.show = false;
    });
    if (!selectedLayer[0]) {
      var layer = new NewFiberMap.Layer.MVTImageryProvider({
        style: blue_vector,
        tileSize: 1024,
      });
      layer.newfiberId = 'blackMap';
      newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(8,27,54,1)');
      newfiberMap.getMap().imageryLayers.addImageryProvider(layer);
    } else {
      newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(8,27,54,1)');
      selectedLayer[0].show = true;
    }
  }
  //影像图
  static mapSetImageStyle(newfiberMap) {
    let removedLayers = newfiberMap
      .getMap()
      .imageryLayers._layers.filter(
        layer => layer.imageryProvider.newfiberId == 'whiteMap' || layer.imageryProvider.newfiberId == 'blackMap'
      );
    let selectedLayer = newfiberMap
      .getMap()
      .imageryLayers._layers.filter(layer => layer.imageryProvider.url && layer.imageryProvider.url.includes('webst0'));
    removedLayers.forEach(layer => {
      layer.show = false;
    });
    if (!selectedLayer[0]) {
      newfiberMap.setBaseMapByEnum([NewFiberMap.Enum.BaseMap.ARCGIS_VECTOR_BLUE]);
    } else {
      selectedLayer[0].show = true;
    }
  }
}