园林绿化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

  1. //火星科技定义的geoserver发布的pdf的Sld样式(未调试完成)
  2. (function (window) {
  3. class MarsPbfStyle {
  4. constructor(options) {
  5. this.options = options;
  6. this.ol = window.ol;
  7. }
  8. //对外主要方法
  9. getStyle() {
  10. let that = this;
  11. return function (feature, resolution) {
  12. that.type = feature.getGeometry().getType();
  13. that.properties = feature.getProperties();
  14. that.resolution = resolution;
  15. that.scale = 1 / (0.0254 / (96 * resolution));
  16. //通过外部接口获取style配置信息
  17. var styleCfg = that.options.getStyle(that.properties, that);
  18. var style = {};
  19. if (styleCfg.stroke) {
  20. //线
  21. style.stroke = new ol.style.Stroke({ color: styleCfg.color, width: styleCfg.width });
  22. }
  23. if (styleCfg.fill) {
  24. //面
  25. style.fill = new ol.style.Fill({ color: styleCfg.fillColor });
  26. }
  27. // 组装层级样式
  28. style.zIndex = that.options.zIndex || 1;
  29. return [new ol.style.Style(style)];
  30. };
  31. }
  32. }
  33. //对外接口
  34. window.mars3d.MarsPbfStyle = MarsPbfStyle;
  35. })(window);