Newer
Older
KaiFengPC / src / views / sponeScreen / gisMF / changeMapStyle.js
@jimengfei jimengfei on 9 Aug 2 KB updata
  1. import blue_vector from './mapStyle.js';
  2. import white_vector from './whiteMapStyle.js';
  3. export default class changeMapStyle {
  4. //地图白色风格
  5. static mapSetWhiteStyle(newfiberMap) {
  6. let removedLayers = newfiberMap
  7. .getMap()
  8. .imageryLayers._layers.filter(
  9. layer =>
  10. layer.imageryProvider.newfiberId == 'blackMap' || (layer.imageryProvider.url && layer.imageryProvider.url.includes('style=6'))
  11. );
  12. let selectedLayer = newfiberMap.getMap().imageryLayers._layers.filter(layer => layer.imageryProvider.newfiberId == 'whiteMap');
  13. removedLayers.forEach(layer => {
  14. layer.show = false;
  15. });
  16. newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(238,251,255,1)');
  17. selectedLayer[0].show = true;
  18. }
  19. //地图深色风格
  20. static mapSetBlueStyle(newfiberMap) {
  21. let removedLayers = newfiberMap
  22. .getMap()
  23. .imageryLayers._layers.filter(
  24. layer =>
  25. layer.imageryProvider.newfiberId == 'whiteMap' || (layer.imageryProvider.url && layer.imageryProvider.url.includes('webst0'))
  26. );
  27. let selectedLayer = newfiberMap.getMap().imageryLayers._layers.filter(layer => layer.imageryProvider.newfiberId == 'blackMap');
  28. removedLayers.forEach(layer => {
  29. layer.show = false;
  30. });
  31. if (!selectedLayer[0]) {
  32. var layer = new NewFiberMap.Layer.MVTImageryProvider({
  33. style: blue_vector,
  34. tileSize: 1024,
  35. });
  36. layer.newfiberId = 'blackMap';
  37. newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(8,27,54,1)');
  38. newfiberMap.getMap().imageryLayers.addImageryProvider(layer);
  39. } else {
  40. newfiberMap.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString('rgba(8,27,54,1)');
  41. selectedLayer[0].show = true;
  42. }
  43. }
  44. //影像图
  45. static mapSetImageStyle(newfiberMap) {
  46. let removedLayers = newfiberMap
  47. .getMap()
  48. .imageryLayers._layers.filter(
  49. layer =>
  50. layer.imageryProvider.newfiberId == 'whiteMap' || (layer.imageryProvider.url && layer.imageryProvider.url.includes('style=7'))
  51. );
  52. let selectedLayer = newfiberMap
  53. .getMap()
  54. .imageryLayers._layers.filter(layer => layer.imageryProvider.url && layer.imageryProvider.url.includes('style=6'));
  55. removedLayers.forEach(layer => {
  56. layer.show = false;
  57. });
  58. if (!selectedLayer[0]) {
  59. newfiberMap.setBaseMapByEnum([NewFiberMap.Enum.BaseMap.AMAP_IMAGE]);
  60. } else {
  61. selectedLayer[0].show = true;
  62. }
  63. }
  64. }